mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1017] [CLOSED] feature: RDNA3 support / Cache-aware routing #2967
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#2967
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/1017
Author: @dhoard
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:feature/rdna3-support📝 Commits (10+)
04cdd86kernels: Q4_K down projection in the grouped native expert path89ec72dornith: run3.sh launcher, single-file cache resolution and docs711f058qwen35 test: fix the header-out flag name in the commentd541220Prompt path: an MMQ group's experts gathered in one launch, after one wait, released by one event6639c7bPrompt path: the first chunk's n-gram (PLE) rows read beside layer 0, 256 at a time4f7b3e8ple_land: the rows' upload, its event and the wait before a refill are checked3a91b9cPrompt path: a stager buffer's first job of a generation waits for the previous DMA from itba790d6prefill: the draft layer's batched K/V for a ring too (KV streaming), and STRATA_DRAFT_TIMING778e1f6qsa_prompt_attn: Q4_0 K and V on tensor cores (mode 4) - long prompts with --kv q4_0 no longer take the old kernel79670a6qsa_prompt_attn: Q4_0 mode 4 on sm_80+ only (#452 follow-up)📊 Changes
7 files changed (+340 additions, -39 deletions)
View changed files
📝
docker/entrypoint-hip.sh(+17 -0)📝
docs/AMD_HIP.md(+6 -2)➕
docs/AMD_HIP_GFX1101_TUNING.md(+174 -0)📝
run.sh(+3 -0)📝
tests/hip/prefill_hipblaslt_gemm.cpp(+48 -19)➕
tools/hip/gfx1101-hipblaslt-100202.txt(+63 -0)📝
tools/hip/tune_hipblaslt.cpp(+29 -18)📄 Description
RDNA3 support
Base:
main(6f32ec0) · Head:feature/rdna3-support(9dbc79e)Net diff: 39 files added, 25 modified, 172 deleted (all under
bench/results/)Everything below is what the branch is, read from the tree at
9dbc79e, not from individual commitmessages: several commits in the history add work that a later commit in the same branch removes, and those
cancellations are not part of this PR.
1. Summary
The branch turns Strata into something that runs on one AMD RDNA3 card from the repository root, and then
measures and tunes that deployment:
build.sh(builder + runtime images),docker/(entrypoint, model bootstrap, device probe, VRAM guard),run.sh, one launcher for the container (the branch's ownrun2.sh/run3.share gone, so this isthe only one): a release axis (
qwen|swift|coder), per-release default quant and tuning,release-qualified pack directories with a provenance guard, and a shipped default of Swift 1.5 IQ3_XXS
(measured on the reference card),
resident expert of that layer when the router's own score ratio clears a threshold. On by default at
0.35, with
--car-threshold 1.0restoring byte-identical stock tokens,reasoning effort.
2. Docker / HIP build and run path for gfx1101 (new)
build.shstrata-hip-builder:<arch>(ROCm toolchain) → compiles the engine into./build-hip(ccache volume) → buildsstrata-hip:<arch>(+-<gitsha>,-latest).--tests,--arch,--runtime-only.docker/Dockerfile.hip-builderdocker/Dockerfile.hiprocm/dev-ubuntu-24.04:7.2.1-complete): engine,serve/,tools/, model bootstrap. The compiled binary arrives through theenginenamed build context, so the build context stays source-only.docker/build-engine.shdocker/entrypoint-hip.shdocker/bootstrap-model.shcheckmode never writes. Free-space gate before any download.docker/hipinfo.py--arch,--vram,--render-node,--reserve-mib.docker/vram-guard.py--pidattribution to the container's engine.docker/README.md.dockerignoreThe 10 GiB ceiling is enforced in three places in the current code, not one:
src/core/hip_budget.cpp(new) — a Linux HIP interposer over the allocation APIs, enabled fromcmake/hip_backend.cmake(--export-dynamic,dl), withSTRATA_VRAM_BUDGET_MIB(default 10240),STRATA_VRAM_RUNTIME_RESERVE_MIB,STRATA_VRAM_SLACK_MIB,include/strata/platform/device_budget.hpp(new) —DeviceBudget, the serializable reservationaccounting used by callers,
docker/vram-guard.py+run.sh's budget checks (1281..10240 MiB).Tests:
docker/test_runtime_contract.py,tests/hip/device_budget.cpp(ctesthip_device_budget, run withSTRATA_VRAM_BUDGET_MIB=10240),src/platform/device_budget_test.cpp(ctestdevice_budget_test).3.
run.sh— one launcher, a release axis, Swift 1.5 by default (new file)mainhas norun.sh; the branch adds it and drops the branch-internalrun2.sh/run3.sh.Release axis:
--release qwen|swift|coder(or$STRATA_RELEASE, or implied by$STRATA_HF_REPO,or by the quant). Resolution is asked of
docker/hfmodel.py --print release, so the launcher and thecontainer cannot disagree, and a refusal from the resolver is the launcher's error message.
Per-release default quant: swift
IQ3_XXS, qwenIQ3_S, coderIQ1_M.Tuning keyed on release+quant (
case "$RELEASE:$MODEL"):qwen:IQ3_XXSqwen:IQ3_S,swift:IQ3_XXSautoRefuses before Docker sees data: wrong card (only
gfx1100/gfx1101),HSA_OVERRIDE_GFX_VERSIONset, a budget outside
1281..10240, any--max-contextother than 131072, a filesystem too small forthe quant plus its pack plus a 20 GB floor, and an image too old to carry the allocation guard (checked
through its
io.strata.vram-budgetlabel).$STRATA_HF_REPO now reaches the container (it did not before), and the release-qualified
STRATA_PACK_DIR/MODEL_NAME/HF_REPOare forwarded for non-qwen releases while the qwen linestays byte-identical to the pre-switch fixture.
docker/entrypoint-hip.shgives the same axis on the container side: the pack directory takes therelease tag (
packs/swift-iq3_xxsbesidepacks/iq3_xxs), the model id comes from the release name(
swift-1.5-iq3_xxs), the release license is logged at every start, and the pre-release-axis defaultsare kept whenever the resolver abstains.
Model resolution (
docker/hfmodel.py, +381)FAMILIES/MODELSmirrorsetup.py's table for the three releases. Two behaviour fixes are in thecurrent code:
(
*0000{i}-of-00002.gguf) let a request for a Swift quant that is absent in the cache resolve asibling quant's shard - the launcher would then report "cached" and advertise one quantization while
loading another. Offline now fails with the right fetch command.
per_layer_token_embd.weightinto file 1, the Qwen/Coder reposinto file 2; the resolver reports which, and the entrypoint takes it as
STRATA_PLE_FILE.Pinned by
docker/test_hfmodel_release.py,docker/test_hfmodel_ple.py, and (for packs)docker/test_pack_provenance.py:experts.bin.src.jsonshard names must belong to the selected release orthe container refuses to start (the quant vocabulary is shared, so the wrong pack is silent corruption);
a pack predating that file warns by name only.
4. Cache-aware routing (engine, default on)
New:
include/strata/core/car.hpp,src/core/car.cpp,tests/core/car_substitute_test.cpp,tools/car_estimate.py,tools/test_car_estimate.py.Changed:
verify.hpp/verify.cpp(score publication + the per-group host hook),expert_source.hpp/expert_source.cpp(car_apply,car_report, backfill intousage),elementwise.hpp/elementwise.cu(optional weights/router-score publication indoorbell_publish_res),generate.cpp(flags,
STRATA_CAR_*, refusals, reports).The rule: a decode window's uncached pick
Eis replaced by the best resident expertCthat the tokendid not already select, when
p_C / p_Eclears the threshold. The substituted entry keeps its router weightand the GPU computes the resident expert from a slot already in VRAM. The decision is a pure function with
its own translation unit and its own test (it builds and runs in a CPU-only configuration); the
implementation allocates nothing per token and is deterministic (best ratio first, ties by lower id).
--car-threshold 0.35.1.0is OFF and restores the stock model's tokens byte for byte(verified against the build that predates the feature).
--car-threshold 1.0is the fidelity escapehatch;
docs/DETAILS.mdstates plainly that the default changes answers.--car-threshold,--car-warmup,--car-budget,--car-free-ratioandSTRATA_CAR_*(a flag always wins over the environment).
--car-dampen 1is refused rather than ignored.from the default, they print "cache-aware routing is OFF for this run" and downgrade to 1.0 (no pool,
--spec 0,--batch/--slots,--layer-split,--peer-device,--remote-expert-opt,STRATA_VERIFY_DEVICE_PLAN=1).STRATA_DUMP_ROUTER_SCORES=<path>writes aSTRCS1trace (ids + the whole score row per token, beforeany substitution);
tools/car_estimate.pyreplays a trace offline against the same rules and can checkits copy of the rule against the engine's own golden case.
Measured (RX 7700 XT, gfx1101, 10 GiB share, Swift 1.5 IQ3_XXS,
./run.shwith no flags, 4K-8K prompt,8 trials per arm, as recorded in
docs/DETAILS.md): decode 30.5 → 35.3 tokens/s (+15.5%), the window86.0 → 75.3 ms, the CPU pool's share -28% (20.4 → 14.7 ms per layer-window) at 30.8% of decode misses
substituted (mean accepted ratio 0.598); the VRAM hit kernel grows ~3x, which is where the work moved. Peak
card share 9,931 MiB off / 10,155 MiB at
--car-threshold 1.0, both under the 10,240 MiB contract.tools/car_estimate.py(offline): 30.6% of misses at 0.35 (2.7/token), 42.9% at 0.25, 18.3% at 0.5, 8.3% at0.7; 94.5% of substitutions are ranks 5-9 of the ten.
Limits, as documented in
docs/DETAILS.md: perplexity/KL against CAR off is not measured, and neitherare the other shipped lines (Qwen IQ3_S, Coder). The quality evidence is the coding smoke (205/205),
needles 9/9 at 1k/4k/32k, and the bounded rule above.
5. gfx1101 prompt-GEMM calibration
tools/hip/gfx1101-hipblaslt-100202.txt— a 58-row hipBLASLt table (RX 7700 XT, Swift 1.5 IQ3_XXS,ROCm 7.2.1-complete, including dense T=128/512/2048).
docs/AMD_HIP.mdrecords it and stops claiminggfx1101 has no table;
docs/AMD_HIP_GFX1101_TUNING.mdis the calibration/validation record.tools/hip/tune_hipblaslt.cppgains--warmups/--repetitions/--iterations/--max-algos(defaultsunchanged in effect) and reports them.
tests/hip/prefill_hipblaslt_gemm.cppgains--all, which validates every row at its calibrated Twith
beta=0andbeta=1+ output offset, plus a repeated-call descriptor-cache timing; the defaultsmoke keeps its four pinned cases and now prints how many rows it covered.
src/prefill/gemm.cubounds the hipBLASLt metadata (cache and fallback-shape set) at 512 entries soarbitrary tail shapes cannot grow server metadata without limit.
6. CPU expert pool: the intermediate quantization as a parallel phase
pool.hpp/pool.cppadd drain mode 7: the per-(expert, token) intermediate quantization of a multi-tokenlayer runs across the pool and the host instead of as a single-threaded nested loop (the phase barrier is
still required; the work no longer sits on one thread).
prepare_quant_taskskeeps a running count perexpert, so no per-task allocation happens.
STRATA_POOL_PARALLEL_QUANT=0restores the sequential loop (theA/B arm) and
STRATA_POOL_QUANT_MIN_TASKS(default 8, the measured crossing) keeps it on the host below thesize where the barrier costs more than the work. Both arms call the same function with the same arguments,
so the results are bitwise equal.
Recorded in the header from the bench: 0.27x/0.5x at 1-2 tasks up to ~2.0x at 64-96; end to end
pool multi quantize 0.457 → 0.280 ms/roundover eight runs (1.6x on that step, ~0.18% of a ~100 ms decoderound), byte-identical generated tokens. Tests:
src/kernels/cpu/pool_quant_test.cpp(ctestpool_quant_test)against a serial reference, and
src/kernels/cpu/pool_topology_test.cpp(Linux-only).7. Serving: streaming tool calls and the deployment's reasoning effort
OutputParser.feedused to re-scan the whole growing call bodyfor every delta (quadratic, and it could end a call early on a literal closing tag inside a parameter
value). A
_CallBoundarywalker now tracks call structure once, keeps only a possible delimiter prefix,and only a structural follower closes a parameter; raw parameter text is accumulated across deltas.
Pinned by
serve/test_parser_stream.py(5 tests, run withPYTHONPATH=.).reasoning_effortis validated at startup(
serve/server.py→frontend.default_effort, a typo refuses instead of 400-ing every request later) andfills the effort for requests that name none, for both the OpenAI and Anthropic shapes; a request's own
value always wins. The container writes it from
STRATA_REASONING_EFFORT(defaulthigh).8. Smaller engine/test changes in the same net diff
src/program/generate.cpp:--capabilities/--list-architecturesprints the architectures this binarycan serve (
qwen4exp) and exits;STRATA_PREFILL_MEMORY_REPORTprints the prefill scratch/cache/slotarithmetic per chunk size; the pool line now says which quantization arm ran; CAR flags/reports as above.
src/kernels/cuda/iq_kernels.cu: Q4_K admitted on the down side too (one more kernel template, keepsthe down path whole for a Unsloth UD-Q4_K_XL-style pack), and the Q2_0 half-path sign fix is widened from
gfx1012+HIP<7 to every HIP build (measured to fold on ROCm 7.2.1/gfx1101 as well).src/kernels/native_expert_parity.cpp: expert geometry fromSTRATA_PARITY_H/STRATA_PARITY_FF(default2560/640) so the harness can check another model's geometry; CMake moves the two Q5_0 pairs to CUDA-only
because their fp16-dequant bit-equality fails on gfx1101/ROCm 7.2.1 (Q4_K/Q5_1, Q4_K/Q8_0, Q5_K/Q8_0,
Q8_0/Q8_0 pass on both), and points
qsa_prompt_attn_parityat the project's GPU target variables so itlinks in a HIP build.
include/strata/core/verify.hpp/src/core/verify.cpp: the batch verify path (--batch/--slots)refuses CAR explicitly instead of silently substituting nothing.
tests/core/expert_cache_segmented_test.cpp: skips (77) when the segmented cache reports "CUDA-only" in aHIP build, as it already did for missing VMM.
tools/hip/:bench_discover.py(serial, token-counted streaming probes),bench_parser.py(compare anarchived frontend against the current parser, no model needed),
check_coding_task.py(the coding smokewith an independent oracle),
bench_prefill.py --trials/--start-trial,tokens_for_bench.py.docs/DOCKER_GFX1101_PLAN.md(plan + verified machine facts + acceptance checklist),PLAN_TEMPLATE.md(the plan template),
DISCOVER.md(the discovery/implementation plan).9. Repository hygiene (and one change to review)
.gitignore:plans/, the Amanda harness dirs (.amanda/,amanda/) andornith-1.5.md— workingplans are local records (per
PLAN_TEMPLATE.md). Those paths are the whole of the plans/harness changein this diff: the branch's own plan records were added and untracked inside the branch, so none of them
reaches
main(plans/is empty of tracked files in this tree).AGENTS.md: notes that the Qwen35MoE/Ornith-1.5 backend was prototyped and removed, and where its recordlives.
⚠️
bench/results/is deleted by this branch — 172 tracked files, ~50k lines. This is the one change Iwould confirm before merging, because the current tree still depends on it:
python -m unittest discover -s dockerruns 34 tests and6 error with
FileNotFoundErrorfor fixtures underbench/results/2026-10-04-iq3s-tuning/,.../2026-10-04-launcher-consolidation/and.../2026-10-05-run-default-swift/(
test_launcher_contract.py), so the launcher contract is currently unpinned;bench/results/..., includingAGENTS.md,DISCOVER.md,docker/README.md,docs/COMMUNITY_BENCHMARKS.md,docs/DETAILS.md,docs/MULTI_GPU.md,docs/NVIDIA_V100.md,run.sh,docker/Dockerfile.hip,docker/hfmodel.pyand several engine headers;PR removes.
Either restore the record or repoint the fixtures and links (a fixture copy under
tests/and a note indocs/would be enough for the tests).docker/test_hfmodel_ple.pyandtest_launcher_contract.pycurrently read fixtures from that tree, so it is not only documentation that depends on it.
10. What is not in this PR
The branch also contains ~25 commits that build a Qwen35MoE/Ornith-1.5 backend (
run3.sh, its own modelidentity, GGUF loader, GDN/attention/MoE forward pass, a GPU dense tier) and then a commit that removes all
of it. Net effect on
main: zero — none of those files exist in the tree at9dbc79e,--capabilitiesanswers
qwen4exponly, and the launcher has no Ornith line. The generic pieces those commits left behindare in the diff above (the Q4_K down-projection admission, the parity harness's geometry env vars,
--capabilities) anddocs/ornith/gguf-layout.txt, kept as a record of the inspected GGUF layout.11. Behaviour changes to expect / breaking changes
run.shships with Swift 1.5 IQ3_XXS as its default line (this also reverses the branch's ownearlier Qwen IQ3_S default). A Qwen line must be asked for explicitly
(
./run.sh --release qwen --model IQ3_S), and$STRATA_MODELalone now names a quant of thedefault release.
--car-threshold 0.35): answers are no longer the stock model's, and theengine says so at startup.
--car-threshold 1.0restores byte-identical tokens. Documented indocs/DETAILS.md, including what is not measured.STRATA_POOL_PARALLEL_QUANT=0for the old loop).reasoning_effort(defaulthigh), which now applies torequests that name none, and an invalid value refuses startup.
gfx1101is now a first-class target inrun.sh/build.sh, in a container whose provider isrocm/dev-ubuntu-24.04:7.2.1-complete;HSA_OVERRIDE_GFX_VERSIONis refused on it.The engine's default decode path matches
main's byte for byte only with--car-threshold 1.0.12. How to verify (no GPU or downloads needed)
tools/test_setup_amd.pyhas 1 failure (28 tests) in this tree; that failure is already present onmainand
setup.pyis not modified by this branch, so it is not part of this PR.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.