[PR #5470] [Engine] DS4_PROF_WIN: the decode profile of the drafter's verify windows, and the attention by part #5444

Open
opened 2026-11-07 17:34:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5470
Author: @R-Okauchi
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: dsv41-prof-win


📝 Commits (4)

  • 2f195ef DeepSeek engine: DS4_PROF's chunked prompt fits its sample array again
  • d863038 DeepSeek engine: DS4_PROF_WIN, the decode profile of the verify windows
  • d963470 DeepSeek engine: DS4_PROF splits a decode layer's attention into its parts
  • 2850437 DeepSeek engine: DS4_PROF_WIN splits a verify window's experts into their stages

📊 Changes

5 files changed (+73 additions, -14 deletions)

View changed files

📝 include/strata/dsv41/exl3.hpp (+4 -0)
📝 src/dsv41/ds4_gguf.cu (+3 -0)
📝 src/dsv41/ds4_main.cpp (+21 -4)
📝 src/dsv41/ds4_model.cu (+42 -9)
📝 src/dsv41/ds4_model.hpp (+3 -1)

📄 Description

Problem and result

DS4_PROF=1 times a decoded token's GPU work by stage, but only for windows of one token. With the drafter on, most of
a decode is the drafter's verify windows, and those go untimed. The attention is also a single number: 36.8 of a
token's 110.9 ms of GPU time on a DGX Spark.

With this PR, DS4_PROF_WIN=1 (beside DS4_PROF=1) also times the verify windows and prints them on lines of their
own, and both profiles split the attention into its parts. Without the variables nothing changes. #5170's command with
the drafter, on a DGX Spark (GB10):

GPU per token (DS4_PROF): 110.90 ms - between layers 2.19, attention 36.80, routing + shared expert 14.32, experts gate/up 9.15, waiting for the CPU lane 42.03, down + post 6.40
GPU per token, the attention (DS4_PROF): mHC + norm 3.53, q_a / kv 2.66, q_b + rope 8.56, compressor + indexer + attention 6.49, wo_a + wo_b 15.25, post 0.31
GPU per verify window (DS4_PROF_WIN, 61 windows of 3.97 tokens): 235.59 ms - between layers 4.75, attention 48.22, routing + shared expert 16.41, experts gate/up 25.51, down 20.29, waiting for the CPU lane 118.78, the sum + post 1.63
GPU per verify window, the attention (DS4_PROF_WIN): mHC + norm 4.27, q_a / kv 3.17, q_b + rope 10.36, compressor + indexer + attention 11.98, wo_a + wo_b 17.97, post 0.47

A window of four tokens spends half of its GPU time waiting for the CPU lane's experts, which the token line alone
does not show.

#5170, where I used these numbers. No issue for the profile itself: it is an opt-in diagnostic.

This PR is stacked on #5127. Its first commit is #5127's change, without which DS4_PROF=1 aborts on any prompt that
takes the chunked pass, as this command's prompt does. Once #5127 is in, only the last three commits remain.

Approach

  • DS4_PROF_WIN=1 profiles the drafter's verify windows too (spec_win). A short prompt's windows of 16 stay out. A
    window of more than one token adds its sample to Stats::prof_win_ms, with the number of windows and their tokens,
    instead of prof_ms. DS4_PROF_SYNC's host-clock path keeps them apart the same way.
  • The attention's parts: five more marks in the decode layer (after the mHC and norm, the q_a / kv projections, q_b and
    the rope, the core, and wo_a / wo_b) as stages 6-10, so prof_ms grows from 6 to 12 entries. The first line still
    gives the attention as the sum of its parts.
  • A window's experts: WinArgs::mark, set only while a window is profiled, lets the GGUF form's win_experts mark the
    stream after the gate / up, the down (stage 11) and the wait for the CPU lane.
  • The new marks go through prof_event, the part of prof_mark after the Mac's DS4_TLOG host phases, so those
    phases see the same marks as before.

Off the profile, the decode path gains five calls a layer that return at once, as the existing marks do, and a null
check in win_experts.

Validation

On one DGX Spark (GB10, 128 GB, driver 580.178.04, CUDA 13.0.2 in an Ubuntu 24.04 container, nothing else on the GPU),
with #5170's IQ2_XS pack. The binary was built from source with spark/build_engine.sh's flags (sm_121 plus PTX):

DS4_PROF=1 DS4_PROF_WIN=1 DS4_UMA_HEADROOM_GIB=12 DS4_LANE_CAL=none strata-dsv41 --pack <IQ2_XS pack> --ids @<ids> \
  --n 256 --max-context 262144 --eos 1 --vision on --experts 6 --dspark auto --dspark-conf 0.65

Passed:

  • The run above (exit 0). It printed the four lines in "Problem and result" and the chunked prompt's table, with every
    stage filled (#5127's part). The 1,308-token prompt read at 162.99 tok/s. The 256 tokens decoded at 13.07 tok/s with
    2.49 tokens a round, against 13.94 and 14.77 tok/s for main without the profile in the same session.
  • The run is of an earlier state of this branch (02cb609c). The head differs from it in three places, none of which
    this run reaches:
    • DS4_PROF_WIN now takes only the verify windows, where 02cb609c also took a short prompt's windows of 16. This
      prompt took the chunked pass.
    • DS4_PROF_SYNC now sums a verify window apart from the tokens. It was off here.
    • The new marks no longer pass through the Mac's DS4_TLOG. That is a Metal-only diagnostic.
  • Builds of the head:
    • CUDA 13.0.2 for sm_121 (121-real;121-virtual) with spark/build_engine.sh's flags, on the Spark: strata-dsv41
      builds. There are no warnings in the changed files apart from three that main has too.
    • HIP, ROCm 7.2.4 for gfx1151 and gfx1201: tools/dsv41/build_hip_linux.sh strata-dsv41 ds4_iq_test builds both.
    • Metal, macOS 26.4 on an M3 Max: metal/ with metal-cpp, target strata_ds4, builds, with no warnings in the
      changed files.

Failed: none observed.

Not run:

  • DS4_PROF_SYNC=1 with DS4_PROF_WIN=1, and the head's change to it.
  • A short prompt (fewer than 96 tokens, the window path) with DS4_PROF_WIN=1.
  • An EXL3 set's verify windows. Their win_experts (vendor/exl3.cu) marks nothing inside, so there the window's
    experts would count in "the sum + post".
  • --parallel decode steps of several conversations. They are not profiled, as before.
  • HIP and Metal at runtime.

Limits

  • The marks cost something: the decode ran at 13.07 tok/s with them, against 13.94 and 14.77 without, so the times are
    those of a slightly slower run.
  • Measured on one GB10, with one set (IQ2_XS) and the CLI.

🔄 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/5470 **Author:** [@R-Okauchi](https://github.com/R-Okauchi) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `dsv41-prof-win` --- ### 📝 Commits (4) - [`2f195ef`](https://github.com/Niko1221/Strata/commit/2f195efc15e762f74648d7267be734a95d6234b5) DeepSeek engine: DS4_PROF's chunked prompt fits its sample array again - [`d863038`](https://github.com/Niko1221/Strata/commit/d863038897d4c38da5cf99f3e3ee6cba8a1ea0e5) DeepSeek engine: DS4_PROF_WIN, the decode profile of the verify windows - [`d963470`](https://github.com/Niko1221/Strata/commit/d963470ed5256fabd7a359268af45293d775da54) DeepSeek engine: DS4_PROF splits a decode layer's attention into its parts - [`2850437`](https://github.com/Niko1221/Strata/commit/28504379d36c5ebf84e703b2380fee31d5d59e1e) DeepSeek engine: DS4_PROF_WIN splits a verify window's experts into their stages ### 📊 Changes **5 files changed** (+73 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/dsv41/exl3.hpp` (+4 -0) 📝 `src/dsv41/ds4_gguf.cu` (+3 -0) 📝 `src/dsv41/ds4_main.cpp` (+21 -4) 📝 `src/dsv41/ds4_model.cu` (+42 -9) 📝 `src/dsv41/ds4_model.hpp` (+3 -1) </details> ### 📄 Description ## Problem and result `DS4_PROF=1` times a decoded token's GPU work by stage, but only for windows of one token. With the drafter on, most of a decode is the drafter's verify windows, and those go untimed. The attention is also a single number: 36.8 of a token's 110.9 ms of GPU time on a DGX Spark. With this PR, `DS4_PROF_WIN=1` (beside `DS4_PROF=1`) also times the verify windows and prints them on lines of their own, and both profiles split the attention into its parts. Without the variables nothing changes. #5170's command with the drafter, on a DGX Spark (GB10): ``` GPU per token (DS4_PROF): 110.90 ms - between layers 2.19, attention 36.80, routing + shared expert 14.32, experts gate/up 9.15, waiting for the CPU lane 42.03, down + post 6.40 GPU per token, the attention (DS4_PROF): mHC + norm 3.53, q_a / kv 2.66, q_b + rope 8.56, compressor + indexer + attention 6.49, wo_a + wo_b 15.25, post 0.31 GPU per verify window (DS4_PROF_WIN, 61 windows of 3.97 tokens): 235.59 ms - between layers 4.75, attention 48.22, routing + shared expert 16.41, experts gate/up 25.51, down 20.29, waiting for the CPU lane 118.78, the sum + post 1.63 GPU per verify window, the attention (DS4_PROF_WIN): mHC + norm 4.27, q_a / kv 3.17, q_b + rope 10.36, compressor + indexer + attention 11.98, wo_a + wo_b 17.97, post 0.47 ``` A window of four tokens spends half of its GPU time waiting for the CPU lane's experts, which the token line alone does not show. ## Related discussion #5170, where I used these numbers. No issue for the profile itself: it is an opt-in diagnostic. This PR is stacked on #5127. Its first commit is #5127's change, without which `DS4_PROF=1` aborts on any prompt that takes the chunked pass, as this command's prompt does. Once #5127 is in, only the last three commits remain. ## Approach - `DS4_PROF_WIN=1` profiles the drafter's verify windows too (`spec_win`). A short prompt's windows of 16 stay out. A window of more than one token adds its sample to `Stats::prof_win_ms`, with the number of windows and their tokens, instead of `prof_ms`. `DS4_PROF_SYNC`'s host-clock path keeps them apart the same way. - The attention's parts: five more marks in the decode layer (after the mHC and norm, the q_a / kv projections, q_b and the rope, the core, and wo_a / wo_b) as stages 6-10, so `prof_ms` grows from 6 to 12 entries. The first line still gives the attention as the sum of its parts. - A window's experts: `WinArgs::mark`, set only while a window is profiled, lets the GGUF form's `win_experts` mark the stream after the gate / up, the down (stage 11) and the wait for the CPU lane. - The new marks go through `prof_event`, the part of `prof_mark` after the Mac's `DS4_TLOG` host phases, so those phases see the same marks as before. Off the profile, the decode path gains five calls a layer that return at once, as the existing marks do, and a null check in `win_experts`. ## Validation On one DGX Spark (GB10, 128 GB, driver 580.178.04, CUDA 13.0.2 in an Ubuntu 24.04 container, nothing else on the GPU), with #5170's IQ2_XS pack. The binary was built from source with `spark/build_engine.sh`'s flags (sm_121 plus PTX): ``` DS4_PROF=1 DS4_PROF_WIN=1 DS4_UMA_HEADROOM_GIB=12 DS4_LANE_CAL=none strata-dsv41 --pack <IQ2_XS pack> --ids @<ids> \ --n 256 --max-context 262144 --eos 1 --vision on --experts 6 --dspark auto --dspark-conf 0.65 ``` **Passed:** - The run above (exit 0). It printed the four lines in "Problem and result" and the chunked prompt's table, with every stage filled (#5127's part). The 1,308-token prompt read at 162.99 tok/s. The 256 tokens decoded at 13.07 tok/s with 2.49 tokens a round, against 13.94 and 14.77 tok/s for main without the profile in the same session. - The run is of an earlier state of this branch (02cb609c). The head differs from it in three places, none of which this run reaches: - `DS4_PROF_WIN` now takes only the verify windows, where 02cb609c also took a short prompt's windows of 16. This prompt took the chunked pass. - `DS4_PROF_SYNC` now sums a verify window apart from the tokens. It was off here. - The new marks no longer pass through the Mac's `DS4_TLOG`. That is a Metal-only diagnostic. - Builds of the head: - CUDA 13.0.2 for sm_121 (`121-real;121-virtual`) with `spark/build_engine.sh`'s flags, on the Spark: `strata-dsv41` builds. There are no warnings in the changed files apart from three that main has too. - HIP, ROCm 7.2.4 for gfx1151 and gfx1201: `tools/dsv41/build_hip_linux.sh strata-dsv41 ds4_iq_test` builds both. - Metal, macOS 26.4 on an M3 Max: `metal/` with metal-cpp, target `strata_ds4`, builds, with no warnings in the changed files. **Failed:** none observed. **Not run:** - `DS4_PROF_SYNC=1` with `DS4_PROF_WIN=1`, and the head's change to it. - A short prompt (fewer than 96 tokens, the window path) with `DS4_PROF_WIN=1`. - An EXL3 set's verify windows. Their `win_experts` (`vendor/exl3.cu`) marks nothing inside, so there the window's experts would count in "the sum + post". - `--parallel` decode steps of several conversations. They are not profiled, as before. - HIP and Metal at runtime. ## Limits - The marks cost something: the decode ran at 13.07 tok/s with them, against 13.94 and 14.77 without, so the times are those of a slightly slower run. - Measured on one GB10, with one set (IQ2_XS) and the CLI. --- <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#5444
No description provided.