mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4382] [Engine] DeepSeek-V4.1: the hyper-connection split off the decode path, +1.4% decode, bit-exact #5031
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5031
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4382
Author: @Licenser
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:dsv41-hc-mix📝 Commits (1)
9bc42f7dsv41: the hyper-connection split beside the norm, off the decode path📊 Changes
3 files changed (+33 additions, -58 deletions)
View changed files
📝
src/dsv41/ds4_kernels.cu(+18 -46)📝
src/dsv41/ds4_kernels.cuh(+5 -5)📝
src/dsv41/ds4_model.cu(+10 -7)📄 Description
Problem and result
In a decode window every layer runs
hc_mix_splittwice, before the attention and before the FFN: 24 dot productsover the 4 x 5120 hyper-connection state, then the split (the gates and a 20-step 4 x 4 Sinkhorn) on one warp of the
block that finishes last.
hc_pre_normwaits for all of it. Timed on its own on an A40, a call takes 15.55 us, and thesplit alone 10.04 us of it: the Sinkhorn is a chain of 40 normalizations on one warp. 80 calls a token come to about
1,240 us of a 27,460 us token.
The norm does not need that split. It reads an earlier split's
pre: before the attention the previous layer'sf_pre, before the FFN the attention'sa_pre.postandcombare read only byhc_postat the end of thesublayer. This PR runs the split beside the norm instead of before it. The arithmetic is the same, and so are the bits.
5e8a4cca+1.4% decode on the means, about 370 us a token. The output is bit for bit main's: the scored files on two cards, and
the generated text with and without DSpark.
Related discussion
None. A focused change that keeps the output bit for bit.
Approach
hc_mix(the kernel the prompt path already uses) and thenhc_pre_norm_split:hc_pre_norm_kernellaunched with 2T blocks, where blocks T and up run the token'shc_split_bodyon their first warp, from the mixeshc_mixleft. The split's outputs are complete when the kernelends, before
hc_postreads them.hc_mix_split_kernel, its wrapper with the per-token counters and the counters (hccnt) go: nothing else usedthem. The
hc_mix_splitwithout counters stays: the Mac (Metal) decode path calls it and thenhc_pre_norm, as onmain.
hc_mix+hc_split+hc_pre_norm) and the plainhc_pre_normare unchanged.Validation
Machine: an A40 48 GB (sm_86) and an RTX 2080 Ti 11 GB (sm_75), each used alone (
CUDA_VISIBLE_DEVICES); Threadripper3960X, 184 GiB RAM, Linux, CUDA 13.4,
packaging/build_dsv41_cuda.shwithARCH="75;86-real". Model:ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUFIQ2_XXS 2.00 bpw @ cb02422c,--experts 5, a fresh copy ofdata/dsv41/profile-2.00.binfor each run. The first line under Passed is this PR (9bc42f77) against main46c152a1;the other lines were measured with this PR on main
5e8a4cca, against5e8a4cca.Passed:
46c152a1, the A40 alone:--scoreover the multilingual set (999 positions,--no-expert-cache,STRATA_DS4_SLOT_KEEP=0 STRATA_DS4_AUTO_PIN=0, the CPU lane's experts read in place with--mmap-experts on),windows of 16 and windows of 1, this PR against main: byte-identical score files (4,995 rows each).
--scoreover the multilingual set (999 positions,--no-expert-cache,STRATA_DS4_SLOT_KEEP=0 STRATA_DS4_AUTO_PIN=0), windows of 16 and windows of 1, this PR against main on the same card: byte-identical scorefiles (4,995 rows each) on the A40 and on the 2080 Ti.
--ids <1K prompt> --n 256(the prompt read through the chunked path), this PR against main:identical on the A40 (two runs each) and on the 2080 Ti (two runs each).
--dspark on, A40, the same 1K prompt and 256 tokens): the generated text is identical to main's,and so are the drafter's rounds (68 rounds, 187 of 196 drafts accepted, in both).
DS4_PROF=1on the A40, one run each: the attention's mixing stage 438 -> 185 us a token; the GPU total 26,960 ->26,330 us a token (the profiler's per-stage waits make that difference larger than in a plain run).
hc_mix_split15.55 us, the mix alone 5.78 us, the split alone 10.04 us, an empty kernel 2.41 us.
46c152a1and on5e8a4cca.5e8a4cca: HIP for gfx1200 + gfx1201 (tools/dsv41/build_hip_linux.sh, targetsstrata-dsv41andds4_iq_test) with ROCm 7.10.0a20251120 from AMD's TheRock wheels, setup's pin. Compiled and linked, with the samenumber and kinds of warnings as main's: one sign-compare warning moves from the removed kernel to the new block
check (
blockIdx.x >= T). Not run: there is no AMD card here.Failed: none observed.
Not run:
46c152a1: the 2080 Ti, the generated text, DSpark, the decode timing and a HIP build.Limits
show it: two runs of this PR differed by 2.6% (21.86 and 21.30 tok/s), more than the 1.4% the A40 showed; main
5e8a4ccaran at 21.61 and 21.20 tok/s.Used Claude.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.