Repository navigation
test(gpu): repair the #4387, #5014 and #5020 host gates - #5138
Merged
Merged
Conversation
- #4387: the biased GGUFCudaKernel layer now caches its (0, 4) uint8 shift table as an immutable per-module constant (#5014), so the exact `before - qweight.nbytes` bound is 512 B short. Allow the module's small cached constants, then drop the derived caches and assert the exact packed-weight release, so a second weight copy still fails. - #5014: Q2_K/Q3_K packing needs llama.cpp's native quantizer. Skip only the host-dequant declaration nodes when llama-cpp-python is absent and add a unit check for that skip reason. - #5020: gate the GPTQ_TRITON node, and the repeated-generate node that uses the same backend, on the shared #5056 `requires_nvidia_cuda()` predicate instead of hard-coding a CUDA-only kernel on ROCm.
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 #5113
Test-only fixes for three tests that were red on GPU hosts for test-side reasons. No product code changes.
Item 1 —
test_gguf_cuda_weight_storage_4387.py::test_forward_leaves_one_device_copy_of_the_packed_weight[True]Root cause.
tests/kernels/test_gguf_cuda_weight_storage_4387.py:104assertedmemory_allocated() <= allocated_before - qweight.nbyteswith zero slack. Since #5035 the biasedGGUFCudaKerneldequantizes throughGGUFTorchLinear, whose_u8_shift()(gptqmodel/nn_modules/qlinear/gguf.py:1506) caches the immutable(0, 4)uint8 shift table on the device (#5014). The 2-byte table occupies one 512-byte allocator block, so the first forward retains 512 B more than the exact bound.Fix.
tests/kernels/test_gguf_cuda_weight_storage_4387.py:112-130: allow the module's small cached constants (4 KiB, 18x below the 73 KiB packed weight), then callclear_weight_cache()and assert the exactallocated_before - nbytesbound. Anything the forward retained outside those derived caches still fails the exact assertion.Before (GPU 0, this branch's parent):
After (GPU 0):
Still guaranteed.
qweight's Torch allocation is released by the first forward;_ggml_cuda_weight.backs(kernel.qweight)and the shareddata_ptrprove one device copy; a second copy (73,728 B) fails both the allowance and the exact post-clear bound.Item 2 —
test_gguf_kquant_graph_capture_5014.py::test_graph_capture_declaration_is_per_formatRoot cause.
_build("q2_k")/_build("q3_k")callGGUFTorchLinear.pack_original, and_pack_weight_tensor→_quantize_gguf_tensor_numpy(gptqmodel/nn_modules/qlinear/gguf.py:911-918) needs llama.cpp's native quantizer for Q2_K/Q3_K. On hosts without llama-cpp-python that raises instead of skipping.Fix.
tests/kernels/test_gguf_kquant_graph_capture_5014.py:47-64adds_host_dequant_skip_reason(), and the declaration test is parametrized (:180-211) so only the two host-dequant nodes skip whenllama_cppis missing.:214-228adds a unit check that the skip reason is returned and the node raisesSkippedwhenimportlib.util.find_spec("llama_cpp")returnsNone.Before (simulated no-llama host, exact pre-fix path):
After (this host has llama-cpp-python, no new skips):
After (simulated no-llama host, full file):
Still guaranteed. The capturable formats (q4_0/q8_0/q4_k/q5_k/q6_k) assert
supports_graph_capture() is True; Q2_K/Q3_K still assertFalseon hosts that can pack them, and the class-levelgraph_capture_safe(GGUFTorchLinear) is Trueassertion is unchanged.Item 3 —
test_optimize_dynamo_release_5020.py::test_optimize_generate_does_not_pin_the_model[gptq_triton]Root cause. The parametrization hard-coded
BACKEND.GPTQ_TRITON;TritonV2Linearis CUDA-only and raisesValueError: TritonV2Linear is CUDA-only and does not run on ROCmon a HIP build instead of skipping.Fix.
tests/test_optimize_dynamo_release_5020.py:36imports the shared #5056 predicatetests.accelerator_gates.requires_nvidia_cuda;:62-66adds_require_nvidia_for(), used at:198for the parametrized node and:232fortest_repeated_generate_does_not_accumulate, which also hard-codesGPTQ_TRITONthrough_run_two_generates.:253-261unit-checks that a HIP build skipsGPTQ_TRITONwhileGPTQ_TORCHis not gated.On this CUDA host (GPU 0):
The end-to-end nodes need
HuggingFaceTB/SmolLM2-135M; this host's cache lacksrefs/main(the environment note in #5113), so the run used a temporaryHF_HUB_CACHEoverlay that only adds the missing ref to the already-present snapshot. No repository or test-fixture change was made for that.Item 3 is ROCm-only and was not executed here. It is verified by gate inspection and by the unit check above: the node now calls the same
requires_nvidia_cuda()predicate (torch.cuda.is_available() and torch.version.hip is None) that #5056 uses for the other CUDA-only nodes, and the unit check patchestorch.version.hipto a HIP string to confirm the skip.Validation
All commands run as
cd /root/work/issue-5113 && CUDA_VISIBLE_DEVICES=0 PYTHONPATH=/root/work/issue-5113 HF_HUB_OFFLINE=1 /root/venv/bin/python -m pytest ...:tests/kernels/test_gguf_cuda_weight_storage_4387.pytests/kernels/test_gguf_kquant_graph_capture_5014.pytests/test_optimize_dynamo_release_5020.pytests/test_accelerator_gates.pytests/test_optimize_no_reference_cycle_4937.pyruff checkon the three changed files: all checks passed.