Skip to content

fix(omni): save and load Qwen2.5-Omni checkpoints in the source HF key layout (#4758) - #4810

Merged
Qubitium merged 2 commits into
mainfrom
fix/issue-4758
Nov 17, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/issue-4758

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Problem

A Qwen2.5-Omni model quantized and saved by GPT-QModel was written in the in-memory Transformers 5.22 layout (thinker.model.audio_tower.*, thinker.model.visual.*, thinker.model.language_model.embed_tokens.*). On reload the reverse map's broad thinker.model.(.+) -> thinker.model.language_model.\1 rule double-prefixed those keys, so the dense tensors were never loaded: the audio tower, vision tower and embed_tokens kept torch.empty storage (random, sometimes NaN) with no warning. All 8 test_omni_lm_head_quantize_save_reload cases failed on main.

Fix

  • gptqmodel/models/definitions/base_qwen2_5_omni.py: add checkpoint_key_for_save / checkpoint_key_for_load built on the model's HF_CONVERSION_MAP_REVERSED (the Gemma3 pattern), so quantized saves write thinker.audio_tower.*, thinker.visual.*, thinker.model.embed_tokens.*, thinker.model.layers.*.
  • gptqmodel/utils/model.py: after a quantized load, _raise_on_unmaterialized_checkpoint_parameters compares the converted checkpoint key set against live parameters and raises a RuntimeError naming them when a non-quantized parameter has no source tensor. It skips meta/lazy-shell params, QUANT_TYPE module params, tied params sharing a loaded tensor and _keys_to_ignore_on_load_missing.
  • gptqmodel/utils/offload.py: restore_offloaded_modules skips a captured base module that was replaced during quantization (the thinker.lm_head bundle collision that caused Offload: base modules remain on the meta device).

Tests

tests/test_qwen2_5_omni_lm_head.py:

  • test_omni_saved_checkpoint_uses_source_hf_layout (GPTQ + RTN, lm_head=False): asserts source-layout keys for the audio tower / vision tower / embed_tokens / decoder and a bit-identical reload from the file;
  • test_omni_load_fails_loudly_on_unmapped_checkpoint_keys.

Red on parent: 2 failed — assert 'thinker.audio_tower.conv1.weight' in {'thinker.model.audio_tower.conv1.weight': ...} (GPTQ + RTN); removing only the save mapping produces the loud does not provide tensors for 50 non-quantized parameter(s) error, matching the issue's 50/82 tensors.

Verification

  • tests/test_qwen2_5_omni_lm_head.py: 19 passed (all 8 original save/reload cases, CPU + cuda:0)
  • test_gemma3_vl_support.py 18 passed; models/test_non_w4a_lifecycle.py 16 passed; test_checkpoint_interop_4053.py 27 passed/1 skipped; legacy VL + LFM2-VL + InternVL: 8 passed/10 skipped
  • ruff check gptqmodel tests: clean
  • test_checkpoint_compat.py::test_untied_lm_head_quantizes_and_reloads fails identically on parent (Marlin JIT, CUDA_HOME unset) — environmental

Closes #4758

@Qubitium
Qubitium merged commit d86b425 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the fix/issue-4758 branch November 17, 2026 15:38
sLaffey pushed a commit to sLaffey/GPTQModel that referenced this pull request Nov 18, 2026
…lCloud#4978)

Seven tests went red because their doubles/oracles predate library changes
that behave as intended. This is test-only; no product code changes.

- test_fusion_kernel_backends: gc.collect() before the weakref check; ModelCloud#4871
  leaves transient Dynamo trace garbage that keeps the pre-fusion weight
  alive. The refs are still asserted dead afterwards.
- test_failed_run_fence_4595: del qmodel + gc.collect() so ModelCloud#4829's finalizer
  runs before the no-leak assertion; a late finalizer must not recreate the
  released run dir.
- test_exl3_projection_resume: add _release_deferred_hessian_sources() to the
  _Capture double (ModelCloud#4837).
- test_kernel_audit_regressions: stub _needs_torch_fallback=lambda: False on
  the SimpleNamespace self (ModelCloud#4835).
- test_moe_resave_preserves_experts_4589: accept the earlier RuntimeError
  "does not provide tensors" refusal (ModelCloud#4810); still assert no safetensors.
- test_positional_mask_capture_4660: build the native oracle with the same
  mask-derived position_ids the capture uses (ModelCloud#4930).
- test_qqq_kernel_memory_4387: snapshot the oracle weight/s_channel before
  the first forward, which may drop the checkpoint layout (ModelCloud#4856).
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