mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3867] [CLOSED] [Engine] GP100 (sm_60): the decode down projection staged in shared memory, bitwise expert mode 0 (opt-in, STRATA_DOWN_WS=1) #4805
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#4805
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/3867
Author: @ruibeikaa
Created: 10/23/2026
Status: ❌ Closed
Base:
main← Head:down-ws-sm60📝 Commits (2)
d9cfdb6iq_kernels: the decode down projection staged in shared memory on GP100 (STRATA_DOWN_WS=1, opt-in, cc 6.0)1b60e3edocs: OLDER_GPUS.md - STRATA_DOWN_WS=1, the staged decode down projection on GP100 (opt-in)📊 Changes
2 files changed (+321 additions, -1 deletions)
View changed files
📝
docs/OLDER_GPUS.md(+6 -1)📝
src/kernels/cuda/iq_kernels.cu(+315 -0)📄 Description
Problem and result
Measured on PH402 SKU 200 boards: four GP100 dies, 32 GB HBM2 each (128 GB in all), every expert resident in VRAM, no CPU share, no PCIe share.
On a GP100 die (compute capability 6.0: no
__dp4a, no tensor cores) the verify window's routed down projection for the native packs' IQ4_NL and Q2_0 rows is latency bound, not bandwidth bound: expert mode 0'snative_down_multi_kernelreads each weight with 2-byte loads, one item at a time, straight from global memory (IQ4_NL at ~170-185 GB/s of the die's ~730). The cc 6.0 default, mode 8 (native_down_lds_kernel), is faster than mode 0 for Q2_0 but slower for IQ4_NL on this card.With
STRATA_DOWN_WS=1, on a cc 6.0 device,native_down_ws_kerneltakes the down step instead: a block copies its rows (IQ4_NL 32, Q2_0 64: 11,520 bytes) into shared memory with 16-byte loads, all in flight at once, reads the plan words before the group test and the destination rows before the weights land, and then runs mode 0's row dots on the copy. Per layer on one GP100 die (Swift 1.5 IQ3_S, real rows, T-token window = 10T groups of one entry, us per call, the minimum of 3 interleaved rounds of 300 calls):STRATA_DOWN_WS=1Swift 1.5 IQ3_S has 39 IQ4_NL and 9 Q2_0 down layers; weighted that way a layer's down step is 69.0 -> 41.6 us at T = 1 (-39.7% against the default, -26.4% against mode 0) and 245.6 -> 148.7 us at T = 4 (-39.5% / -28.9%). The output is mode 0's bit for bit, and mode 0's equals mode 8's here, so it is also the default's. Unset (the default) nothing changes.
End to end on four GP100 dies, on a different revision (engine 0.1.47 plus my GP100 stack, expert mode 0 in both arms, details below): decode +2.41% with every reply hash identical.
Related discussion
No scope issue. Same card and setup as #3455 and #3752 (GP100 decode and prompt-path experts); this change is independent of both and applies to plain main. My comment on #3455 measured expert mode 0 decoding about 2% faster than the cc 6.0 default mode 8 on this card, with the difference in the down projection; this kernel makes the down step faster than either mode without changing their results.
Approach
src/kernels/cuda/iq_kernels.cu:native_down_ws_kernel<TD, NCMAX>(TD 20 = IQ4_NL, 42 = Q2_0; NCMAX 1 for a one-token window, 4 otherwise),down_ws_on,launch_down_ws, and a seven-line branch at the start ofnative_expert_grouped's down step, before the mode 8 / AMD / CUDA-layout choice.row_dot_40_sub8/row_dot_20_sub16, with the same float expressions in the same order (s += item,s16/s8/s24, the__fadd_rns, the xor reduction,* sd). Only an item's integer sum changes form: the dp4a emulation's byte products are taken withvmadbyte selectors straight from the table lookup's bytes (no interleavingbyte_perm), and IQ4_NL's lookup uses rawprmtselectors (bit 3 of a selector only affects bytes the low/high merge drops, and the merge selector's nibbles are 0..7). The same int8 x int8 products give the same int32, so the floats that follow are mode 0's.STRATA_EXPERIMENTAL_SM60(not HIP, not Metal; a localSTRATA_DOWN_WS_BUILT). At run time only withSTRATA_DOWN_WS=1, on a compute capability 6.0 device (checked per device;vmadis emulated on Volta and later), for IQ4_NL / Q2_0 down rows at n_ff 640, and not withSTRATA_OLD_IQ_MMVQorSTRATA_NO_SUB16_GU. When on it takes the down step in expert mode 0 and mode 8 alike.docs/OLDER_GPUS.md: one bullet in the GP100 section.Validation
Environment note: measured only on PH402 SKU 200 boards - four GP100 dies of 48 SMs and 32 GB HBM2 each (128 GB in all), application clocks 715 / 1050 MHz - with every expert resident in VRAM (no CPU share, no PCIe share, no adaptive tier). The single-die numbers use one of those dies.
Rig: Windows 11, driver 581.80 (TCC), CUDA 12.9, VS 2022; build
-DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=60, ggml at the pinned 3cf03257f. Model: Swift 1.5 IQ3_S (abliterated GSQ-RCO GGUF).Passed:
7ddc17a3+ this PR), one GP100 die:native_expert_bench <shard> 0,2,1,8 <G> 1 <ref> <mode> 300withBENCH_CAP=G, G = 10 / 20 / 30 / 40 (T = 1..4 windows, one entry per group), layers 0 / 2 (IQ4_NL) and 1 / 8 (Q2_0). Without the switch: mode 8 bitwise equal to mode 0 on all 16 (layer, G) cases. WithSTRATA_DOWN_WS=1: the output's FNV-1a hash equal to the switch-off run's (that is, mode 0's and mode 8's) on all 16. The table above is from these runs.cuobjdumpofiq_kernels.cu, sm_60 build: the 442 kernels of main have identical SASS with this PR; the fournative_down_ws_kernelinstances are the only additions. The sm_86 build withoutSTRATA_EXPERIMENTAL_SM60compiles none of them (442 kernels, as main) and builds clean.011c9e60) plus 26 opt-in GP100 commits of mine (#3455's 4-bit gate/up slots on 47 of 48 layers, #3752,--pipeline-windows 3and others not posted), expert mode 0 (STRATA_SM60_TABLE=0) in both arms, so the gain is against mode 0's down, not the default mode 8's. Swift 1.5 IQ3_S, layer split 12,24,36, MTP, one fresh engine per arm, eight decode prompts (five short prompts, 8K / 26K / 88K-token contexts) token-weighted: 57.53 -> 58.92 tok/s (+2.41%), each prompt +2.2..+2.5%; every reply hash and the draft acceptance identical on all 9 requests; prompt reads within 0.05%. One run per arm. Against the default mode 8 the down step saves more per layer (table above) but that was not run end to end.Failed: none observed.
Not run: HIP (gfx906), SYCL and Metal builds (no such machine here; the kernel is under the
STRATA_EXPERIMENTAL_SM60CUDA-only guard). An end-to-end run on this branch's own revision. A single Tesla P100 16 GB with experts partly in RAM. Packs other than Swift 1.5 IQ3_S. Cards other than GP100 (the switch does nothing below or above cc 6.0).Limits
STRATA_EXPERIMENTAL_SM60builds only, IQ4_NL and Q2_0 down rows at n_ff 640 only.CI note: the red
metal-linkcheck is not caused by this PR. The job fails while compiling upstream'smetal/src/mtl_rt.mm(lines 69 and 92:MTLGPUFamilyMetal4,MTLCompileOptions.mathMode,MTLMathModeFast/MTLMathModeSafe), which themacos-14runner's SDK does not provide. The workflow runs on any pull request that touchessrc/orinclude/; this PR changes no file undermetal/.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.