perf: add opt-in fused BF16 SwiGLU - #54
Closed
0z5a wants to merge 1 commit into
Closed
Conversation
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
M=1..8decode inputs(N,K)=(6912,1536)M=2/4/8 cellsASTRAI_SWIGLU=0is unfused,1is explicit opt-in, and defaultautocurrently enables no shapeThe unfused fallback still calls AstrAI's existing linear backend, so independently qualified GEMV bands remain available.
L20 benchmark
CUDA Graph medians for the AstrAI 1B MLP shape:
The five-shape matrix also covers LLaMA 2 7B/13B, LLaMA 3 8B, and GPT-NeoX 20B. The wide shapes stay within about -1.2% to +0.9% of the best unfused path, so they are not automatically selected.
Real 24-layer AstrAI checkpoint results through
InferenceEngine(scheduler, sampling, and CUDA Graph; A-B-B-A):The fused operator uses one CUDA kernel. Direct comparisons stayed within
max_abs <= 2.4e-4with cosine similarity approximately 1.0.Dispatch decision
Deterministic greedy checkpoint generations changed for M=1, M=2, and M=4 because the fused FP32 reduction order differs. The before/after hashes and outputs are checked in rather than omitted.
Therefore this PR deliberately leaves the
autotable empty. Default behavior is unchanged; onlyASTRAI_SWIGLU=1opts into the experimental primitive. A future automatic band must pass both performance and checkpoint-output gates.Validation
main:623 passed, 123 skipped23 passedmain:746 passed53 passed; Draft validate/resolve: passInfraSWE's frozen formula gives diagnostic ProjectFit 90.95/100 and BenchmarkTrust 95.87/100. These are explicitly non-official: official ProjectFit remains unresolved because the D3 Draft is unsealed and lacks the required fresh-process count, system traces, hidden probes, and verified manifest.
Environment disclosure
Benchmarks ran on NVIDIA L20 (sm_89), PyTorch 2.11.0+cu128, and CUDA 12.8. An existing GPU5 AstrAI service remained resident at about 15.4 GiB but was idle at sampling boundaries. No process or container was stopped.
Related: #53 (independent common-shape GEMV tuning).