Skip to content

test(qqq,exl3): realign stale oracles with the FP32 epilogue and Torch wide path - #3764

Merged
Qubitium merged 1 commit into
mainfrom
fix/stale-oracle-and-exl3-stub
Nov 11, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/stale-oracle-and-exl3-stub

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Two pre-existing failures on f68935b61 were stale test contracts, not regressions from the CPU fusion work (PRs #3762/#3763 touch only models/fusion*.py and torch_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::oracle narrowed accum * scale * channels to 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]:

  • double round disagreed on 446 / 1792 elements, each by one visible step (≤ 0.0039)
  • adding the bias in FP32 before the single cast makes the oracle match the module bitwise exactly for both float16 and bfloat16
raw = accum * scale * channels
if module.bias is not None:
    raw = raw + module.bias.float()     # keep the epilogue wide
visible = raw.to(activation.dtype).reshape(...)

This 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_output was written in #3717 against _ensure_inner. #3731 (86a59903e) routed non-FP16 activations through ExllamaV3TorchLinear, whose _forward_eager takes a single x, upcasts to FP32 internally, and returns .to(input_dtype). The stale stub still expected (x, _params, out_dtype=...), so it raised:

TypeError: Inner.forward() missing 1 required positional argument: '_params'

The test now pins the live dispatch:

input path inner sees result
bf16 (wide) _ensure_torch_inner caller dtype (bfloat16) bf16, finite
fp16 _ensure_inner (fp16, out_dtype=fp16) 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] feeds 1e10 and 1e-10 — values that straddle FP16's range, so an FP16-first path would produce inf/0 (verified). The real module stays finite and within 2e-3 relative 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 passed
  • qqq + exl3 suites (kernel_audit_regressions, qqq_cpu, exllamav3_cpu, exl3_wide_input, exl3_cache_signature, exl3_native_half_rounding): 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 6 linear classes × to/train_toggle): all exact, err=0.0e+00

Scope

Test-only. No production code changed, no packed-weight/cache behavior touched.

… 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
@Qubitium
Qubitium merged commit 1d0d04e into main Nov 11, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/stale-oracle-and-exl3-stub branch November 11, 2026 03:07
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