[PR #4301] [Engine] strata-dsv41: build with -Xptxas -dlcm=ca in the experimental sm_60/sm_70 build (Pascal decode 1.66 -> 3.50 tok/s) #4991

Open
opened 2026-11-07 16:31:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4301
Author: @orlyandico
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: sm61-dsv41-dlcm


📝 Commits (1)

  • 81ff0c5 DeepSeek engine: build with -Xptxas -dlcm=ca in the experimental sm_60 / sm_70 build, as Maya's Pascal build: the Q5_K dense GEMV's plain loads were L2-only on a P40 (attention 278 -> 34 ms a token, same output; #4174)

📊 Changes

1 file changed (+6 additions, -0 deletions)

View changed files

📝 CMakeLists.txt (+6 -0)

📄 Description

Problem and result

On Pascal, plain global loads are cached in L2 only. In strata-dsv41 the Q5_K dense GEMV (iq::mv_kernel<13, 1>, the attention and routing stages' weights) reads its 5.3 GB through Jobs struct pointers, without const __restrict__, so it gets LDG.E rather than LDG.E.CI. nvprof put it at 44.9% of GPU time on a P40, at about 14 GB/s (about 4% of the card's 347 GB/s). Building with -Xptxas -dlcm=ca, as Maya's Pascal build does, caches those loads in L1. On 2× P40 the GPU's share of a decode token falls from 585 to 283 ms (attention 278 → 27 ms) and decode goes from 1.66 to 3.50 tok/s, with the same output.

Fixes #4174. Depends on #4173 (PR #4300) for an sm_61 build to exist at all.

Approach

-Xptxas=-dlcm=ca on strata-dsv41 and strata_dsv41_kernels, only when STRATA_ENABLE_CUDA AND STRATA_EXPERIMENTAL_SM60. The ready-made engines are not SM60 builds, so they compile exactly as before. In an SM60 build that also targets sm_70, the flag reaches the Volta pass too, where global loads are already cached in L1 by default. Other targets (the Qwen engine) are unchanged: their kernels already take the read-only path (#1469), and a Qwen engine built with the flag gave the same decode here (40.4 against 40.5 tok/s).

A flag rather than kernel edits: it covers every kernel in the engine at once. Giving mv_kernel const __restrict__ pointers would be the narrower fix, but the flag needs no change to vendored code.

Validation

Environment: x9srl, 2× Tesla P40 24 GB (sm_61), Xeon E5-2651 v2 (AVX, no AVX2), 128 GB, Ubuntu 24.04, CUDA 12.3, g++-12. Model: ISTA-DASLab DeepSeek-V4.1-Flash-1017-GSQ-RCO IQ2_XXS (pack deepseek-v4.1-flash-ist-das-2.00bpw).

An sm_61 build needs #4173's fix, so both builds below include it: "before" is the #4173 branch (b007a36d); "after" is this branch (81ff0c57) with that commit applied on top, not committed here.

Passed:

  • Build with the command from #4173's PR (no CMAKE_CUDA_FLAGS) → strata-dsv41 0.1.51 build 81ff0c57c; -Xptxas=-dlcm=ca appears in CMakeFiles/strata-dsv41.dir/flags.make.

  • Decode on both P40s, 96 greedy tokens after a 20-token coding question, page cache warm in both runs:

    DS4_PROF=1 strata-dsv41 --pack <pack> --ids @ids.txt --n 96 --max-context 4096 --dspark none --gpus 0,1 --ssd-cache 85
    
    DS4_PROF, ms per token before after
    attention 277.6 27.1
    routing + shared expert 95.8 9.4
    experts gate/up 15.3 5.6
    down + post 16.2 6.1
    waiting for the CPU lane 180.6 234.5
    GPU per token 585.4 282.8
    decode 1.66 tok/s 3.50 tok/s

    The CPU lane (SSD reads for experts not in RAM, then AVX-only arithmetic) is now nearly all of the token. Its wait rises because the GPU no longer hides it.

  • Output: the "after" run's 96 token ids are identical to a "before" run's (cold cache, 1.17 tok/s). Two "before" runs differ from each other from token 59: the ids follow where the expert cache places experts, not this flag.

  • Multi-arch SM60 compile (-DCMAKE_CUDA_ARCHITECTURES="61;70;86", with #4300 applied) of the engine's ds4_gguf.cu.o
    and ds4_iq.cu.o: no errors. -Xptxas=-dlcm=ca is in strata-dsv41's flags.make and ptxas accepts it for all three
    arches.

Failed: none observed.

Not run:

  • Volta (sm_70) on hardware: no such card here; the multi-arch build above only shows it compiles.
  • Windows (MSVC) SM60 builds: not available here; the option is passed through $<COMPILE_LANGUAGE:CUDA>, so only nvcc sees it.
  • One run per build. The difference (GPU stages 585 → 283 ms) is well beyond the run-to-run spread seen here (attention 278 / 296 ms across the two "before" runs), but it is not a multi-run benchmark.

Limits

Measured on one machine and one model. The gain is in the GPU stages. How much of it reaches tok/s depends on how much of the token the CPU lane takes: on this box with 128 GB of RAM it is the remaining limit.

🤖 Generated with Claude Code

https://claude.ai/code/session_01X1cLqPe2PZ4sDqfHSEgfLr


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4301 **Author:** [@orlyandico](https://github.com/orlyandico) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `sm61-dsv41-dlcm` --- ### 📝 Commits (1) - [`81ff0c5`](https://github.com/Niko1221/Strata/commit/81ff0c57c4903cc84e1d89983e1ee92910516b64) DeepSeek engine: build with -Xptxas -dlcm=ca in the experimental sm_60 / sm_70 build, as Maya's Pascal build: the Q5_K dense GEMV's plain loads were L2-only on a P40 (attention 278 -> 34 ms a token, same output; #4174) ### 📊 Changes **1 file changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+6 -0) </details> ### 📄 Description ## Problem and result On Pascal, plain global loads are cached in L2 only. In `strata-dsv41` the Q5_K dense GEMV (`iq::mv_kernel<13, 1>`, the attention and routing stages' weights) reads its 5.3 GB through `Jobs` struct pointers, without `const __restrict__`, so it gets `LDG.E` rather than `LDG.E.CI`. nvprof put it at 44.9% of GPU time on a P40, at about 14 GB/s (about 4% of the card's 347 GB/s). Building with `-Xptxas -dlcm=ca`, as Maya's Pascal build does, caches those loads in L1. On 2× P40 the GPU's share of a decode token falls from 585 to 283 ms (attention 278 → 27 ms) and decode goes from 1.66 to 3.50 tok/s, with the same output. ## Related discussion Fixes #4174. Depends on #4173 (PR #4300) for an sm_61 build to exist at all. ## Approach `-Xptxas=-dlcm=ca` on `strata-dsv41` and `strata_dsv41_kernels`, only when `STRATA_ENABLE_CUDA AND STRATA_EXPERIMENTAL_SM60`. The ready-made engines are not SM60 builds, so they compile exactly as before. In an SM60 build that also targets sm_70, the flag reaches the Volta pass too, where global loads are already cached in L1 by default. Other targets (the Qwen engine) are unchanged: their kernels already take the read-only path (#1469), and a Qwen engine built with the flag gave the same decode here (40.4 against 40.5 tok/s). A flag rather than kernel edits: it covers every kernel in the engine at once. Giving `mv_kernel` `const __restrict__` pointers would be the narrower fix, but the flag needs no change to vendored code. ## Validation Environment: x9srl, 2× Tesla P40 24 GB (sm_61), Xeon E5-2651 v2 (AVX, no AVX2), 128 GB, Ubuntu 24.04, CUDA 12.3, g++-12. Model: ISTA-DASLab DeepSeek-V4.1-Flash-1017-GSQ-RCO IQ2_XXS (pack `deepseek-v4.1-flash-ist-das-2.00bpw`). An sm_61 build needs #4173's fix, so both builds below include it: "before" is the #4173 branch (`b007a36d`); "after" is this branch (`81ff0c57`) with that commit applied on top, not committed here. **Passed:** - Build with the command from #4173's PR (no `CMAKE_CUDA_FLAGS`) → `strata-dsv41 0.1.51 build 81ff0c57c`; `-Xptxas=-dlcm=ca` appears in `CMakeFiles/strata-dsv41.dir/flags.make`. - Decode on both P40s, 96 greedy tokens after a 20-token coding question, page cache warm in both runs: ``` DS4_PROF=1 strata-dsv41 --pack <pack> --ids @ids.txt --n 96 --max-context 4096 --dspark none --gpus 0,1 --ssd-cache 85 ``` | DS4_PROF, ms per token | before | after | |---|---:|---:| | attention | 277.6 | 27.1 | | routing + shared expert | 95.8 | 9.4 | | experts gate/up | 15.3 | 5.6 | | down + post | 16.2 | 6.1 | | waiting for the CPU lane | 180.6 | 234.5 | | **GPU per token** | **585.4** | **282.8** | | **decode** | **1.66 tok/s** | **3.50 tok/s** | The CPU lane (SSD reads for experts not in RAM, then AVX-only arithmetic) is now nearly all of the token. Its wait rises because the GPU no longer hides it. - Output: the "after" run's 96 token ids are identical to a "before" run's (cold cache, 1.17 tok/s). Two "before" runs differ from each other from token 59: the ids follow where the expert cache places experts, not this flag. - Multi-arch SM60 compile (`-DCMAKE_CUDA_ARCHITECTURES="61;70;86"`, with #4300 applied) of the engine's `ds4_gguf.cu.o` and `ds4_iq.cu.o`: no errors. `-Xptxas=-dlcm=ca` is in `strata-dsv41`'s `flags.make` and ptxas accepts it for all three arches. **Failed:** none observed. **Not run:** - Volta (sm_70) on hardware: no such card here; the multi-arch build above only shows it compiles. - Windows (MSVC) SM60 builds: not available here; the option is passed through `$<COMPILE_LANGUAGE:CUDA>`, so only nvcc sees it. - One run per build. The difference (GPU stages 585 → 283 ms) is well beyond the run-to-run spread seen here (attention 278 / 296 ms across the two "before" runs), but it is not a multi-run benchmark. ## Limits Measured on one machine and one model. The gain is in the GPU stages. How much of it reaches tok/s depends on how much of the token the CPU lane takes: on this box with 128 GB of RAM it is the remaining limit. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01X1cLqPe2PZ4sDqfHSEgfLr --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4991
No description provided.