[PR #1017] [CLOSED] feature: RDNA3 support / Cache-aware routing #2967

Closed
opened 2026-11-04 02:04:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 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+)

  • 04cdd86 kernels: Q4_K down projection in the grouped native expert path
  • 89ec72d ornith: run3.sh launcher, single-file cache resolution and docs
  • 711f058 qwen35 test: fix the header-out flag name in the comment
  • d541220 Prompt path: an MMQ group's experts gathered in one launch, after one wait, released by one event
  • 6639c7b Prompt path: the first chunk's n-gram (PLE) rows read beside layer 0, 256 at a time
  • 4f7b3e8 ple_land: the rows' upload, its event and the wait before a refill are checked
  • 3a91b9c Prompt path: a stager buffer's first job of a generation waits for the previous DMA from it
  • ba790d6 prefill: the draft layer's batched K/V for a ring too (KV streaming), and STRATA_DRAFT_TIMING
  • 778e1f6 qsa_prompt_attn: Q4_0 K and V on tensor cores (mode 4) - long prompts with --kv q4_0 no longer take the old kernel
  • 79670a6 qsa_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

  • RDNA3 (gfx1101) support
  • Swift 1.5 launcher
  • Cache-aware routing
  • Docker build/run

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 commit
messages: 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:

  • a HIP/Docker build-and-run path for gfx1101 (RX 7700 XT) under an enforced 10 GiB VRAM contract:
    build.sh (builder + runtime images), docker/ (entrypoint, model bootstrap, device probe, VRAM guard),
  • run.sh, one launcher for the container (the branch's own run2.sh/run3.sh are gone, so this is
    the 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),
  • cache-aware routing (CAR) in the engine: a decode window's uncached expert is replaced by the best
    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.0 restoring byte-identical stock tokens,
  • a parallel intermediate activation quantization phase in the CPU expert pool (PR #500),
  • gfx1101 prompt-GEMM calibration (a 58-row hipBLASLt table plus the tooling and the record),
  • two serving fixes: an unbounded/incorrect streaming tool-call parser, and a deployment-wide default
    reasoning effort.

2. Docker / HIP build and run path for gfx1101 (new)

File What it does
build.sh Builds strata-hip-builder:<arch> (ROCm toolchain) → compiles the engine into ./build-hip (ccache volume) → builds strata-hip:<arch> (+ -<gitsha>, -latest). --tests, --arch, --runtime-only.
docker/Dockerfile.hip-builder ROCm 7.2 builder image.
docker/Dockerfile.hip Runtime image (rocm/dev-ubuntu-24.04:7.2.1-complete): engine, serve/, tools/, model bootstrap. The compiled binary arrives through the engine named build context, so the build context stays source-only.
docker/build-engine.sh The in-container CMake configure/build (Ninja, MMQ prefill, ccache).
docker/entrypoint-hip.sh Guard → device → VRAM budget → model/pack → engine config → server. All tuning by environment; the config it writes is the one the server reads.
docker/bootstrap-model.sh Check-and-fetch the quant and the pack; check mode never writes. Free-space gate before any download.
docker/hipinfo.py GPU discovery from the KFD topology (no ROCm Python bindings), with --arch, --vram, --render-node, --reserve-mib.
docker/vram-guard.py Samples device memory against the 10 GiB budget, with --pid attribution to the container's engine.
docker/README.md The image/run story and the measured facts (engine build, GPU suite, VRAM peak, first-start download).
.dockerignore Rewritten for the HIP context: build trees, GGUFs, packs, harness state and captures excluded.

The 10 GiB ceiling is enforced in three places in the current code, not one:

  1. src/core/hip_budget.cpp (new) — a Linux HIP interposer over the allocation APIs, enabled from
    cmake/hip_backend.cmake (--export-dynamic, dl), with STRATA_VRAM_BUDGET_MIB (default 10240),
    STRATA_VRAM_RUNTIME_RESERVE_MIB, STRATA_VRAM_SLACK_MIB,
  2. include/strata/platform/device_budget.hpp (new) — DeviceBudget, the serializable reservation
    accounting used by callers,
  3. docker/vram-guard.py + run.sh's budget checks (1281..10240 MiB).

Tests: docker/test_runtime_contract.py, tests/hip/device_budget.cpp (ctest hip_device_budget, run with
STRATA_VRAM_BUDGET_MIB=10240), src/platform/device_budget_test.cpp (ctest device_budget_test).

3. run.sh — one launcher, a release axis, Swift 1.5 by default (new file)

main has no run.sh; the branch adds it and drops the branch-internal run2.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 the
    container cannot disagree, and a refusal from the resolver is the launcher's error message.

  • Per-release default quant: swift IQ3_XXS, qwen IQ3_S, coder IQ1_M.

  • Tuning keyed on release+quant (case "$RELEASE:$MODEL"):

    release:quant expert cache later allowance prefill ring
    qwen:IQ3_XXS 800 (the 0.1.39 pin, unchanged) 768 none
    qwen:IQ3_S, swift:IQ3_XXS auto 700 48
    anything else 680 (conservative) 768 none, with a warning that the combination is unmeasured
  • Refuses before Docker sees data: wrong card (only gfx1100/gfx1101), HSA_OVERRIDE_GFX_VERSION
    set, a budget outside 1281..10240, any --max-context other than 131072, a filesystem too small for
    the 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-budget label).

  • $STRATA_HF_REPO now reaches the container (it did not before), and the release-qualified
    STRATA_PACK_DIR / MODEL_NAME / HF_REPO are forwarded for non-qwen releases while the qwen line
    stays byte-identical to the pre-switch fixture.

  • docker/entrypoint-hip.sh gives the same axis on the container side: the pack directory takes the
    release tag (packs/swift-iq3_xxs beside packs/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 defaults
    are kept whenever the resolver abstains.

Model resolution (docker/hfmodel.py, +381)

FAMILIES/MODELS mirror setup.py's table for the three releases. Two behaviour fixes are in the
current code:

  • A shard must belong to the quant that was asked for. The old name-blind catch-all
    (*0000{i}-of-00002.gguf) let a request for a Swift quant that is absent in the cache resolve a
    sibling 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-release PLE file. Swift packs per_layer_token_embd.weight into file 1, the Qwen/Coder repos
    into 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.json shard names must belong to the selected release or
the 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 into usage), elementwise.hpp/
elementwise.cu (optional weights/router-score publication in doorbell_publish_res), generate.cpp
(flags, STRATA_CAR_*, refusals, reports).

The rule: a decode window's uncached pick E is replaced by the best resident expert C that the token
did not already select, when p_C / p_E clears the threshold. The substituted entry keeps its router weight
and 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).

  • Default --car-threshold 0.35. 1.0 is OFF and restores the stock model's tokens byte for byte
    (verified against the build that predates the feature). --car-threshold 1.0 is the fidelity escape
    hatch; docs/DETAILS.md states plainly that the default changes answers.
  • Knobs: --car-threshold, --car-warmup, --car-budget, --car-free-ratio and STRATA_CAR_*
    (a flag always wins over the environment). --car-dampen 1 is refused rather than ignored.
  • Paths it is not wired into are handled explicitly: with the feature asked for, they are an error; coming
    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 a STRCS1 trace (ids + the whole score row per token, before
    any substitution); tools/car_estimate.py replays a trace offline against the same rules and can check
    its 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.sh with 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 window
86.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% at
0.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 neither
are 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.md records it and stops claiming
    gfx1101 has no table; docs/AMD_HIP_GFX1101_TUNING.md is the calibration/validation record.
  • tools/hip/tune_hipblaslt.cpp gains --warmups/--repetitions/--iterations/--max-algos (defaults
    unchanged in effect) and reports them.
  • tests/hip/prefill_hipblaslt_gemm.cpp gains --all, which validates every row at its calibrated T
    with beta=0 and beta=1 + output offset, plus a repeated-call descriptor-cache timing; the default
    smoke keeps its four pinned cases and now prints how many rows it covered.
  • src/prefill/gemm.cu bounds the hipBLASLt metadata (cache and fallback-shape set) at 512 entries so
    arbitrary tail shapes cannot grow server metadata without limit.

6. CPU expert pool: the intermediate quantization as a parallel phase

pool.hpp/pool.cpp add drain mode 7: the per-(expert, token) intermediate quantization of a multi-token
layer 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_tasks keeps a running count per
expert, so no per-task allocation happens. STRATA_POOL_PARALLEL_QUANT=0 restores the sequential loop (the
A/B arm) and STRATA_POOL_QUANT_MIN_TASKS (default 8, the measured crossing) keeps it on the host below the
size 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/round over eight runs (1.6x on that step, ~0.18% of a ~100 ms decode
round), byte-identical generated tokens. Tests: src/kernels/cpu/pool_quant_test.cpp (ctest pool_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

  • Streaming tool-call parsing is fixed. OutputParser.feed used to re-scan the whole growing call body
    for every delta (quadratic, and it could end a call early on a literal closing tag inside a parameter
    value). A _CallBoundary walker 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 with PYTHONPATH=.).
  • Deployment default reasoning effort. A config's reasoning_effort is validated at startup
    (serve/server.py → frontend.default_effort, a typo refuses instead of 400-ing every request later) and
    fills 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 (default high).

8. Smaller engine/test changes in the same net diff

  • src/program/generate.cpp: --capabilities / --list-architectures prints the architectures this binary
    can serve (qwen4exp) and exits; STRATA_PREFILL_MEMORY_REPORT prints the prefill scratch/cache/slot
    arithmetic 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, keeps
    the 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 from STRATA_PARITY_H/STRATA_PARITY_FF (default
    2560/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_parity at the project's GPU target variables so it
    links 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 a
    HIP build, as it already did for missing VMM.
  • tools/hip/: bench_discover.py (serial, token-counted streaming probes), bench_parser.py (compare an
    archived frontend against the current parser, no model needed), check_coding_task.py (the coding smoke
    with 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/) and ornith-1.5.md — working
    plans are local records (per PLAN_TEMPLATE.md). Those paths are the whole of the plans/harness change
    in 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 record
    lives.

⚠️ bench/results/ is deleted by this branch — 172 tracked files, ~50k lines. This is the one change I
would confirm before merging, because the current tree still depends on it:

  • the branch's own docker suite fails: python -m unittest discover -s docker runs 34 tests and
    6 error with FileNotFoundError for fixtures under bench/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;
  • 24 tracked files reference bench/results/..., including AGENTS.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.py and several engine headers;
  • the measured numbers quoted above (Swift default line, IQ3_S tuning, CAR A/B) point at directories this
    PR removes.

Either restore the record or repoint the fixtures and links (a fixture copy under tests/ and a note in
docs/ would be enough for the tests). docker/test_hfmodel_ple.py and test_launcher_contract.py
currently 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 model
identity, 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 at 9dbc79e, --capabilities
answers qwen4exp only, and the launcher has no Ornith line. The generic pieces those commits left behind
are in the diff above (the Q4_K down-projection admission, the parity harness's geometry env vars,
--capabilities) and docs/ornith/gguf-layout.txt, kept as a record of the inspected GGUF layout.

11. Behaviour changes to expect / breaking changes

  1. run.sh ships with Swift 1.5 IQ3_XXS as its default line (this also reverses the branch's own
    earlier Qwen IQ3_S default). A Qwen line must be asked for explicitly
    (./run.sh --release qwen --model IQ3_S), and $STRATA_MODEL alone now names a quant of the
    default release.
  2. CAR is on by default (--car-threshold 0.35): answers are no longer the stock model's, and the
    engine says so at startup. --car-threshold 1.0 restores byte-identical tokens. Documented in
    docs/DETAILS.md, including what is not measured.
  3. The pool's intermediate quantization is parallel by default (byte-identical output;
    STRATA_POOL_PARALLEL_QUANT=0 for the old loop).
  4. The container's server config carries reasoning_effort (default high), which now applies to
    requests that name none, and an invalid value refuses startup.
  5. gfx1101 is now a first-class target in run.sh/build.sh, in a container whose provider is
    rocm/dev-ubuntu-24.04:7.2.1-complete; HSA_OVERRIDE_GFX_VERSION is refused on it.
  6. The CUDA path changes only in the Q2_0 half-sign fix, the bounded hipBLASLt metadata and the pool phase.
    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)

python3 -m unittest discover -s docker      # 34 tests; 6 currently error on the removed bench fixtures (§9)
python3 tools/test_car_estimate.py          # 13 tests, OK
PYTHONPATH=. python3 serve/test_parser_stream.py   # 5 tests, OK
python3 tools/test_setup_choices.py         # 35 tests, OK

./build.sh                                  # then, on the card
./build.sh --tests                          # the HIP test set (reported 42/44 in docker/README.md)
./run.sh --dry-run                          # the exact docker line for the default (Swift IQ3_XXS) release
./run.sh --release qwen --model IQ3_S --dry-run

tools/test_setup_amd.py has 1 failure (28 tests) in this tree; that failure is already present on main
and setup.py is 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.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1017 **Author:** [@dhoard](https://github.com/dhoard) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/rdna3-support` --- ### 📝 Commits (10+) - [`04cdd86`](https://github.com/Niko1221/Strata/commit/04cdd86800a0b28416a5e56febc7916009181a1e) kernels: Q4_K down projection in the grouped native expert path - [`89ec72d`](https://github.com/Niko1221/Strata/commit/89ec72d81c13dba9e3c3e521fedce3623f4363c3) ornith: run3.sh launcher, single-file cache resolution and docs - [`711f058`](https://github.com/Niko1221/Strata/commit/711f05822400b9a33243891ec112f99d67990846) qwen35 test: fix the header-out flag name in the comment - [`d541220`](https://github.com/Niko1221/Strata/commit/d541220a1c799f92c32538351bc7e156b2c2f643) Prompt path: an MMQ group's experts gathered in one launch, after one wait, released by one event - [`6639c7b`](https://github.com/Niko1221/Strata/commit/6639c7b82799a3d549b01aa497fbaf04101d1124) Prompt path: the first chunk's n-gram (PLE) rows read beside layer 0, 256 at a time - [`4f7b3e8`](https://github.com/Niko1221/Strata/commit/4f7b3e8291a6158069ec5212541b8118ed6ad49d) ple_land: the rows' upload, its event and the wait before a refill are checked - [`3a91b9c`](https://github.com/Niko1221/Strata/commit/3a91b9cd5596f2011b917d3b41a8a1689ec20da6) Prompt path: a stager buffer's first job of a generation waits for the previous DMA from it - [`ba790d6`](https://github.com/Niko1221/Strata/commit/ba790d68e3a70c5df96d45a2ae36fe31f031ca89) prefill: the draft layer's batched K/V for a ring too (KV streaming), and STRATA_DRAFT_TIMING - [`778e1f6`](https://github.com/Niko1221/Strata/commit/778e1f693d20e59bedbc01eee471d9e6772e9758) qsa_prompt_attn: Q4_0 K and V on tensor cores (mode 4) - long prompts with --kv q4_0 no longer take the old kernel - [`79670a6`](https://github.com/Niko1221/Strata/commit/79670a6e15542c7a14959b5eb837f00d5d8f8303) qsa_prompt_attn: Q4_0 mode 4 on sm_80+ only (#452 follow-up) ### 📊 Changes **7 files changed** (+340 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 Description # RDNA3 support - RDNA3 (gfx1101) support - Swift 1.5 launcher - Cache-aware routing - Docker build/run **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 commit messages: 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: * a HIP/Docker build-and-run path for **gfx1101 (RX 7700 XT)** under an enforced **10 GiB VRAM contract**: `build.sh` (builder + runtime images), `docker/` (entrypoint, model bootstrap, device probe, VRAM guard), * **`run.sh`**, one launcher for the container (the branch's own `run2.sh`/`run3.sh` are gone, so this is the 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), * **cache-aware routing (CAR)** in the engine: a decode window's uncached expert is replaced by the best *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.0` restoring byte-identical stock tokens, * a **parallel intermediate activation quantization** phase in the CPU expert pool (PR #500), * **gfx1101 prompt-GEMM calibration** (a 58-row hipBLASLt table plus the tooling and the record), * two serving fixes: an unbounded/incorrect streaming tool-call parser, and a deployment-wide default reasoning effort. ## 2. Docker / HIP build and run path for gfx1101 (new) | File | What it does | | --- | --- | | `build.sh` | Builds `strata-hip-builder:<arch>` (ROCm toolchain) → compiles the engine into `./build-hip` (ccache volume) → builds `strata-hip:<arch>` (+ `-<gitsha>`, `-latest`). `--tests`, `--arch`, `--runtime-only`. | | `docker/Dockerfile.hip-builder` | ROCm 7.2 builder image. | | `docker/Dockerfile.hip` | Runtime image (`rocm/dev-ubuntu-24.04:7.2.1-complete`): engine, `serve/`, `tools/`, model bootstrap. The compiled binary arrives through the `engine` **named build context**, so the build context stays source-only. | | `docker/build-engine.sh` | The in-container CMake configure/build (Ninja, MMQ prefill, ccache). | | `docker/entrypoint-hip.sh` | Guard → device → VRAM budget → model/pack → engine config → server. All tuning by environment; the config it writes is the one the server reads. | | `docker/bootstrap-model.sh` | Check-and-fetch the quant and the pack; `check` mode never writes. Free-space gate before any download. | | `docker/hipinfo.py` | GPU discovery from the KFD topology (no ROCm Python bindings), with `--arch`, `--vram`, `--render-node`, `--reserve-mib`. | | `docker/vram-guard.py` | Samples device memory against the 10 GiB budget, with `--pid` attribution to the container's engine. | | `docker/README.md` | The image/run story and the measured facts (engine build, GPU suite, VRAM peak, first-start download). | | `.dockerignore` | Rewritten for the HIP context: build trees, GGUFs, packs, harness state and captures excluded. | The 10 GiB ceiling is enforced in three places in the current code, not one: 1. `src/core/hip_budget.cpp` (new) — a Linux HIP interposer over the allocation APIs, enabled from `cmake/hip_backend.cmake` (`--export-dynamic`, `dl`), with `STRATA_VRAM_BUDGET_MIB` (default 10240), `STRATA_VRAM_RUNTIME_RESERVE_MIB`, `STRATA_VRAM_SLACK_MIB`, 2. `include/strata/platform/device_budget.hpp` (new) — `DeviceBudget`, the serializable reservation accounting used by callers, 3. `docker/vram-guard.py` + `run.sh`'s budget checks (`1281..10240 MiB`). Tests: `docker/test_runtime_contract.py`, `tests/hip/device_budget.cpp` (ctest `hip_device_budget`, run with `STRATA_VRAM_BUDGET_MIB=10240`), `src/platform/device_budget_test.cpp` (ctest `device_budget_test`). ## 3. `run.sh` — one launcher, a release axis, Swift 1.5 by default (new file) `main` has no `run.sh`; the branch adds it and drops the branch-internal `run2.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 the container cannot disagree, and a refusal from the resolver is the launcher's error message. * **Per-release default quant:** swift `IQ3_XXS`, qwen `IQ3_S`, coder `IQ1_M`. * **Tuning keyed on release+quant** (`case "$RELEASE:$MODEL"`): | release:quant | expert cache | later allowance | prefill ring | | --- | --- | --- | --- | | `qwen:IQ3_XXS` | 800 (the 0.1.39 pin, unchanged) | 768 | none | | `qwen:IQ3_S`, `swift:IQ3_XXS` | `auto` | 700 | 48 | | anything else | 680 (conservative) | 768 | none, with a warning that the combination is unmeasured | * **Refuses** before Docker sees data: wrong card (only `gfx1100`/`gfx1101`), `HSA_OVERRIDE_GFX_VERSION` set, a budget outside `1281..10240`, any `--max-context` other than 131072, a filesystem too small for the 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-budget` label). * **$STRATA_HF_REPO now reaches the container** (it did not before), and the release-qualified `STRATA_PACK_DIR` / `MODEL_NAME` / `HF_REPO` are forwarded for non-qwen releases while the qwen line stays byte-identical to the pre-switch fixture. * `docker/entrypoint-hip.sh` gives the same axis on the container side: the pack directory takes the release tag (`packs/swift-iq3_xxs` beside `packs/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 defaults are kept whenever the resolver abstains. ### Model resolution (`docker/hfmodel.py`, +381) `FAMILIES`/`MODELS` mirror `setup.py`'s table for the three releases. Two behaviour fixes are in the current code: * **A shard must belong to the quant that was asked for.** The old name-blind catch-all (`*0000{i}-of-00002.gguf`) let a request for a Swift quant that is absent in the cache resolve a sibling 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-release PLE file.** Swift packs `per_layer_token_embd.weight` into file 1, the Qwen/Coder repos into 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.json` shard names must belong to the selected release or the 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 into `usage`), `elementwise.hpp`/ `elementwise.cu` (optional weights/router-score publication in `doorbell_publish_res`), `generate.cpp` (flags, `STRATA_CAR_*`, refusals, reports). The rule: a decode window's uncached pick `E` is replaced by the best **resident** expert `C` that the token did not already select, when `p_C / p_E` clears the threshold. The substituted entry keeps its router weight and 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). * **Default `--car-threshold 0.35`.** `1.0` is OFF and restores the stock model's tokens byte for byte (verified against the build that predates the feature). `--car-threshold 1.0` is the fidelity escape hatch; `docs/DETAILS.md` states plainly that the default changes answers. * Knobs: `--car-threshold`, `--car-warmup`, `--car-budget`, `--car-free-ratio` and `STRATA_CAR_*` (a flag always wins over the environment). `--car-dampen 1` is **refused** rather than ignored. * Paths it is not wired into are handled explicitly: with the feature asked for, they are an error; coming 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 a `STRCS1` trace (ids + the whole score row per token, before any substitution); `tools/car_estimate.py` replays a trace offline against the same rules and can check its 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.sh` with 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 window 86.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% at 0.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 neither are 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.md` records it and stops claiming gfx1101 has no table; `docs/AMD_HIP_GFX1101_TUNING.md` is the calibration/validation record. * `tools/hip/tune_hipblaslt.cpp` gains `--warmups/--repetitions/--iterations/--max-algos` (defaults unchanged in effect) and reports them. * `tests/hip/prefill_hipblaslt_gemm.cpp` gains `--all`, which validates **every** row at its calibrated T with `beta=0` and `beta=1` + output offset, plus a repeated-call descriptor-cache timing; the default smoke keeps its four pinned cases and now prints how many rows it covered. * `src/prefill/gemm.cu` bounds the hipBLASLt metadata (cache and fallback-shape set) at 512 entries so arbitrary tail shapes cannot grow server metadata without limit. ## 6. CPU expert pool: the intermediate quantization as a parallel phase `pool.hpp`/`pool.cpp` add drain mode 7: the per-(expert, token) intermediate quantization of a multi-token layer 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_tasks` keeps a running count per expert, so no per-task allocation happens. `STRATA_POOL_PARALLEL_QUANT=0` restores the sequential loop (the A/B arm) and `STRATA_POOL_QUANT_MIN_TASKS` (default 8, the measured crossing) keeps it on the host below the size 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/round` over eight runs (1.6x on that step, ~0.18% of a ~100 ms decode round), byte-identical generated tokens. Tests: `src/kernels/cpu/pool_quant_test.cpp` (ctest `pool_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 * **Streaming tool-call parsing is fixed.** `OutputParser.feed` used to re-scan the whole growing call body for every delta (quadratic, and it could end a call early on a literal closing tag inside a parameter value). A `_CallBoundary` walker 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 with `PYTHONPATH=.`). * **Deployment default reasoning effort.** A config's `reasoning_effort` is validated at startup (`serve/server.py` → `frontend.default_effort`, a typo refuses instead of 400-ing every request later) and fills 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` (default `high`). ## 8. Smaller engine/test changes in the same net diff * `src/program/generate.cpp`: `--capabilities` / `--list-architectures` prints the architectures this binary can serve (`qwen4exp`) and exits; `STRATA_PREFILL_MEMORY_REPORT` prints the prefill scratch/cache/slot arithmetic 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, keeps the 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 from `STRATA_PARITY_H`/`STRATA_PARITY_FF` (default 2560/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_parity` at the project's GPU target variables so it links 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 a HIP build, as it already did for missing VMM. * `tools/hip/`: `bench_discover.py` (serial, token-counted streaming probes), `bench_parser.py` (compare an archived frontend against the current parser, no model needed), `check_coding_task.py` (the coding smoke with 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/`) and `ornith-1.5.md` — working plans are local records (per `PLAN_TEMPLATE.md`). Those paths are the whole of the plans/harness change in 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 record lives. **⚠️ `bench/results/` is deleted by this branch — 172 tracked files, ~50k lines.** This is the one change I would confirm before merging, because the current tree still depends on it: * the branch's **own** docker suite fails: `python -m unittest discover -s docker` runs 34 tests and **6 error** with `FileNotFoundError` for fixtures under `bench/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; * **24 tracked files** reference `bench/results/...`, including `AGENTS.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.py` and several engine headers; * the measured numbers quoted above (Swift default line, IQ3_S tuning, CAR A/B) point at directories this PR removes. Either restore the record or repoint the fixtures and links (a fixture copy under `tests/` and a note in `docs/` would be enough for the tests). `docker/test_hfmodel_ple.py` and `test_launcher_contract.py` currently 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 model identity, 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 at `9dbc79e`, `--capabilities` answers `qwen4exp` only, and the launcher has no Ornith line. The generic pieces those commits left behind are in the diff above (the Q4_K down-projection admission, the parity harness's geometry env vars, `--capabilities`) and `docs/ornith/gguf-layout.txt`, kept as a record of the inspected GGUF layout. ## 11. Behaviour changes to expect / breaking changes 1. **`run.sh` ships with Swift 1.5 IQ3_XXS as its default line** (this also reverses the branch's own earlier Qwen IQ3_S default). A Qwen line must be asked for explicitly (`./run.sh --release qwen --model IQ3_S`), and `$STRATA_MODEL` alone now names a quant of the **default** release. 2. **CAR is on by default** (`--car-threshold 0.35`): answers are no longer the stock model's, and the engine says so at startup. `--car-threshold 1.0` restores byte-identical tokens. Documented in `docs/DETAILS.md`, including what is not measured. 3. **The pool's intermediate quantization is parallel by default** (byte-identical output; `STRATA_POOL_PARALLEL_QUANT=0` for the old loop). 4. **The container's server config carries `reasoning_effort`** (default `high`), which now applies to requests that name none, and an invalid value refuses startup. 5. `gfx1101` is now a first-class target in `run.sh`/`build.sh`, in a container whose provider is `rocm/dev-ubuntu-24.04:7.2.1-complete`; `HSA_OVERRIDE_GFX_VERSION` is refused on it. 6. The CUDA path changes only in the Q2_0 half-sign fix, the bounded hipBLASLt metadata and the pool phase. 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) ```sh python3 -m unittest discover -s docker # 34 tests; 6 currently error on the removed bench fixtures (§9) python3 tools/test_car_estimate.py # 13 tests, OK PYTHONPATH=. python3 serve/test_parser_stream.py # 5 tests, OK python3 tools/test_setup_choices.py # 35 tests, OK ./build.sh # then, on the card ./build.sh --tests # the HIP test set (reported 42/44 in docker/README.md) ./run.sh --dry-run # the exact docker line for the default (Swift IQ3_XXS) release ./run.sh --release qwen --model IQ3_S --dry-run ``` `tools/test_setup_amd.py` has 1 failure (28 tests) in this tree; that failure is already present on `main` and `setup.py` is not modified by this branch, so it is not part of this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:04:33 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2967
No description provided.