QNN sharded LLM export fails: ResolveDebugHandle is not the last edge pass (dep_table entry overwritten by SplitGraph registration)
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
🐛 Describe the bug
Exporting any sharded LLM through the QNN static-llama flow (num_sharding > 1, i.e. every model ≥ ~3B such as llama3_2-3b_instruct, or a Qwen3-4B registered locally) fails with:
AssertionError: Please ensure ResolveDebugHandle is the last executed edge pass.
File "backends/qualcomm/_passes/qnn_pass_manager.py", line 432, in _validate_edge_passes
Non-sharded models (Qwen3 0.6B/1.7B, etc.) export fine, which is probably why CI has not caught this.
Root cause
When sharding is enabled, the dynamically created SplitGraph pass is registered like this (3 call sites):
dep_table[SplitGraph] = [FoldQDQ]
dep_table[TagQuantIO] = [SplitGraph] # <-- overwrites TagQuantIO: [LayoutTransform]
examples/qualcomm/oss_scripts/llama/wrappers/llm_wrappers.py(two sites)examples/models/llama/export_llama_lib.py(_export_llama, QNN branch)
The assignment replaces the pre-existing entry TagQuantIO: [LayoutTransform] from get_passes_dependency_for_capture_program(), silently dropping the LayoutTransform → TagQuantIO constraint. With that edge gone, the topological solver schedules TagQuantIO (and transitively ResolveDebugHandle, whose only constraint is "after TagQuantIO") too early, so ResolveDebugHandle is no longer last and the (recently added) _validate_edge_passes assertion fires.
Broken schedule tail: ... → ResolveDebugHandle → AnnotateGetAttr → InsertCastForFpActQuantizedWeight
Minimal repro (no device, no weights, runs in seconds):
from torch.fx.passes.infra.pass_manager import this_before_that_pass_constraint
from executorch.backends.qualcomm._passes import FoldQDQ, TagQuantIO
from executorch.backends.qualcomm._passes.qnn_pass_manager import get_qnn_pass_manager_cls
from executorch.extension.llm.custom_ops import model_sharding
cls = get_qnn_pass_manager_cls()
pm = cls()
passes_job = cls.get_capture_program_passes()
dep_table = cls.get_passes_dependency_for_capture_program()
SplitGraph, setting = model_sharding.get_split_graph_pass(36, shares=4, pattern=r"^layers\.(\d+)")
passes_job[SplitGraph] = setting
dep_table[SplitGraph] = [FoldQDQ]
dep_table[TagQuantIO] = [SplitGraph] # verbatim from the call sites above
for that, these in dep_table.items():
for this in these:
pm.add_constraint(this_before_that_pass_constraint(this, that))
for p in passes_job:
pm.add_pass(p)
pm.solve_constraints()
order = [getattr(p, "__name__", str(p)) for p in pm.passes]
assert order[-1] == "ResolveDebugHandle", f"tail: {order[-3:]}" # fails on main
End-to-end repro: python examples/qualcomm/oss_scripts/llama/llama.py --decoder_model llama3_2-3b_instruct ... (any sharded model).
Proposed fix (PR to follow):
- Call sites: append instead of overwrite —
dep_table.setdefault(TagQuantIO, []).append(SplitGraph). - Structural guarantee in
QnnPassManager.get_to_edge_transform_passes: constrainResolveDebugHandleafter every other pass inpasses_job, so dynamically registered passes can never be scheduled after it. This keeps the invariant that_validate_edge_passesasserts, instead of relying on call sites to remember it.
Verified: with the fix, a sharded Qwen3-4B (16a4w, 4 shards) exports and runs on SM8650 (113.8 tok/s prefill, 7.24 tok/s decode), and TestQNNQuantizedOperator.test_qnn_backend_abs --enable_x86_64 passes.
Found and analyzed with AI assistance (Claude Code).
Versions
- executorch: main @ 5e21c13cc9e34fa2922d5708ba5962e3e365afdb (2026-10-05)
- QNN SDK: 2.37.0.250724, SoC: SM8650 (HTP v75)
- torch 2.14.0+cpu, Python 3.11, Ubuntu (Linux 5.15)
cc @cbilgin @psiddh @larryliu0820 @mergennachin @cccclai @helunwencser @jackzhxng @digantdesai
- 主要语言
- Python
- 星标
- 5.1k
- 派生
- 1.2k
- 平均合并
- 2 天 51 分钟
- 30 天内合并 PR
- 712
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/executorch 的其他 Issue
-
Portable remainder kernel: wrong sign for integers and float64 rounded to float可能已有人在做 @JakeStevens 于 2 天前认领。 未关闭bug module: kernels triaged
难度 2/5 1-3 小时 新手友好度 82/100
pytorch/executorch#23682 · 已指派 2 人 ·
维护者通常 1 天内回复
-
enhancement triaged
难度 2/5 半天 新手友好度 68/100
pytorch/executorch#21640 ·
维护者通常 1 天内回复
-
bug module: microcontrollers partner: arm
难度 4/5 3-5 天 新手友好度 38/100
pytorch/executorch#23812 · 1 个 reaction ·
维护者通常 1 天内回复
-
[muse-glimmer] interpolate_pos_emb returns corrupted bf16 values on CPU and can segfault可能已有人在做 @JakeStevens 于 1 天前认领。 未关闭bug module: examples triaged
pytorch/executorch#23797 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
macOS Python wheel _portable_lib has non-relocatable libtorch rpath可能已有人在做 @JacobSzwejbka 今天认领。 未关闭
pytorch/executorch#23742 · 1 条评论 · 已指派 2 人 ·
维护者通常 1 天内回复
查看 pytorch/executorch 的全部 Issue
相似的 Issue
-
Workflow.schedule stops when a cron deadline passes before sleep可能已有人在做 @HuaTNA 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[Bug] HiveDialect shares its colspecs dict with SQLAlchemy's DefaultDialect (python/pyhive)可能已有人在做 @rusackas 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 80/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
[20.0] hr_work_entry: Duration column of Export Time Entries is truncated to whole hours可能已有人在做 @odooaktiv 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
fix formatting of the sample database page of the docs可能已有人在做 @Aaqibhafeezkhan 今天认领。 未关闭documentation good first issue help wanted
难度 1/5 1 小时以内 新手友好度 72/100
chaoss/CollectOSS#544 · 1 条评论 ·
维护者通常 1 天内回复