Skip to content

test: realign the qwen3-omni decoder walk and the hessian-release oracle (#4769) - #5187

Merged
Qubitium merged 1 commit into
mainfrom
fix/4769-tests-transformers522
Nov 18, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/4769-tests-transformers522

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4769 (the residual that is still red on this host).

Scope

The issue's last residual comment listed two failures reproducible here at main @ 49a6dc5b9 (RTX 4090, CUDA 13.2, torch 2.15.0+cu132, transformers 5.22.1, py3.14). Both are test-side staleness, not product bugs. Everything else the residual listed was re-verified green in this pass and is untouched.

node red cause
test_qwen_moe_converter.py::test_qwen3_omni_uses_defuser_for_fused_experts AttributeError: 'Qwen3OmniMoeThinkerModel' object has no attribute 'layers' transformers 5.22 nests the thinker decoder under language_model
test_fallback_hessian_release.py::TestFallbackReleasesPartials::test_shared_input_fallback_releases_adopted_source_before_clone IndexError on follower._deferred_hessian_sources[0] adopt_hessian_from now drains the registry itself (#4430)

1. transformers 5.22 decoder nesting

graph LR
  subgraph "transformers 5.20"
    A["thinker"] --> B["model<br/>(Qwen3OmniMoeThinkerModel)"] --> C["layers[0]"]
  end
  subgraph "transformers 5.22"
    D["thinker"] --> E["model<br/>(Qwen3OmniMoeThinkerModel)"] --> F["language_model"] --> G["layers[0]"]
  end
  H["test hard-coded<br/>thinker.model.layers[0]"] -.->|"works on 5.20"| C
  H -.->|"AttributeError on 5.22"| E
Loading

The test walked a fixed path. The product code was already layout-tolerant: Qwen3OmniMoeGPTQ.module_tree lists both thinker.model.layers and thinker.model.language_model.layers, and convert_model reports thinker.model.language_model.layers.0.mlp.experts → _ExpertContainer on 5.22, so nothing was silently skipped.

The fix uses the production accessor gptqmodel.utils.model.thinker_text_model, which is exactly what qwen3_omni_moe.py uses and which returns getattr(thinker.model, "language_model", thinker.model):

layer = thinker_text_model(model).layers[0]

The assertions are unchanged: _assert_converted_experts still runs against the real converted layer and "qwen3_omni_moe" not in MODULE_CONVERTER_MAP is kept.

2. Hessian source release moved to adoption

Before #4430 the release happened at quantize(); the test observed the deferral in between. #4430 made adoption the last consumer and releases immediately, so the deferral is created and drained inside adopt_hessian_from.

sequenceDiagram
  participant L as leader (GPTQ)
  participant F as follower (GPTQ)
  participant Reg as F._deferred_hessian_sources
  Note over L: materialize_global_hessian()
  L->>F: copy leader.H (private follower H)
  F->>Reg: _defer_hessian_sources([leader.H], ready_event)
  rect rgba(200,60,60,0.25)
  Note over F: before #4430 the test read Reg[0] HERE
  end
  F->>Reg: _release_deferred_hessian_sources()  (event.synchronize + clear)
  Note over Reg: now empty when adopt_hessian_from returns
  F->>F: quantize() -> clone_module()
Loading

The invariant the test protects is unchanged and in fact stronger — the adopted source must be gone before the memory-heavy clone_module, so leader H + leader partial + follower copy are never all live at clone time. The test now asserts it at the new boundary: the registry is drained, the follower's ready event was synchronized, and weakref(leader.H) is dead after leader.free() and before quantize(). Reverting the #4430 block makes the retargeted test fail on assert follower._deferred_hessian_sources == [], so the guard is preserved rather than deleted.

follower._hessian_ready_event is used instead of "last event created" so there is no ordering assumption.

Evidence

Red on 49a6dc5b9 (both files, CUDA_VISIBLE_DEVICES=""):

FAILED tests/test_fallback_hessian_release.py::TestFallbackReleasesPartials::test_shared_input_fallback_releases_adopted_source_before_clone
FAILED tests/test_qwen_moe_converter.py::test_qwen3_omni_uses_defuser_for_fused_experts
========================= 2 failed, 15 passed in 4.58s =========================

Green:

run result
the two touched files 17 passed
target tests, 3x in isolation each 1 passed each
test_fallback_hessian_release.py 12 passed
test_qwen_moe_converter.py 5 passed
neighbours: test_fallback.py, test_exl3_projection_resume.py, test_gptq_hessian_accumulation.py, test_gptq_shared_hessian.py, test_gptq_hessian_pipeline.py, test_shared_input_hessian_dedup.py, test_qwen3_omni_embeddings_4816.py, test_defuser_version_check.py, test_qwen3_omni_key_map_4881.py, module_tree/test_model_alignment.py 409 passed, 12 skipped
uvx [email protected] check on both files All checks passed

Not verified

  • transformers 5.20.x runtime (only 5.22.1 installed here); 5.20 compatibility is by inspection of thinker_text_model's getattr fallback.
  • tests/models/test_qwen3_omni.py needs the real 30B checkpoint, unavailable offline.
  • The hessian release lifecycle is exercised with fake events on CPU, as the original test did; no real CUDA event path.
  • Not in scope and untouched: test_bits_new (offline allenai/c4 builder cache), test_quant_batch::test_diff_batch (this venv's flash_attn_2_cuda undefined symbol), and the ROCm/R9700-only remainder.

…cle (#4769)

Two tests in #4769 are still red at 49a6dc5 on this host and both are
test-side staleness, not product bugs.

tests/test_qwen_moe_converter.py
  transformers 5.22 moved the thinker decoder under language_model, so
  model.thinker.model.layers[0] raises AttributeError. Resolve the decoder
  with the production helper gptqmodel.utils.model.thinker_text_model, which
  qwen3_omni_moe.py itself uses and which returns
  getattr(thinker.model, "language_model", thinker.model), so 5.20 and 5.22
  both work. _assert_converted_experts still runs against the real converted
  layer and the MODULE_CONVERTER_MAP assertion is kept.

tests/test_fallback_hessian_release.py
  adopt_hessian_from now releases both deferred-source registries itself
  (260af2a, #4430), so follower._deferred_hessian_sources is already empty
  when the test indexes [0]. The invariant the test protects is unchanged and
  now stronger - the adopted source is released before the memory-heavy
  clone_module - so assert it at the new boundary: the registry is drained,
  the follower's ready event was synchronized, and the leader's H is gone
  before quantization starts.

Red on 49a6dc5: 2 failed, 15 passed. Green: 17 passed. Neighbours: 409
passed, 12 skipped.
@Qubitium
Qubitium marked this pull request as ready for review November 18, 2026 10:17
@Qubitium
Qubitium merged commit 666e2d2 into main Nov 18, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/4769-tests-transformers522 branch November 18, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant