mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #139] [CLOSED] perf(prefill): add shape-selected pre-Ampere BF16 SGEMM with current-main A/B #2474
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#2474
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/139
Author: @rluisr
Created: 9/29/2026
Status: ❌ Closed
Base:
main← Head:perf/pre-ampere-bf16-prefill📝 Commits (4)
f4c8687perf(prefill): add pre-Ampere BF16 SGEMM fallback and routed staging opt-inbbdaf4cMerge remote-tracking branch 'upstream/main' into perf/pre-ampere-bf16-prefill33e24e9fix(prefill): reserve BF16 expansion scratch at init and retain cuBLAS fallback4350f99perf(prefill): retain GemmEx for deep narrow BF16 projections📊 Changes
4 files changed (+211 additions, -0 deletions)
View changed files
📝
CMakeLists.txt(+10 -0)📝
include/strata/prefill/gemm.hpp(+1 -0)📝
src/prefill/gemm.cu(+62 -0)➕
src/prefill/gemm_test.cpp(+138 -0)📄 Description
Summary
Add an optional BF16-to-FP32 expansion + tiled SGEMM path for Volta/Turing (
sm_70/sm_75). Current main already handles BF16 withcublasGemmExon these cards; this is an alternative for selected projection shapes, not an enablement fix.The final current-main request A/B is essentially unchanged: 65.590 s → 65.478 s (−0.17%). This PR is not demonstrated to improve end-to-end performance on the measured workload; the shape-level results and tradeoffs are reported below.
Revised after review:
bbaaabb4643bb7873d4cef9d48b5dcf96e6cbff4(engine 0.1.28), including #87 and the HIP backend.initandinit_external. There is no allocation or retry inbf16().cublasGemmExpath. Other CUDA errors are not treated as an OOM.betaand output stride.STRATA_PREFILL_RING=8staging change to #225. It is not in this diff or the current-main A/B.prefill_gemm_testCUDA/CTest target, including deterministic allocation-failure injection on Linux.V100 A/B against current main
bbaaabb/ GemmExObserved warm wall-time difference: -0.17%. With only two warm samples per arm, this is not evidence of a reliable general end-to-end speedup.
All request measurements
All six requests: zero reused prompt tokens, zero cgroup CPU throttling events. No OOM kills were recorded.
GEMM-only comparison (exact 64 MiB tiled production path)
Three warmups, then seven CUDA-event-timed calls on an otherwise idle GPU; median below. Initialization is excluded, but both BF16 expansion and SGEMM are included. No staging or server is involved.
The two arms were run sequentially with normal GPU boost behavior, not locked clocks. In particular,
4096/320/10240uses the same GemmEx path in both final arms; its GPU 0 timing difference should not be interpreted as a kernel improvement.The initial revised candidate regressed
4096/320/10240by about 19% (3.27 ms vs 2.75 ms on GPU 0). The final branch therefore retains GemmEx whenN < ceil(K/16), as well as whenN < 32. The regression test includes that selection. This heuristic is based on this V100 experiment, not a claim of universal optimality.Matched conditions
18,34(18/16/14 layers),STRATA_PREFILL_RINGunset,STRATA_PREFILL_TIMING=1, prompt-cache/root/every disabled.This is a small, repetitive-input experiment, not a model-quality benchmark or a statistically established speedup. SGEMM changes reduction order and rounding; greedy outputs need not be bitwise identical.
Request reproduction
For run indices 0, 1, 2, construct a user message from:
Benchmark 31744-{run}-coldwarm-20260930.\n.The expedition recorded observations of the landscape, atmosphere, rocks, and distant stars.\n.\nWrite a detailed original science-fiction story of at least 2000 words about an expedition to a distant planet. Start the story directly, continue at length, and do not discuss the notes above.Choose the largest repetition count whose model-tokenized rendered chat template (
enable_thinking=False, special-token parsing enabled) fits 31,744 tokens. The rendered input here was 31,730 tokens. POST/v1/chat/completionswithmax_tokens: 256,temperature: 0, andreasoning_effort: "none". Measure wall time until the complete JSON response is received; use the engine-reported prompt/decode timings. Report run 0 separately and the median of runs 1 and 2 as warm.Validation
prefill_gemm_testbuilt through CMake and passed through CTest on all three V100s.(1,35,47),(17,35,47),(33,35,47),(1031,35,47),(3,4103,4097),(17,4,47),(3,35,577); beta 0/0.5/1, output strideN+4, row/column tile boundaries, narrow/deep-narrow fallback, and BF16 65536 outside FP16 range. Tolerance:1e-5 * (1 + sum(abs(products)))against CPU double.On the experimental V100 build:
sm_75 evidence
@Adamyno reported carrying the original changes onto main
a790805and rebuilding on an RTX 2080 Ti, CUDA 13.0. No measured numbers were included in that comment, so this PR does not treat it as quantified runtime evidence. The revised scratch reservation and shape selection still need an sm_75 runtime A/B.Historical evidence from the original submission (not a current-main comparison)
The original combined experiment used a local sm_70 SIMT baseline, routed-only staging, and larger chunks. It reported warm wall time 90.82 s → 56.52 s (−37.8%), while decode throughput fell from 43.75 to 35.05 tok/s. The baseline was an experimental V100 build based on
f1b1d961537fd66d37fee68a60015701375b7b5a, with #87 changes and local sm_70 fixes.Those measurements remain historical evidence for that combined local tuning. They do not establish this GEMM-only PR's advantage over main's existing
cublasGemmEx, and the original standalone diagnostic used full expansion buffers rather than the exact 64 MiB tiled path. The comparison above supersedes those claims for this PR.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.