Skip to content

test: realign stale CUDA suite expectations with current contracts (#4241) - #4298

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4241-stale-cuda-tests
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4241-stale-cuda-tests

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4241

What this does

Every test below was reproduced at HEAD on this box (2× RTX 4090, CUDA 13, torch 2.16 dev), then classified against the current library contract before editing. Numeric oracles are independent fp64/stable-torch references, never the code under test. ruff check gptqmodel docs/eora tests setup.py passes.

The only library change is a 2-line behavioral fix plus a refactor in nn_modules/qlinear/{__init__,_fused_train_state}.py: a checkpoint-layout load_state_dict(assign=False) now materializes inference-tensor operands (notably g_idx, which is not part of the snapshot) before the copy. test_runtime_load_materializes_inference_g_idx caught a real gap; the test was right. Everything else is tests/fixtures.

Verification

  • tests/... fixed set: 1013 passed (fixed1.log, 241.69s)
  • tests/test_paroquant.py tests/test_vptq.py tests/test_weight_only.py: 602 passed, 9 skipped (extra1.log)
  • tests/test_torch_weight_storage.py tests/test_qzeros_format_invariant.py tests/test_load_state_assertions.py tests/test_checkpoint_state_invariant.py: 234 passed, 3 skipped
  • ruff check gptqmodel docs/eora tests setup.py: All checks passed

Per-test verdicts

T = test was wrong (test-side fix), L = library was wrong (minimal library fix). Parametrized counts are in parentheses.

qzeros_format marker in state_dict/named_buffers (all T)

The library persists a 1-element int64 qzeros_format marker so a checkpoint round-trip keeps its zero layout (#4125/#4134) and intentionally omits it from HF exports (#4155).

Test Verdict Evidence
test_allspark_linear.py::test_linear_bias_does_not_expand_persistent_storage (2) T only extra bytes are the 8-byte marker
...::test_module_export_keeps_checkpoint_layout (2) T marker is in state_dict(), not in get_state_dict_for_save()
...::test_runtime_state_dict_roundtrip_and_cache_invalidation (2) T marker shape ()
test_allspark_awq_cuda.py::test_awq_module_pack_boundaries_and_dtype_moves (2) T marker buffer
...::test_awq_module_export_keeps_checkpoint_layout (2) T export omits marker
test_marlin_cpu_offload_post_init.py::test_marlin_cpu_offload_refreshes_packed_weights (4) T marker key
kernels/test_gptq_torch_cpu_bias_epilogue.py::test_packed_gptq_cpu_bias_cancels_before_output_rounding (6) T marker key
test_rco_formats.py::test_awq_cost_includes_partial_words_and_metadata (9) T 4.625*256=1184 = payload; 1248-1184 = 64-bit marker

Checkpoint-snapshot state_dict semantics (#4166/#4167) (T, except one L)

state_dict() now emits the checkpoint snapshot; a self round-trip is a checkpoint load that restores checkpoint shapes. A loaded/edited checkpoint exports its real values.

Test Verdict Evidence
test_kernel_audit_regressions.py::test_transformed_cpu_layer_round_trips_its_own_state_dict (12) T post-load qweight shape == snapshot (32,512), round-trip numerics bit-exact
...::test_edited_checkpoint_scales_export_instead_of_stale_snapshot T edited scales are exported; no stale snapshot
...::test_checkpoint_layout_gate_uses_discriminating_operands (6) T runtime dict must be built from live buffers, not state_dict()
...::test_runtime_load_materializes_inference_g_idx L assign=False copy into an inference g_idx raised; library now clones inference operands for checkpoint loads too
test_weight_only.py::test_baseqmodel_quantize_uses_weight_only_rtn_pipeline T RTN pack writes v2 and records qzero_format()==2; numerics vs independent fp64 RTN pass

Mocks missing current APIs (T)

Test Verdict Evidence
test_stage_modules.py::test_run_layer_stage_* (6) T DummyLooper lacked layer_modules_for_prefix (contract from #1998); no-op None keeps global declaration
test_paroquant.py processor tests (13) T SimpleNamespace qcfg lacked resolve_module_config; default resolved config uses qcfg defaults
test_writer_attention.py (2) T _DummyModel.named_modules, _save_model_configs_without_weights(trust_remote_code=...)
test_out_of_model_tensors.py (13) T _DummyModel.named_modules/modules, _DummyQuantizeConfig.has_dynamic_exclusions
test_eora_merge.py::test_eora_covariance_weights_every_batch_uniformly T _FakeModule needed real parameters()/buffers()
test_gemma2_backend_guard.py (2) T _FakeEngine.modules
test_kimi_k3_core_format.py::test_generic_wrapper_crops_padded_output_and_preserves_input_dtype (3) T wrapper gained out_dtype= and a separate non-fp16 torch path
test_specialized_eora_lifecycle.py::test_qqq_packs_uncorrected_weight_after_eora T _quant_linear_kernel(dtype=...)
test_xing4_0_support.py::test_xing4_0_lm_head_hook_reduces_hyperconnection_streams T qcfg gained activation_mode
test_qwen3_vl_dependency.py (3) T test bypassed nn.Module.__init__ and used SimpleNamespace instead of a hook-capable module
test_fp8_nonfinite_source.py::...[smoother-*] (3) T helper moved to qlinear.gguf; patch the definition site
test_moe_expert_batching.py (9) T contradictory restore_subset_capture_frontier=None then .return_value=False; replay is now deferred to the layer stage (1 forward/chunk, not 2)
test_cpp_nvcc_flags.py::test_is_nvcc_compatible_rejects_missing_nvcc T probe also falls back to CUDA_HOME//usr/local/cuda; stub _nvcc_path
test_lazy_kernel_registry_import.py::test_import_gptqmodel_skips_optional_backend_modules T private helpers (_numerics, _runtime_cache, ...) were counted as kernels; 10 public kernels <= 12

Kernel constraints and config changes (T)

Test Verdict Evidence
test_awq_gemv_fast_jit.py (6) T SUPPORTS_IN_FEATURES_DIVISIBLE_BY=[64], out % 128, group_size 128; fixture used 32/8/32
test_qqq_jit.py (3) T QQQ is FP16-only by design; fp32/fp16 fixture used fp32, bf16 case is now an explicit refusal test
kernels/test_awq_gemv_splitk.py::test_real_qwen25_awq_gemv_greedy_decode_stays_finite T QuantizeConfig(dtype=...) rejected (#4052); dtype belongs to GPTQModel.load
test_hunyuan_v1_dense_support.py::test_hunyuan_v1_dense_module_tree_skips_qk_norms T :in=x shared-input tags are part of the tree
test_laguna_support.py::test_laguna_module_tree_expands_dense_attention_and_sparse_moe_paths T g_proj:! is intentional (#2983, kernel-incompatible width)
test_awq_gptq_lifecycle.py::test_awq_capture_is_pre_forward_and_gptq_does_not_receive_the_hook T GPTQ now deliberately registers the MoE pad-zeroing hook (preserve_batch_keep_mask=True)
test_awq_weight_mean.py::test_awq_search_best_scale_coalesces_cpu_activation_replay T chunked reference outputs stay on the replay device by design

Stale numeric fixtures (T)

Test Verdict Evidence
test_quantized_embeddings.py (28) T rand*0.02 produced nonzero scales below fp16 min subnormal; clamped to 1e-3; library correctly rejects storage underflow
test_marlin_scratch_cuda.py::test_scratch_matches_independent_reference[...-awq-...-8-...] (4) T fixture interleaved 8-bit AWQ; library/writer uses natural order. Natural order matches the independent dense reference (max err <=0.016 vs 4.6)
test_q4_exllama_v2.py::test_exllamav2 T baked reference no longer described the version-dependent randint stream; replaced with deterministic nibbles + independent fp64 dequant of the pre-shuffle checkpoint buffers (max err 0.0016)
test_vptq.py::test_vptq_quantizer_matches_independent_oracle[group_size_remainder] T argmin tie ~5e-9; test now accepts a mismatch only when the best/second-best gap <=1e-6
test_paroquant.py::test_paroquant_rotation_backward_folds_frozen_theta_sweep_into_one_reverse_launch T fp32 summation-order drift 1.9e-6; atol raised 1e-6 -> 1e-5
test_paroquant.py::test_paroquant_rotation_fused_bf16_uses_fp16_workspace_contract T old check compared against a fp32-accumulated bf16 reference; now asserts the bf16 kernel tracks the fp16-workspace reference more closely than the fp32 one and within 4 bf16 ulps
test_paroquant.py autotune tests (3) T tests read the user's persistent launch cache; autouse fixture isolates GPTQMODEL_CACHE_DIR

Residual risk

  • The qlinear load change only affects CPU int4pack modules with an inference-tensor operand. The full test_kernel_audit_regressions, test_torch_weight_storage, test_qzeros_format_invariant, test_load_state_assertions, and test_checkpoint_state_invariant suites pass.
  • test_q4_exllama_v2 now checks the checkpoint layout against an independent fp64 dequant before ExLlamaV2's in-place shuffle; it no longer pins a historical baked output.
  • I did not run the entire 13k-item suite. Tests outside this issue's list were not touched. The two kernels touched by other workers (quantization/*, nn_modules/qlinear/*) are limited to the 2-line load materialization above.

…4241)

Each failing test was reproduced at HEAD and classified before editing. Test-side fixes cover the qzeros_format marker, checkpoint-snapshot state_dict semantics, kernel constraints, mock contracts, and stale or non-deterministic numeric references. One real library gap was found and fixed minimally: checkpoint-layout loads now materialize inference-tensor operands such as g_idx before an assign=False copy.
@Qubitium
Qubitium merged commit ca57940 into main Nov 16, 2026
8 of 9 checks passed
@Qubitium
Qubitium deleted the fix/issue-4241-stale-cuda-tests branch November 16, 2026 08:22
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.

[TEST] Stale tests failing at HEAD while the library behaves correctly (CUDA suite triage, 2× RTX 4090)

1 participant