Repository navigation
perf: --mode strix, Triton kernels for AMD Strix Halo (gfx1151), on basal 2.0.0 - #2
Merged
Merged
Conversation
…ls for AMD Strix Halo (gfx1151) A profile of --mode gguf on the Radeon 8060S: every request is >=98.5% GPU decode at 16-19 useful TFLOPS; FFN matmuls take 47-69% of the GPU time (21-25 TFLOPS), flash attention up to 28.5% on long states (~11 TFLOPS), unfused bias / residual / SwiGLU passes ~15% (the model has biases on every linear layer). basal/strix.py (StrixHaloFastBackend) keeps the bf16 weights and replaces those kernels: - attention: Triton flash attention over the packed prefix trie, GQA-packed. The block mask becomes an interval per key (depth-first packing: key k is visible to query q iff k <= q < sub_end[k]); key blocks no query can see are skipped, fully visible ones run unmasked. ~20 TFLOPS at 6k tokens (AOTriton ~10) - FFN input: gate, up, biases and SwiGLU in one kernel, ~32 TFLOPS (F.linear + silu*up ~17) - qkv / o / down: Triton matmuls with the bias and residual add in the epilogue, tile configs per row count - RMSNorm and rotary kernels, the last layer for the readout rows only, all rows of a chunk one sequence (no padding, shapes or graphs), the GPU awaited by polling an event (ROCm's synchronize spins a core at 100%); rounding as the stock bf16 forward Request matrix over HTTP against gguf, basal-1.5-4.5B: 1.12-1.75x (S 1 q 178 -> 159 ms, L 1 q 1.28 -> 0.74 s, XL 1 q 4.16 -> 2.73 s, XL 20 q 6.77 -> 4.57 s; 32 clients 7.7 -> 10.9/s); 144/144 decisions equal to an fp32 reference, 26/26 edge cases. basal-2.0-4.5B (same Llama shape) runs through it unchanged: 1.37-1.81x except one short question at a time (136 -> 144 ms, 0.94x); XL 20 q 5.25 -> 2.90 s, 32 clients 11.5 -> 19.0/s; 142/144 equal to fp32 (the other two are one 0.502 / 0.498 question), 26/26 edge cases. GTT 10.0 GiB, start-up 6-7 s. Opt-in by name (--mode strix in basal-serve and basal-bench); every other mode and basal/engine.py are unchanged. Like GGUFBackend it runs its own run_shared, so it declares streams = False, inflight = 1 (no early readouts, one engine call at a time). Tests: tests/test_strix.py (kernels against their stock counterparts, the interval mask against the block mask, the backend against separate forwards). Co-Authored-By: Claude Opus 5.5 <[email protected]>
kardysm
force-pushed
the
strix-halo-perf
branch
from
October 16, 2026 05:43
bc13562 to
b2bc0e4
Compare
… --deterministic; safe warmup From the review of rkinas#14: - StrixHaloFastBackend.unsupported(cfg) replaces the start-up shape check. Every tile config must divide its projection: the matmuls have no column or depth masks, so a qkv width that is not a multiple of 128 left its last columns unwritten. Head size and query heads per kv head must be powers of two (tl.arange; other shapes failed to compile), head size at least 16. RoPE types whose frequencies depend on the sequence length (dynamic, longrope) are refused, since the tables are computed once. basal-1.5 and basal-2.0 pass unchanged. - ROCm only: the kernels take AMD launch options (waves_per_eu). On CUDA the mode now refuses at start-up, and the GPU tests skip. - --deterministic accepts strix. It already runs one request per forward, and the Triton kernels have no atomics or split-K, so an answer depends only on its own request. Tested under torch.use_deterministic_algorithms: identical answers, no refused op. - Warmup token ids stay within the vocabulary and lengths within the context. - Docstring: a single prompt over TOKEN_BUDGET runs alone in one forward, as in GraphBackend. Tests: 11 new in tests/test_strix.py; suite 521 passed, 20 skipped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kardysm
added a commit
that referenced
this pull request
Oct 16, 2026
docs(strix): --mode strix benchmarks, HARDWARE.md and SERVING.md (stacked on #2)
kardysm
pushed a commit
that referenced
this pull request
Oct 19, 2026
@lukaspoloki) Conflicts: the MPS commit of the branch (c531ba3) is not taken, since main has MPS from #4: README.md, basal/engine.py, basal/server.py, basal/bench.py and tests/test_engine.py stay as on 2.2. Kept: basal/viz.py, basal/viz.html, the basal-viz script, viz.html as package data and the segments test. The port to the 2.2 engine follows.
kardysm
pushed a commit
that referenced
this pull request
Oct 19, 2026
… option orders, calibration and answer Port of #2 to the current engine without its MPS backend (main has MPS since #4): the page runs a basal-serve Server in process (--mode mps on Apple Silicon, eager elsewhere) and reads its PyTorch model for the per-layer readout. Prompts, option codes (up to 255, format 2 from basal.json) and option orders (one by default for format-2 models; --orders 1|2) come from Server.jobs_for; temperatures per type and option-count bucket and the per-type certified thresholds from the calibration file basal-serve loads; multi questions are explained per label, act and tool by their base type. The code logits are read in fp32 as the engines read them. Each request is also answered by Server.decide and the page shows the difference. The page handles one or two orders and types without a certified threshold; question types the form does not edit (act, tool, tasks) are sent as JSON. Llama-architecture models only (refused otherwise). Docs: SERVING.md, "See how a decision is made". Checked with basal-2.0-mini on MPS and CPU, bundled examples and a multi / act / 30-option request: equal to the served answer for single questions (0 on MPS), within 0.006 for requests with several questions (one packed row over the state, bf16).
kardysm
pushed a commit
that referenced
this pull request
Oct 19, 2026
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.
Code and tests only: one commit (b2bc0e4) touching
basal/strix.py,basal/server.py,basal/bench.pyandtests/test_strix.py. The docs, the benchmark scripts and the raw results are in #3, which is stacked on this branch; merge this PR first.Rebased onto basal 2.0.0
This is #1 again, rebased onto upstream
mainat 45cf199 (af1ce43 feat: basal 2.0.0plus three docs commits). #1 was merged into the fork's 1.5-basedmain. Thatmainhas been reset to upstream, and the old merge stays on the branchstrix-1.5-merged(be2e2dc).What changed against #1:
streams, inflight = False, 1onStrixHaloFastBackend. In 2.0,GraphBackenddeclaresstreams = True/inflight = 2, and the server then callsrun_shared(..., done=callback)with two calls at once. The strix backend runs its ownrun_shared(asGGUFBackendandMPSBackenddo), so it declares the same values they do. Without this line every request through--mode strixwould fail with aTypeError.strixrow of the modes table goes todocs/SERVING.md(in docs(strix): --mode strix benchmarks, HARDWARE.md and SERVING.md (stacked on #2) #3). This was the only rebase conflict.strix.pyuses from the engine is the same in 2.0:_units/_readout/_assemble, the five-field packed row,PREFILL, and the readout rows taken fromlm_head. The 2.0 option-code readout goes through the same_readout(h, lids).basal-2.0-4.5B through
--mode strixbasal-2.0-4.5B has the architecture of basal-1.5 (Llama, 60 layers, hidden 2048, GQA 16/2, biases) and runs through
--mode strixunchanged. Against--mode ggufwithbasal-2.0-4.5B-Q8_0.gguf, interleaved A/B with both servers up (each shape sent to both engines in alternating order, median of 5 rounds; the scriptbench_ab.pyis in #3), so thermal drift and the power limit hit both alike:ggufstrixggufon every shape except one short question at a time. The long-state gain is larger than with basal-1.5 (XL, 1 question: 1.70× in the matrix, 1.52× with 1.5). Each added question costs 12–28 ms (gguf37–55 ms).strixmean |Δp| 0.0047, max 0.028;gguf0.0064, 0.068). The two others are one question that fp32 puts at 0.502 / 0.498 and both engines the other way round. All 26 edge-case decisions equal fp32.strixandggufdiffer on 4 of 188 matrix decisions, all multi-label yes/no on XL at 0.47–0.54.gguf3.3 s, 5.8 GiB).strix: S with 20 questions 1.08 s → 467 ms, XL with 20 questions 4.57 → 3.00 s, 32 clients 10.9 → 20.3/s.strix231 ms there, 142–148 ms in every A/B round).The numbers in the sections below were measured with basal-1.5-4.5B on #1 (981b354).
Summary
--mode strixis a basal forward written for AMD Strix Halo (Ryzen AI Max+ 395, Radeon 8060S, gfx1151), on basal-1.5; basal-2.0 runs through it unchanged. It keeps the bf16 weights and replaces the kernels that a profile showed to be slow on this GPU with Triton ones. On a request matrix with basal-1.5 it is 1.12–1.75× faster than--mode ggufand agrees with an fp32 reference on 144 of 144 decisions. With basal-2.0 it is 1.37–1.81× faster except for one short question at a time (0.94×), and agrees with fp32 on 142 of 144 (the other two are a 0.502 / 0.498 tie).It is opt-in by name (
basal-serve --mode strix,basal-bench --modes strix). Every other mode is unchanged:basal/engine.pyis not touched, andserver.py/bench.pyonly gain the dispatch for the new mode. The new module isbasal/strix.py. It needs no new dependencies (Triton ships with PyTorch on ROCm) and adds no CLI flags.Why: where
--mode ggufspends its timeEvery request is at least 98.5% GPU decode, at 16–19 useful TFLOPS whatever the size. GPU time by operation, from llama.cpp's Vulkan performance logger:
The model has biases on every linear layer, and llama.cpp adds each one in a separate pass. This GPU sustains ~35–40 TFLOPS on matmuls. The CPU, weight bandwidth, clock ramp-up and llama.cpp's batch size are not limits.
What it does
F.linear+ silu × up ~17F.linear+ add 3.7 msGraphBackend.Results: request matrix over HTTP, p50
--mode fast-nocompileas shipped is 2–12× slower thanstrixhere, at 888 s start-up and 32 GiB.gguf143/144, 0.0067) and 26/26 edge cases.gguf; start-up 6–7 s.Full tables, method and raw results: #3 (
docs/benchmarks/STRIX_HALO.md).Limits
strixthe package runs at its power limit (~160 W, then ~140 W after ~25 s), with the GPU at 2.15–2.33 GHz. A single XL forward on a cool GPU takes 2.37 s (1.76×).gguf(141 vs 159 ms): the bf16 weights are 9 GB per forward, the Q8_0 file 5 GB.Tests
tests/test_strix.py, 18 cases:It caught rows of a later request in one sequence turning into NaN, which is fixed.
Full suite on the 8060S, rebased onto 2.0.0: 510 passed, 20 skipped (MLX, and the
media/mcpextras not installed, training-side code).tests/test_format2_vectors.pypasses against the basal-2.0-4.5B tokenizer.Engine 2.0.0 installed into a venv with llama-cpp-python (Vulkan): 511 passed, 19 skipped;
tests/test_strix.py18 passed.Real model: on perf: --mode strix, Triton kernels for AMD Strix Halo (gfx1151) #1, answers equal to the benchmarked basal-1.5 run (max |Δp| 0.000). basal-2.0-4.5B: request matrix, edge cases, fp32 reference and the A/B above.
🤖 Generated with Claude Code