Repository navigation
test(allspark): cover CUDA graph capture of the W8A16 GEMM - #3515
Merged
Merged
Conversation
Decode loops replay a captured graph, so anything that round-trips to the host inside the GEMM turns into a capture error. Nothing exercised that before now, and the kernel already passes - these tests pin the behaviour. Four cases, fp16 and bf16: the MMA path at M=1/16, replay against a rewritten input buffer, the cuBLAS fallback above ALLSPARK_M_CUBLAS_THRESHOLD (which builds dense scratch per call), and AllSparkLinear.forward on a 3D input. A negative control confirms the tests are load-bearing: injecting a .item() into allspark_gemm fails exactly the two M=1 capture cases and leaves the other eight passing. What this does not catch: a plain torch::empty inside the captured region succeeds, because the capture allocator pool absorbs it. These tests guard host synchronisation and the M-dependent dispatch, not allocations.
Use an independent FP64 reference with 2e-3 tolerances and assert the activation output dtype. Seed preparation and add FP16/BF16 negative controls that reject zero output and frozen replay. Validation: RTX 4090 AllSpark suite 57 passed, 176 skipped; R9700 ROCm suite 179 passed, 54 skipped. Restoring the old 0.05 tolerances makes all four negative controls fail as expected.
Collaborator
|
Tightened in 7aec628: FP64 reference, Validated on both GPUs: RTX 4090 CUDA 57 passed / 176 skipped; Radeon AI PRO R9700 ROCm 179 passed / 54 skipped. This CUDA graph file skips ROCm; separate strict graph probes passed all 16 cases on each GPU. Repository-wide Ruff 0.14.2 also passes locally (GitHub’s fork workflow awaits approval). |
Contributor
Author
|
Merged - thanks. The FP64 reference plus the 2e-3 gate is the part I should have |
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
Nothing exercised AllSpark under a captured decode graph, and the kernel already
passes. These pin the behaviour before someone puts a synchronous call on the
hot path.
Four cases, fp16 and bf16:
the MMA path at M=1 and M=16, captured and replayed
replay against a rewritten input buffer, so the captured kernel is shown to
read current data rather than a snapshot
the cuBLAS fallback above ALLSPARK_M_CUBLAS_THRESHOLD, which builds dense
scratch on every call
AllSparkLinear.forward with a 3D input, since that is what a real model calls
$ python -m pytest tests/test_allspark_cuda_graph.py -q
10 passed
Ran it five times in a row to check for capture flakiness - 10 passed each time,
3.3s per run. The rest of the suite alongside it:
Negative control
The tests are load-bearing. Injecting a
.item()intoallspark_gemmfailsexactly the two M=1 capture cases and leaves the other eight passing.
What this does not catch
A plain
torch::emptyinside the captured region succeeds - the captureallocator pool absorbs it. So these tests guard host synchronisation and the
M-dependent dispatch between the MMA kernel and the cuBLAS fallback. They do not
prove that nothing allocates.
I verified that before writing the docstring, because my first draft claimed the
opposite and would have been wrong.
Notes
than imported. Test modules importing each other makes collection order
matter, and CI splits tests by file, so I kept them independent.