mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1370] [CLOSED] prefill: opt-in STRATA_HC_UPMIX=1 on CUDA - the hyper-connection up projection with gr_mix_r as its epilogue (sm_80+) #3410
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#3410
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/1370
Author: @sergqwer
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:pr/hc-upmix-cuda📝 Commits (1)
d8ed55cprefill: opt-in STRATA_HC_UPMIX=1 on CUDA - the hyper-connection up projection with gr_mix_r as its epilogue (sm_80+)📊 Changes
5 files changed (+396 additions, -6 deletions)
View changed files
📝
CMakeLists.txt(+6 -0)📝
include/strata/prefill/kernels.hpp(+1 -1)➕
src/prefill/gr_upmix_parity.cu(+229 -0)📝
src/prefill/kernels.cu(+147 -3)📝
src/prefill/prefill.cpp(+13 -2)📄 Description
STRATA_HC_UPMIX=1(31b2472a) fuses the hyper-connection read's up projection withgr_mix_ron gfx11; on CUDAgr_upmixreturns false and the pair runs. This adds a CUDA kernel (sm_80+) behind the same switch.Unset (the default), nothing changes: no new code runs, and the output is byte-identical to v0.1.40.2.
Why
Each layer half's read runs the up GEMM, which writes
gated(T x 10240 FP32, 336 MB for an 8,192-token chunk).gr_mix_rthen reads it back with R.gr_mix_ralready runs at ~96% of the bandwidth (102 KB per token in 0.489 ms at 8K on an RTX 5090), so only fewer bytes make the read faster. Fused,gatedis never written or read.What it does
gr_upmix_cuda_kernelcomputes a block of 128 tokens x 32 columns x the 4 streams.cp.async, double-buffered).mma.m16n8k16BF16 with FP32 accumulation (ldmatrix).gr_mix_r_kernel's order, and writesmixedwith its BF16 / FP16 images.cp.asyncand the BF16mma), checked per device;STRATA_EMULATE_CCis honoured. On Turing,gr_upmixreturns false and the pair runs. On CUDA, chunks under 33 tokens also keep the pair (see the parity results below).gr_upmix's signature;STRATA_HC_UPMIX_CHECK.gr_upmix_parity(ctest; GPU, synthetic, no model) compares the fused read with cuBLAS +gr_mix_rand with FP64.--benchadds timings.Measured
RTX 5090, CUDA 13.3, Windows.
Parity (
gr_upmix_parity, 21 sizes from 1 to 32,768 tokens, 0 failures):mixed, the BF16 image and the FP16 image all equal the pair's. cuBLAS's up GEMM sums K in the kernel's order at these sizes.mixedmax |diff| / max |value| is at most 1.8e-7, and at most 0.010% of the BF16 and 0.058% of the FP16 values differ. Both paths are equally close to FP64. These chunks keep the pair anyway.Kernel (
--bench, medians of 20 alternating runs, ms):gr_mix_rPrompt (IQ2_XS,
generate,--prefill auto, 3 interleaved pairs, ms; "hc read" isSTRATA_PREFILL_TIMING's phase):=1: prompt / hc readThe hc read takes 19% less time at 8K and 24% less at 32K, which makes the prompt 4% faster. At 2K the read is a small share of the prompt and the difference is within the noise.
Identity (IQ2_XS, first-token logits and 32 greedy tokens against v0.1.40.2's engine, same expert cache):
=1. The logits are identical at all three lengths, and so are the tokens at 600 and 2K.STRATA_HC_UPMIX_CHECK=100000found every fused read of the 32K prompt bitwise equal to the pair (all 384 of them, 4 chunks).=1. They differ, but not because of the numbers.--suffix-draft 0, both engines give the same 32 tokens.Builds.
75-real;75-virtual;86-real;89-real;120a-real(the release list plus sm_75 PTX) buildsstrataand the test.gr_upmix_parityandgemm_bf16_paritypass. The kernel ran only on sm_120; the bitwise result is cuBLAS 13.3's on that card.🤖 Generated with Claude Code
https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.