Repository navigation
test(qqq,exl3): realign stale oracles with the FP32 epilogue and Torch wide path - #3764
Merged
Merged
Conversation
… path Two pre-existing failures on `f68935b61` were stale test contracts, not regressions from the CPU fusion work. QQQ oracle double-rounded the bias. `test_qqq_cpu.oracle` narrowed `accum * scale * channels` to the activation dtype and then added the bias, while the kernel (qqq.py:722, per #3753) keeps the INT8 reduction and its scales in FP32, adds the bias there, and rounds once. On `test_qqq_bias_noncontiguous_and_empty` the double round disagreed on 446/1792 elements by one visible step (<= 0.0039). Bias is now added in FP32 before the single narrowing cast, which makes the oracle match the module bitwise for both float16 and bfloat16. EXL3 audit test pinned a path deleted by #3731. #3717 asserted wide inputs reached the native kernel with FP32 input/output; #3731 (`86a59903e`) routed non-FP16 activations through `ExllamaV3TorchLinear`, whose inner takes only `x` and upcasts to FP32 internally. The stale stub therefore raised `TypeError: forward() missing 1 required positional argument`. The test now pins the live dispatch: wide inputs reach the Torch inner with the caller dtype and never touch `_ensure_inner`, FP16 keeps the native FP16 kernel with an explicit `out_dtype`, and each half asserts the other path is not taken. Added an end-to-end case where 1e10/1e-10 straddle the FP16 range so an FP16-first path would yield inf/0; the module stays finite and within 2e-3 relative L2 of the FP64 oracle. Verified on f68935b (AVX512-BF16 host, torch 2.15.0+cu132): - test_kernel_audit_regressions + test_qqq_cpu: 67 passed - the four exl3/qqq suites: 143 passed, 5 skipped - tests/module_tree fusion/fusable/module_plan: 728 passed, 633 skipped - test_torch_cpu_avx512(+_awq): 87 passed - 12-layout fusion sweep: all exact, err=0.0e+00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two pre-existing failures on
f68935b61were stale test contracts, not regressions from the CPU fusion work (PRs #3762/#3763 touch onlymodels/fusion*.pyandtorch_cpu_avx512_awq.py; neither file is involved here). Both are fixed at the test layer because the kernels are correct.1. QQQ oracle double-rounded the bias
tests/test_qqq_cpu.py::oraclenarrowedaccum * scale * channelsto the activation dtype and then added the bias. The kernel (qqq.py:722, intentional per #3753) keeps the INT8 reduction and its scales in FP32, adds the bias there, and rounds to the visible dtype once.Evidence on
test_qqq_bias_noncontiguous_and_empty[float16/bfloat16]:float16andbfloat16This also satisfies the repo oracle rule (
.agents/skills/gptqmodel-torch-oracle-numerics): never re-round through a low-precision intermediate.2. EXL3 audit test pinned a path deleted by #3731
test_exllamav3_bf16_uses_fp32_native_input_and_outputwas written in #3717 against_ensure_inner. #3731 (86a59903e) routed non-FP16 activations throughExllamaV3TorchLinear, whose_forward_eagertakes a singlex, upcasts to FP32 internally, and returns.to(input_dtype). The stale stub still expected(x, _params, out_dtype=...), so it raised:The test now pins the live dispatch:
_ensure_torch_innerbfloat16)_ensure_inner(fp16, out_dtype=fp16)Each half fails if the other path is reached. This matches the existing contract test in
tests/test_exl3_wide_input.py(#3731).3. New end-to-end numerical guard
test_exllamav3_wide_activations_stay_finite_through_torch_inner[bf16/fp32]feeds1e10and1e-10— values that straddle FP16's range, so an FP16-first path would produceinf/0(verified). The real module stays finite and within2e-3relative L2 of the FP64 oracle.Verification
On
f68935b61, AVX512-BF16 host, torch 2.15.0+cu132, transformers 5.22.2:test_kernel_audit_regressions+test_qqq_cpu: 67 passedkernel_audit_regressions,qqq_cpu,exllamav3_cpu,exl3_wide_input,exl3_cache_signature,exl3_native_half_rounding): 143 passed, 5 skippedtests/module_treefusion/fusable/module_plan: 728 passed, 633 skippedtest_torch_cpu_avx512+_awq: 87 passedto/train_toggle): all exact,err=0.0e+00Scope
Test-only. No production code changed, no packed-weight/cache behavior touched.