[GH-ISSUE #4174] [Engine] strata-dsv41 on Pascal: build without -Xptxas -dlcm=ca leaves the Q5_K dense GEMV L2-bound (attention 278 -> 34 ms a token on a P40 with it) #1833

Closed
opened 2026-11-04 01:54:28 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @orlyandico on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4174

Area

[Engine]

Desktop app, Terminal or source?

Source (a build)

What happened

On a Tesla P40 (sm_61) the DeepSeek-V4.1 engine spends most of its GPU time in the dense Q5_K GEMV, which runs at a few percent of the card's bandwidth. Compiling with -Xptxas -dlcm=ca (global loads cached in L1), as Project Maya's CMake does for every sm_6x build (#212 / #214 there: "decode 1.7-3x, same answers"), fixes it. Strata's CMakeLists.txt has no dlcm (checked on main 4b9e05a2), so a Pascal build of strata-dsv41 gets the L2-only loads.

nvprof (trace only) over 96 decoded tokens, default build:

Kernel GPU time calls avg
iq::mv_kernel<13, 1> (Q5_K, one column) 44.9% (36.3 s) 19,286 1.88 ms
wait_seq_kernel 30.6% 3,800
host-to-device copies 13.8% 12,727

That is ~378 ms a token for the 5.3 GB of Q5_K dense weights, ~14 GB/s on a 347 GB/s card. The SASS of that kernel has plain LDG.E loads (no LDG.E.CI: the weight pointer comes from the Jobs struct, not a const __restrict__ parameter), and each lane makes ~20 four-byte loads per 32 values, 8 of them the 32-byte qh array that all 8 lanes of a superblock read in full. On GP102 those go to L2 only.

DS4_PROF=1, 96 greedy tokens, 4K context, --dspark none --ssd-cache 85, ms per token:

Stage default -Xptxas -dlcm=ca
attention 278 34
routing + shared expert 96 9.6
experts gate/up + down 31 12
waiting for the CPU lane 271 424
total 675 (1.48 tok/s) 480 (2.08 tok/s)

(The CPU-lane wait grows because the GPU no longer hides it; on this box most of it is SSD reads: 128 GB of RAM for 95 GB of CPU-lane experts plus the Engram table.)

The output is unchanged: the -dlcm=ca build's 96 token ids are identical to the default build's at the default 48 GB store. (Default-build runs at different --ssd-cache sizes differ from each other after ~12 tokens, which follows where the experts are placed, CPU lane against GPU, not the flag.)

Suggested fix: Maya's block (CMakeLists.txt there, after "Maya: CUDA enabled"), which appends -Xptxas -dlcm=ca to CMAKE_CUDA_FLAGS when any target arch is 6x. It would likely help the Qwen engine's Pascal decode as well, but I have only measured strata-dsv41.

Smallest steps or command that reproduce it

Build strata-dsv41 for sm_61 (build line in #4173), once as is and once with "-DCMAKE_CUDA_FLAGS=-Xptxas -dlcm=ca", then for each:

DS4_PROF=1 build/strata-dsv41 --pack <pack> --ids @ids.txt --n 96 --max-context 4096 --dspark none --gpus 0,1 --ssd-cache 85

and compare the "GPU per token (DS4_PROF)" line and the printed ids.

Reproduction status

Reproduced locally

Strata version

Source 7dd5cf18 (0.2.4.2), engine strata-dsv41 0.1.49.2; CMake checked on main 4b9e05a2

Graphics card, memory and system

2x Tesla P40 24 GB (sm_61, PCIe 3.0 x8) · Xeon E5-2651 v2 (AVX, no AVX2) · 128 GB DDR3 · SATA SSD · Ubuntu 24.04 · CUDA 12.3

Model, size and settings

DeepSeek-V4.1-Flash IST-DAS-2.00bpw (ISTA-DASLab IQ2_XXS) · 4,355 of 15,360 experts in VRAM, 11,005 on the CPU lane · layer split over both GPUs

Originally created by @orlyandico on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4174 ### Area [Engine] ### Desktop app, Terminal or source? Source (a build) ### What happened On a Tesla P40 (sm_61) the DeepSeek-V4.1 engine spends most of its GPU time in the dense Q5_K GEMV, which runs at a few percent of the card's bandwidth. Compiling with `-Xptxas -dlcm=ca` (global loads cached in L1), as Project Maya's CMake does for every sm_6x build (#212 / #214 there: "decode 1.7-3x, same answers"), fixes it. Strata's CMakeLists.txt has no `dlcm` (checked on main 4b9e05a2), so a Pascal build of `strata-dsv41` gets the L2-only loads. nvprof (trace only) over 96 decoded tokens, default build: | Kernel | GPU time | calls | avg | |---|---:|---:|---:| | `iq::mv_kernel<13, 1>` (Q5_K, one column) | 44.9% (36.3 s) | 19,286 | 1.88 ms | | `wait_seq_kernel` | 30.6% | 3,800 | | | host-to-device copies | 13.8% | 12,727 | | That is ~378 ms a token for the 5.3 GB of Q5_K dense weights, ~14 GB/s on a 347 GB/s card. The SASS of that kernel has plain `LDG.E` loads (no `LDG.E.CI`: the weight pointer comes from the `Jobs` struct, not a `const __restrict__` parameter), and each lane makes ~20 four-byte loads per 32 values, 8 of them the 32-byte `qh` array that all 8 lanes of a superblock read in full. On GP102 those go to L2 only. `DS4_PROF=1`, 96 greedy tokens, 4K context, `--dspark none --ssd-cache 85`, ms per token: | Stage | default | `-Xptxas -dlcm=ca` | |---|---:|---:| | attention | 278 | 34 | | routing + shared expert | 96 | 9.6 | | experts gate/up + down | 31 | 12 | | waiting for the CPU lane | 271 | 424 | | total | 675 (1.48 tok/s) | 480 (2.08 tok/s) | (The CPU-lane wait grows because the GPU no longer hides it; on this box most of it is SSD reads: 128 GB of RAM for 95 GB of CPU-lane experts plus the Engram table.) The output is unchanged: the `-dlcm=ca` build's 96 token ids are identical to the default build's at the default 48 GB store. (Default-build runs at different `--ssd-cache` sizes differ from each other after ~12 tokens, which follows where the experts are placed, CPU lane against GPU, not the flag.) Suggested fix: Maya's block (CMakeLists.txt there, after "Maya: CUDA enabled"), which appends `-Xptxas -dlcm=ca` to CMAKE_CUDA_FLAGS when any target arch is 6x. It would likely help the Qwen engine's Pascal decode as well, but I have only measured strata-dsv41. ### Smallest steps or command that reproduce it Build `strata-dsv41` for sm_61 (build line in #4173), once as is and once with `"-DCMAKE_CUDA_FLAGS=-Xptxas -dlcm=ca"`, then for each: ``` DS4_PROF=1 build/strata-dsv41 --pack <pack> --ids @ids.txt --n 96 --max-context 4096 --dspark none --gpus 0,1 --ssd-cache 85 ``` and compare the "GPU per token (DS4_PROF)" line and the printed ids. ### Reproduction status Reproduced locally ### Strata version Source 7dd5cf18 (0.2.4.2), engine strata-dsv41 0.1.49.2; CMake checked on main 4b9e05a2 ### Graphics card, memory and system 2x Tesla P40 24 GB (sm_61, PCIe 3.0 x8) · Xeon E5-2651 v2 (AVX, no AVX2) · 128 GB DDR3 · SATA SSD · Ubuntu 24.04 · CUDA 12.3 ### Model, size and settings DeepSeek-V4.1-Flash IST-DAS-2.00bpw (ISTA-DASLab IQ2_XXS) · 4,355 of 15,360 experts in VRAM, 11,005 on the CPU lane · layer split over both GPUs
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660119261 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
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#1833
No description provided.