Add CUDA backend for Laguna S 2.1#594
Draft
devteapot wants to merge 16 commits into
Draft
Conversation
devteapot
force-pushed
the
laguna-s2.1-cuda
branch
from
July 23, 2026 19:20
2b31890 to
e11ed1b
Compare
added 10 commits
July 24, 2026 14:47
devteapot
force-pushed
the
laguna-s2.1-cuda
branch
from
July 24, 2026 13:08
39de6d3 to
a7e064e
Compare
added 6 commits
July 24, 2026 17:00
- Tile warp GQA prefill and add A/B controls - Select tile16 MoE kernels only for compatible PTX - Extend smoke tests for tiled attention equivalence
- Add an environment toggle to isolate the down-projection tile - Document the new CUDA tuning control
- Fuse Q/K/V/gate Q8 projections and single-token Q/K norm/RoPE launches - Add portable fallbacks, controls, documentation, and CUDA smoke coverage
- Calibrate target decode cost per session and adjust depth based on profitability - Add DS4_DFLASH_ADAPTIVE override and adaptive scheduling diagnostics - Document adaptive depth behavior and configuration
- Preserve the target model mapping on CUDA - Commit only accepted DFlash prefixes and roll back rejected SWA rows - Add transient-cache coverage to CUDA smoke tests
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
laguna-s2.1commit3b0ec5fand support all released weight recipes: mixed routed Q2_K/Q3_K, revised Q8_0 signal/all-Q4_K routed, and legacy F16/Q4_K/Q6_KMotivation
Laguna S 2.1 already had model loading and a Metal path, but no end-to-end NVIDIA backend. The source branch now also accepts a 44.95 GiB mixed checkpoint whose routed layers 1..20 use Q2_K and layers 21..47 use Q3_K. CUDA previously had generic Q2_K arithmetic but did not deliberately route this Laguna layout, and it had no Q3_K implementation.
This PR gives all three Laguna recipes an accurate CUDA path and adds target-verified DFlash acceleration for workloads with sufficient draft acceptance.
Impact
Users with a supported NVIDIA GPU can run:
The optional official DFlash BF16 GGUF adds about 2.08 GiB of weights plus graph buffers and works with either the mixed or Q4 target. Raw decode remains the default. Laguna remains single-GPU/full-residency: SSD streaming, distributed inference, ROCm inference, and tensor parallelism are not enabled.
GB10 benchmark: checkpoints with and without DFlash
Current end-to-end results on the NVIDIA GB10 using this PR's native Blackwell build at commit
37abbc5:The build emits native
sm_121code. No rollback environment variables were set, so these runs use the Blackwell target-prefill, raw-decode, and DFlash kernels. Each value is the median of three repeated warm runs after normalizing unified-memory pressure; ranges show process-to-process spread. Model startup is outside the measured interval. Generation is greedy, and steady generation excludes the first decode/speculative cycle.These paired results measure prefill and generation from the same binary and workload. Enabling DFlash reduces prefill throughput by 13.0% on revised Q4 and 3.5% on mixed Q2/Q3 because the capture path is active during prompt ingestion; DFlash accelerates generation, not prefill. Its generation gain remains workload- and acceptance-dependent, which is why it stays explicitly opt-in.
The revised Q4 target has the fastest prefill because its exact INT8 tensor-core path uses 16-pair gate/up and chunked-down tiles. The smaller mixed checkpoint uses the Q2_K/Q3_K DP4A path and is faster for raw generation, but not for prefill.
On DFlash, the Blackwell 9:1 GQA block shares each K/V fetch across the official drafter's nine query heads per KV head.
DS4_CUDA_DFLASH_NO_BLACKWELL=1selects the portable kernel. For target prefill,DS4_CUDA_LAGUNA_NO_WARP_GQA_PREFILL=1selects portable attention andDS4_CUDA_LAGUNA_NO_Q4_MMA=1disables exact Q4_K tensor-core routing.DS4_CUDA_LAGUNA_NO_Q4_MMA_TILE16=1andDS4_CUDA_LAGUNA_NO_Q4_MMA_DOWN_TILE16=1retain the eight-pair rollback paths.DS4_CUDA_LAGUNA_NO_BLACKWELL_SPLIT16=1disables only the wider raw-decode attention schedule.Validation
make cuda-spark -j2make cpu -j2make cuda-regression CUDA_ARCH=nativesm_75Laguna compile and regression on GB10tests/cuda_laguna_smoke, including patterned Q3_K scale/mask coverage, Q2_K/Q3_K decode and expert-sorted batch MoE, real 72:8 Blackwell GQA coverage, and 128-token Q4_K tensor-core/rollback equivalence at1e-6tests/cuda_long_context_smokepatch-md validate laguna-s21-cuda --readyThe broader model-dependent tool-call/logprob fixtures remain sensitive to which Laguna checkpoint is linked. The focused Laguna CUDA builds, numerical regressions, and real-model runtime checks pass.