Skip to content

fix test fakes drift and MoE subset hook-order flake - #3012

Merged
Qubitium merged 1 commit into
mainfrom
fix/test-fakes-and-subset-flake
Aug 8, 2026
Merged

fix test fakes drift and MoE subset hook-order flake #3012
Qubitium merged 1 commit into
mainfrom
fix/test-fakes-and-subset-flake

Conversation

@Qubitium

@Qubitium Qubitium commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

1. tests/test_calibration_data_device.py — 3 failing test_stage_capture_* tests (deterministic)

StageInputsCapture.cache_inputs calls get_modules_with_direct_meta_tensors on the model, but the three FakeGPTQModel stubs predate that API → AttributeError: 'FakeGPTQModel' object has no attribute 'get_modules_with_direct_meta_tensors'. Added the classmethod stub (returns []).

Note: these tests are skipped on single-GPU CI (torch.cuda.device_count() < 2), which is why the drift wasn't caught upstream — it fails on multi-GPU hosts.

2. tests/module_tree/test_subset.pytest_qwen3_5_moe_subset_early_stop_follows_module_tree_execution_order (intermittent flake)

The test asserts the last forward hook is mlp.experts.3.up_proj, but with num_experts_per_tok=2 the executed expert set is chosen by the random router weights. Those weights depend on the RNG state at model construction, which shifts with how many earlier test files consumed randomness — so the test passes in isolation and fails after other suites. Routing all experts (num_experts_per_tok=4) makes the executed set and the asserted hook order fully deterministic (verified experts execute in module-tree index order for multiple seeds).

Not ported (ultra-specific, do not exist upstream)

  • module_path kwarg in shell_direct_meta_materialize / turtle materialize fakes (upstream signature has no module_path)
  • get_input_embeddings / get_input_embeddings_name / offload_to_disk fake additions (upstream capture path doesn't call them)

Validation (Python 3.15.0rc1t free-threaded, torch 2.14 nightly cu130; single-GPU = upstream CI env)

Command Result
3 stage-capture tests + run_input_capture (single GPU) 3 passed, 1 skipped
Full tests/test_calibration_data_device.py (single GPU) 18 passed, 4 skipped
tests/module_tree/test_subset.py 13 passed
ruff check on both files clean

All changes are test-only.

Pre-existing (unrelated, fails with and without this change): tests/module_tree/test_moe_flag_parsing.py::test_get_moe_module_name_none_tree — left untouched.

Port of GPT-QModel-Ultra PR #224 to upstream, limited to what applies
here:

- test_calibration_data_device.py: StageInputsCapture.cache_inputs calls
  get_modules_with_direct_meta_tensors on the model, but the three
  FakeGPTQModel stubs predate that API, so the stage-capture tests failed
  with AttributeError on multi-GPU hosts. Add the classmethod stub
  returning an empty list.

- test_subset.py: test_qwen3_5_moe_subset_early_stop_follows_module_tree_
  execution_order asserts the last forward hook is mlp.experts.3.up_proj,
  but with num_experts_per_tok=2 the executed expert set comes from the
  random router weights, whose RNG state shifts with prior test files, so
  the test flakes. Route all experts (num_experts_per_tok=4) to make the
  executed set and hook order deterministic.

The HRM module_path and get_input_embeddings/offload_to_disk fake updates
from the ultra PR do not apply upstream (those APIs do not exist here).
@Qubitium
Qubitium merged commit 0d95ff9 into main Aug 8, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/test-fakes-and-subset-flake branch August 8, 2026 01:05
@Qubitium Qubitium changed the title fix test fakes drift and MoE subset hook-order flake (port of ultra #224) fix test fakes drift and MoE subset hook-order flake Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant