[PR #4300] [Engine] strata-dsv41: build for Pascal (sm_61) by compiling the WMMA set kernels for sm_70+ only #4990

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/4300
Author: @orlyandico
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: sm61-dsv41-wmma-guard


📝 Commits (1)

  • b007a36 DeepSeek engine: compile the WMMA set kernels' bodies only for sm_70+ device passes, as pf_wmma (a6bdc3fb): an sm_61 build failed in ds4_gguf.cu / ds4_iq.cu with no nvcuda::wmma there (#4173); tc_ok() never launches them below compute capability 7

📊 Changes

2 files changed (+8 additions, -0 deletions)

View changed files

📝 src/dsv41/ds4_gguf.cu (+4 -0)
📝 src/dsv41/ds4_iq.cu (+4 -0)

📄 Description

Problem and result

strata-dsv41 does not build for Pascal (-DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=61): ds4_gguf.cu and ds4_iq.cu use nvcuda::wmma in the prompt path's tensor-core set kernels (mx_set_tc_kernel, set_tc_kernel), and <mma.h> declares that namespace only for __CUDA_ARCH__ >= 700. With this change the engine builds for sm_61 and runs DeepSeek-V4.1-Flash on 2× Tesla P40.

Fixes #4173. No scope agreement sought: a focused build fix.

Approach

The same guard as pf_wmma in a6bdc3fb: the two kernels' bodies compile only in sm_70+ device passes, and the file-scope namespace wm = nvcuda::wmma; alias is guarded the same way (the host pass keeps it). tc_ok() already refuses compute capability below 7 at run time, so on a Pascal card the F32 set kernels run, as before; the guarded kernels are never launched there.

The guards are always true on sm_70 and later and in the host pass, so the release engines (sm_86 / sm_120, HIP) compile the same code as before. The HIP path is outside the #if !defined(STRATA_USE_HIP) block and is untouched.

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

Passed:

  • Build at b007a36d (this branch, on main 4b9e05a2):

    cmake -S . -B build-wg -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF -DSTRATA_BUILD_DSV41=ON \
      -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_ISA_FLOOR=avx -DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=61 \
      -DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.3/bin/nvcc -DSTRATA_GGML_DIR=<llama.cpp at 3cf03257>
    cmake --build build-wg --target strata-dsv41
    

    → strata-dsv41 0.1.51 build b007a36d8. Without the change the same command stops in ds4_gguf.cu / ds4_iq.cu on the undefined nvcuda::wmma.

  • cmake --build build-wg --target ds4_iq_test && CUDA_VISIBLE_DEVICES=0 ./ds4_iq_test on a P40: ALL OK. All 7 types
    (IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S, IQ4_XS, IQ1_M) × token gate_up / down, set gate_up / down and CPU lane are
    within tolerance; the set kernels run the F32 path here, as tc_ok() is false on sm_61.

  • Decode on both P40s, 96 greedy tokens after a 20-token coding question:

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

    Two runs: 1.17 tok/s (cold page cache) and 1.66 tok/s (warm). The text is a sound answer ("# Parsing ISO 8601 Dates in Python … datetime.fromisoformat() …"). The two runs agree for the first 58 tokens and then reword; the token ids follow where the expert cache places the experts (the CPU lane and the GPU round differently), the same behaviour as a 0.2.4.2 build with a local stub in place of this guard.

  • Multi-arch compile, -DCMAKE_CUDA_ARCHITECTURES="61;70;86" (otherwise the same command), the engine's
    ds4_gguf.cu.o and ds4_iq.cu.o: no errors. cuobjdump -sass HMMA count per arch: ds4_gguf.cu.o sm_61 0,
    sm_70 192, sm_86 24; ds4_iq.cu.o sm_61 0, sm_70 2304, sm_86 288. The tensor-core kernels are still built for
    sm_70+ and left out of the sm_61 pass only.

Failed: none observed. The sm_61 pass warns that kLdT is declared but never referenced (it sits outside the guard).

Not run:

  • The guarded tensor-core kernels on an sm_70+ GPU: no such card here. The multi-arch compile above shows they are
    still built there; their arithmetic is not exercised.
  • CUDA 13, HIP and Windows builds: not available here; this change does not touch their code paths.
  • tests/dsv41/ds4_gguf_test.cu: it has no CMake target or documented build command, so ds4_gguf.cu's kernels are not covered by a test run here.

Limits

This makes the sm_61 build possible; it does not add Pascal to any package (packaging/build_dsv41_cuda.sh still notes "the Pascal cuda12 variant has no DeepSeek path"). Decode on this box is limited by the CPU lane and its SSD reads, not by this change. Pascal decode speed is #4174 (-Xptxas -dlcm=ca), a separate PR.

🤖 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/4300 **Author:** [@orlyandico](https://github.com/orlyandico) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `sm61-dsv41-wmma-guard` --- ### 📝 Commits (1) - [`b007a36`](https://github.com/Niko1221/Strata/commit/b007a36d8b200bb9c944f0b594ed824f9d0ab5e0) DeepSeek engine: compile the WMMA set kernels' bodies only for sm_70+ device passes, as pf_wmma (a6bdc3fb): an sm_61 build failed in ds4_gguf.cu / ds4_iq.cu with no nvcuda::wmma there (#4173); tc_ok() never launches them below compute capability 7 ### 📊 Changes **2 files changed** (+8 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/dsv41/ds4_gguf.cu` (+4 -0) 📝 `src/dsv41/ds4_iq.cu` (+4 -0) </details> ### 📄 Description ## Problem and result `strata-dsv41` does not build for Pascal (`-DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=61`): `ds4_gguf.cu` and `ds4_iq.cu` use `nvcuda::wmma` in the prompt path's tensor-core set kernels (`mx_set_tc_kernel`, `set_tc_kernel`), and `<mma.h>` declares that namespace only for `__CUDA_ARCH__ >= 700`. With this change the engine builds for sm_61 and runs DeepSeek-V4.1-Flash on 2× Tesla P40. ## Related discussion Fixes #4173. No scope agreement sought: a focused build fix. ## Approach The same guard as `pf_wmma` in `a6bdc3fb`: the two kernels' bodies compile only in sm_70+ device passes, and the file-scope `namespace wm = nvcuda::wmma;` alias is guarded the same way (the host pass keeps it). `tc_ok()` already refuses compute capability below 7 at run time, so on a Pascal card the F32 set kernels run, as before; the guarded kernels are never launched there. The guards are always true on sm_70 and later and in the host pass, so the release engines (sm_86 / sm_120, HIP) compile the same code as before. The HIP path is outside the `#if !defined(STRATA_USE_HIP)` block and is untouched. ## 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`). **Passed:** - Build at `b007a36d` (this branch, on main `4b9e05a2`): ``` cmake -S . -B build-wg -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF -DSTRATA_BUILD_DSV41=ON \ -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_ISA_FLOOR=avx -DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=61 \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.3/bin/nvcc -DSTRATA_GGML_DIR=<llama.cpp at 3cf03257> cmake --build build-wg --target strata-dsv41 ``` → `strata-dsv41 0.1.51 build b007a36d8`. Without the change the same command stops in `ds4_gguf.cu` / `ds4_iq.cu` on the undefined `nvcuda::wmma`. - `cmake --build build-wg --target ds4_iq_test && CUDA_VISIBLE_DEVICES=0 ./ds4_iq_test` on a P40: `ALL OK`. All 7 types (IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S, IQ4_XS, IQ1_M) × token gate_up / down, set gate_up / down and CPU lane are within tolerance; the set kernels run the F32 path here, as `tc_ok()` is false on sm_61. - Decode on both P40s, 96 greedy tokens after a 20-token coding question: ``` DS4_PROF=1 strata-dsv41 --pack <pack> --ids @ids.txt --n 96 --max-context 4096 --dspark none --gpus 0,1 --ssd-cache 85 ``` Two runs: 1.17 tok/s (cold page cache) and 1.66 tok/s (warm). The text is a sound answer ("# Parsing ISO 8601 Dates in Python … `datetime.fromisoformat()` …"). The two runs agree for the first 58 tokens and then reword; the token ids follow where the expert cache places the experts (the CPU lane and the GPU round differently), the same behaviour as a 0.2.4.2 build with a local stub in place of this guard. - Multi-arch compile, `-DCMAKE_CUDA_ARCHITECTURES="61;70;86"` (otherwise the same command), the engine's `ds4_gguf.cu.o` and `ds4_iq.cu.o`: no errors. `cuobjdump -sass` HMMA count per arch: `ds4_gguf.cu.o` sm_61 0, sm_70 192, sm_86 24; `ds4_iq.cu.o` sm_61 0, sm_70 2304, sm_86 288. The tensor-core kernels are still built for sm_70+ and left out of the sm_61 pass only. **Failed:** none observed. The sm_61 pass warns that `kLdT` is declared but never referenced (it sits outside the guard). **Not run:** - The guarded tensor-core kernels on an sm_70+ GPU: no such card here. The multi-arch compile above shows they are still built there; their arithmetic is not exercised. - CUDA 13, HIP and Windows builds: not available here; this change does not touch their code paths. - `tests/dsv41/ds4_gguf_test.cu`: it has no CMake target or documented build command, so `ds4_gguf.cu`'s kernels are not covered by a test run here. ## Limits This makes the sm_61 build possible; it does not add Pascal to any package (`packaging/build_dsv41_cuda.sh` still notes "the Pascal cuda12 variant has no DeepSeek path"). Decode on this box is limited by the CPU lane and its SSD reads, not by this change. Pascal decode speed is #4174 (`-Xptxas -dlcm=ca`), a separate PR. 🤖 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#4990
No description provided.