Skip to content

test(allspark): cover CUDA graph capture of the W8A16 GEMM - #3515

Merged
Qubitium merged 2 commits into
ModelCloud:mainfrom
Lumea-art:test/allspark-cuda-graph
Nov 3, 2026
Merged

Qubitium merged 2 commits into
ModelCloud:mainfrom
Lumea-art:test/allspark-cuda-graph

Conversation

@Lumea-art

Copy link
Copy Markdown
Contributor

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:

$ python -m pytest tests/test_allspark_{jit,linear,hip,awq,awq_cuda,cuda_graph}.py -q
53 passed, 176 skipped

Negative control

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 - the capture
allocator 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

  • One new file on top of 8a6a03f, no product code changes.
  • The GPTQ packing helper is duplicated from test_allspark_linear.py rather
    than imported. Test modules importing each other makes collection order
    matter, and CI splits tests by file, so I kept them independent.

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.

Qubitium commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Tightened in 7aec628: FP64 reference, rtol=atol=2e-3, output-dtype checks, and FP16/BF16 negative controls rejecting zero and stale replay output. Restoring the old tolerance makes all four negative controls fail.

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).

@Qubitium
Qubitium merged commit 5c34d8c into ModelCloud:main Nov 3, 2026
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Merged - thanks. The FP64 reference plus the 2e-3 gate is the part I should have
written the first time; my 5e-2 tolerance let a frozen output pass.

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.

2 participants