mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2178] [CLOSED] sm_61 (Tesla P40): a wide dequant kernel, expert mode 8 and its matvec table by default (bitwise), the dense GEMMs as cublasSgemm opt-in (7K prompt 360-432 -> 464-474 tok/s) #3905
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#3905
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/2178
Author: @Techannel
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:sm61-p40📝 Commits (4)
b4e0d8ddequant: a thread per 8 values for Q4_K / Q5_K / Q6_K / IQ4_XS, sm_61's default (bitwise; Q6_K 7.2 -> 0.33 ms on a Tesla P40)899260dprefill gemm: opt-in STRATA_DENSE_F32=1 on Pascal - the large dense GEMMs as cublasSgemm on FP32 copies07ac670sm_61: expert mode 8 and its own interleaved-matvec tables by default (bitwise; STRATA_SM61_TABLE=0)2012d88docs + bench: the Tesla P40 (sm_61) profile, the four changes and their measurements📊 Changes
27 files changed (+2831 additions, -6 deletions)
View changed files
📝
CMakeLists.txt(+11 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/README.md(+188 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/bench.py(+28 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/dequant-wide-parity.txt(+25 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/engine-runs.txt(+105 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/equal_check.py(+27 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/fused-gr-bench.txt(+37 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/gemm-f32-parity.txt(+28 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/gemm-sweep.txt(+923 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/gemm_sweep.cu(+86 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/mmvq-il-bench-p40-run1.txt(+133 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/mmvq-il-bench-p40-run2.txt(+133 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/mmvq-il-bench-p40-run3.txt(+133 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/native-expert-bench.txt(+55 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/nvprof-base.txt(+280 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/profile-base.txt(+32 -0)➕
bench/results/2026-10-12-p40-sm61-kernels/profile-new.txt(+32 -0)📝
docs/COMMUNITY_BENCHMARKS.md(+3 -0)📝
docs/OLDER_GPUS.md(+50 -2)📝
include/strata/kernels/dequant_bf16.hpp(+4 -0)...and 7 more files
📄 Description
Title
Issue: none open for this. The P40 path is #395's; #1639's Pascal Q6_K kernel is the P100's decode GEMV, a different kernel from the prompt-path dequantization here.
Summary
One Tesla P40 (sm_61) with IQ3_S on
a0116b2(0.1.43.1). On this card the GPU is the bottleneck of the prompt and of the decode (the prompt's GPU timeline equals its wall time, a decode window is 49 ms of GPU stages with 1-3 ms of CPU experts), so I read the profile first and changed four things where it pointed. Each gives exactly the bits of what it replaces; three become sm_61's defaults, the fourth is opt-in.Through the server, medians of 3 requests, two runs per build alternated, every run started with the card at 65 C:
a0116b2STRATA_DENSE_F32=1The decode gain is small and inside the spread of single requests; the GPU stage profile shows the same size (49.1 -> 45.6 ms per window). Everything, with every request, is in
bench/results/2026-10-12-p40-sm61-kernels/.What changed
Four commits, one per change:
dequant_bf16.cu: a thread per 8 values for Q4_K / Q5_K / Q6_K / IQ4_XS (16-bit loads, one 16-byte store, the same expression per value). The per-group kernel runs at 10 GB/s for Q6_K on a P40 and costs every prompt chunk of the IQ3_S pack ~0.5 s, whatever its length. Q6_K 10240 x 2560: 7.25 -> 0.33 ms; Q4_K 5.2x, Q5_K 3.8x, IQ4_XS 3.6x. Newdequant_wide_parity: 360 cases bitwise (FP16 / BF16 / FP32 out, a padded stride, row slices, sane and raw random blocks). Default on compute capability 6.1 only;STRATA_DEQUANT_WIDE=0/=1for any card.gemm.cu: opt-inSTRATA_DENSE_F32=1on Pascal - the qkv / query / gate / output projections' FP16-operand GEMMs ascublasSgemmon FP32 copies. cuBLAS 12.4 picks its slow FP16-operand kernel for most chunk sizes on this card: qkv runs at 7.6 TFLOPS for T 7,030-7,040 and at 4.3 from T 7,041 (49 -> 85 ms), so the same 7K prompt reads in 16.3 or 19.5 s depending on its token count.cublasSgemmruns at 8.4-9.8 TFLOPS from T 512. For the five shapes and the sizes the route takes the result is bitwise the FP16 call's: newgemm_f32_parity, 5,201 chunk sizes throughGemm::f16. That equality is a property of the cuBLAS build (12.4.5.8 measured), not of the code, which is why it is opt-in and why the tool is not registered as a ctest.iq_kernels.cu,native_mmvq.cu: expert mode 8 andkIlRows_61/kIl1Rows_61for sm_61, as sm_60 has them (STRATA_SM61_TABLE=0).native_expert_benchon the pack's layers, bitwise: IQ3_S 390 -> 255 us for an 18-expert call at 2 tokens. The tables are from three runs ofmmvq_il_parity --bench --emit-table, identical but for two Q3_K cells.docs/OLDER_GPUS.md, the results folder, one line inCOMMUNITY_BENCHMARKS.md.What it leaves alone: every other card runs what it ran (the three defaults are picked only on compute capability 6.1, sm_60 keeps its own; the GEMM route needs the variable and a 6.x card). No change to the server, setup or any HIP / SYCL path.
Extra Notes
mmvq_il_parity(the table) andnative_expert_parityon the model's layers. End to end: seven fixed greedy prompts, two runs of each build with--prompt-cache 0 --adapt-swaps 0 --pcie-frac 0 STRATA_PREFILL_CPU_SHARE=0 STRATA_ROUTE_TAIL_SKIP=0 STRATA_IQ_MT_MIN=1: byte-identical answers in 4 of 4 runs on 7 of 7 prompts. WithoutSTRATA_IQ_MT_MIN=1the comparison cannot be made on this AVX2 CPU - the same build gave two answers to one prompt in two runs (native_gu_mt_min's lone-token rounding and timing-dependent draft windows); the docs section says so.CMakeLists.txtand the docs section) but come from one measurement session, so I kept them as separate commits here. If you would rather have three PRs, say so and I will split them.-DSTRATA_EXPERIMENTAL_SM60=ON), andstrata_kernels/strata_prefill/ the two new tools for sm_75 without that flag. Not built: the CUDA 13 engine, HIP, SYCL - I have no toolkit for them here.--batch, prompts above 7K tokens, a quality suite.STRATA_GR_FAST=1is slower on the P40 below 5 tokens (82 -> 88 us at one).STRATA_DENSE_F32=1(default: 261 tok/s short, 439-446 long at 7,045-7,047 tokens; with the variable: 250 short, 465-473 long).The server here runs with all four.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.