Repository navigation
test(kernels): resolve the generic torch alias to GGUF_TORCH (#4059 regression) - #4064
Merged
Merged
Conversation
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.
Fixes the #4059 regression in
tests/kernels/test_selection.py::test_gguf_does_not_accept_generic_torch_backend(follow-up to #4053, items 4-8).Option chosen: A — keep the mapping, rewrite the test around the real contract
I kept
"gguf": {BACKEND.TORCH: BACKEND.GGUF_TORCH, BACKEND.TRITON: BACKEND.GGUF_TRITON}and rewrote the test to assert that the generictorchalias resolves toGGUFTorchLinearand not to the genericTorchLinear.Why A:
get_kernel_for_backend()(gptqmodel/utils/importer.py:496-508) filters candidates withquant_method not in cls.SUPPORTS_METHODS, andTorchLinear.SUPPORTS_METHODS == [METHOD.GPTQ](gptqmodel/nn_modules/qlinear/torch.py:183). AMETHOD.GGUFselection can therefore never returnTorchLinear; the old assertion only pinned the pre-alias-table fact thattorchwas absent from_LEGACY_BACKEND_BY_METHOD, which is an implementation detail rather than a contract.torchuniform across methods._LEGACY_BACKEND_BY_METHODis the compat table that translates the legacy generic name into each method's canonical kernel (gptq,awq,fp8,exl3,vptqalready did this). Leaving GGUF out madebackend="torch"raise the exact misleadingUnsupported backend: BACKEND.TORCH for METHOD.GGUFerror that the [BUG] Checkpoint interop: AutoAWQ modules_to_not_convert loads as NaN, format-change re-save writes stale qzeros, HF save_pretrained writes kernel runtime layout, Marlin ignores g_idx, is_marlin_format:false rejected, export broken #4053 Minor bullet reported for QQQ/GGUF/BnB.torchworking for QQQ and BitsAndBytes but not GGUF, which is the inconsistency the issue asked to remove.METHOD.GGUF not in TorchLinear.SUPPORTS_METHODS,normalize_backend(TORCH, GGUF) is GGUF_TORCH, andselect_quant_linear(...) is GGUFTorchLinear and is not TorchLinear. Removing the mapping still fails the test (verified below), so it is not vacuous.Change
tests/kernels/test_selection.pytest_gguf_does_not_accept_generic_torch_backend->test_gguf_accepts_generic_torch_backend_as_gguf_torch_kernel; asserts alias resolution toGGUF_TORCH/GGUFTorchLinear, plusTorchLineardoes not declareMETHOD.GGUF.gptqmodel/utils/backend.pyNo control-flow change: the mapping already shipped in #4059; this PR aligns the test with it. No diagrams required.
Before / after
test_gguf_does_not_accept_generic_torch_backendFailed: DID NOT RAISE ValueErrortest_gguf_accepts_generic_torch_backend_as_gguf_torch_kernelnormalize_backend(BACKEND.TORCH, quant_method=METHOD.GGUF)GGUF_TORCH(mapping from #4059)GGUF_TORCH, now assertedTorchLinearSUPPORTS_METHODS)Test commands and results
CUDA venv (
/opt/venvs/cu130t/bin/python,PYTHONPATH=$PWD):ROCm venv (
/opt/venvs/rocm101t/bin/python,HIP_VISIBLE_DEVICES=2):Fail-before check for the rewritten test (mapping removed in-memory, no file edit):
QQQ and BitsAndBytes double-check
Untouched in this PR.
tests/kernels/test_selection.pycovers the whole file (135 passed on CUDA, 118 passed / 56 skipped on ROCm), includingtest_qqq_rejects_native_kernel_on_rocm. The only otherUnsupported backendassertion in the test tree istests/test_awq_bitblas.py::test_awq_bitblas_kernel_mapping_rejects_gptq_bitblas_backend(AWQ +GPTQ_BITBLAS), which passes and is unrelated to these aliases. No test asserted that QQQ or BitsAndBytes reject the generictorchname.Hardware
GPU-d458708b-c760-bbf1-08fb-8b8803a2157d(never the RTX 5090).HIP_VISIBLE_DEVICES=2.