Repository navigation
test(cpu): pin the #4181 int4pack dispatch and dequantize contracts - #4428
Merged
Merged
Conversation
Add CPU-only regression coverage for the four #4181 failure modes: odd out_features (8 and 100) must fall through AUTO to TorchLinear and forward, group_size == in_features (512/512 and 1024/1024) must not select the Aten or Fused CPU int4pack kernels, and dequantize_model must keep bias=None (not a shape-[0] parameter) and preserve BF16 weights with a working forward for TorchLinear, TorchAtenLinear, and TorchFusedLinear. The production fixes are already on main (c9fb1ed for the dispatch contracts and dequantize bias, 266a448/#4370 for the shared dequantize dtype helper); this commit pins them with tests that fail at 2bc2f63. The ATen CPU packer really requires N % 16 == 0, so the existing [16] declaration is kept rather than the issue's suggested [8].
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.
Closes #4181 (coverage; the product fixes already landed).
Status of the four findings
I verified each against current
mainrather than re-landing anything:TorchAtenLinear/TorchFusedLineardeclaredSUPPORTS_OUT_FEATURES_DIVISIBLE_BY=[1], so AUTO accepted odd widths andtransform_cpu'szero_codes.reshape(self.scales.shape)failedTorchAtenLineardeclares[16](the ATen CPU packer requiresN % 16 == 0;N=8raisesexpect N to be dividable by 16).TorchFusedLinearkeeps[8]for XPU plus a CPU-only 16 checkgroup_size == in_features(512/512, 1024/1024) escaped validation and the aten op rejected itdequantize_modelbuiltnn.Parameter(module.bias)withbias=None→ shape-[0]bias, and hard-coded fp16resolve_dequantize_dtype()(#4370)TorchLinearLanded by
c9fb1ed(#4326) and266a448(#4370). The issue text's suggested[8]is looser than the real constraint;[16]is correct.What this PR adds
tests/test_cpu_kernel_constraints_4181.py(CPU-only, 7 tests) so the class of bug cannot return:out_features(8 and 100) → per-module AUTO selection isTorchLinear, forward produces finite(2, N)output;group_size == in_features(512/512, 1024/1024) → per-module AUTO fallback never selectsTorchAtenLinear/TorchFusedLinear;dequantize_modelfor all three kernels on a bias-less layer →bias is None, BF16 weight preserved (not hard-coded FP16), working forward.Verification
tests/kernels/test_selection.py,tests/test_cpu_int4pack_dispatch_contracts.py,tests/test_cpu_torch_avx512*.py→ 168 passed, 123 skipped.2bc2f63, parent ofc9fb1ed, with only the new test file copied in) → 6 failed, 1 passed: odd widths 8/100, gs==K 512/1024, and the Aten/Fused bias cases;TorchLinearpassed becausetorch.pywas already correct.ruff check→ clean.Residual risk
gs == in_featurescase builds the available CPU AUTO candidate set explicitly because the model-wide pass cannot knowin_features; it exercises the real per-module fallback path.2bc2f63(parent of the landed fix) rather than the issue's6c3421c; the relevant declarations are identical.