QNN sharded LLM export fails: ResolveDebugHandle is not the last edge pass (dep_table entry overwritten by SplitGraph registration)
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
🐛 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
- Lenguaje dominante
- Python
- Estrellas
- 5.1k
- Forks
- 1.2k
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 632
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pytorch/executorch
-
Portable remainder kernel: wrong sign for integers and float64 rounded to floatPosiblemente ocupada @JakeStevens la tomó hace 1 día. Abiertobug module: kernels triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
pytorch/executorch#23682 · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
enhancement triaged
Dificultad 2/5 Medio día Aptitud para principiantes 68/100
pytorch/executorch#21640 ·
Los mantenedores suelen responder en 1 día
-
macOS Python wheel _portable_lib has non-relocatable libtorch rpathPosiblemente ocupada @shoumikhin la tomó hoy. Abierto
pytorch/executorch#23742 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Feedback about ToolsAbiertoinvalid module: doc
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
pytorch/executorch#23706 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Portable floor_divide returns non-whole numbers for floats and wrong values for a zero divisorPosiblemente ocupada @JakeStevens la tomó hace 1 día. Abiertobug module: kernels
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
pytorch/executorch#23684 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de pytorch/executorch
Issues similares
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunkPosiblemente ocupada @rodricksz4h5 la tomó hoy. Abiertoarea/streaming comp/gateway P2 type/security
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#138245 ·
Los mantenedores suelen responder en 1 día
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS stepPosiblemente ocupada @github-actions la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
correction metadata
Dificultad 2/5 Menos de una hora Aptitud para principiantes 68/100
acl-org/acl-anthology#10378 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom namePosiblemente ocupada @12YYCCYY16 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
prowler-cloud/prowler#13033 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
graygarbage/HermesKey#23 ·