/loom:loom-rooflinefrom loom
Computes hardware roofline ceilings for LLM inference on AMD Strix Halo / Radeon AI PRO R9700 from a GGUF model, sets realistic optimization targets for decode, prefill, and throughput, and provides a stopping rule. Use before any open-ended 'optimize this model' or 'beat llama.cpp' request.
Ships in loom. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Bundled paths ? first shell action. Before running commands, set LOOM_SKILL_DIR in the shell to the
absolute directory containing this SKILL.md, using its path from the skill listing or read tool.
In Claude Code, run export LOOM_SKILL_DIR="${CLAUDE_SKILL_DIR}" (the host substitutes the path).
In Codex, Pi or another host, export LOOM_SKILL_DIR to the loaded file's directory. Use a
shell-compatible absolute path (Git Bash on Windows). Rebind before using another skill's commands
and in every new shell; it is not the working directory or SDK root. On Windows, use native C:/...
paths for file tools; /c/... paths belong to Git Bash. Never run an unresolved placeholder. Run bundled commands by quoted absolute path; do not run scripts/... from the working directory
or change into the installed skill tree. Install the complete Loom suite: sibling paths are required.
The point is to decide once, up front, with numbers, what the port should reach,
so the optimization loop (loom-optimize) has a finish line, and so a stopping
decision is a measurement rather than a debate.
Read the request for two optional inputs: a performance target and a time budget. A budget the user states covers what they asked for; by default it is the whole job, from the first command to the published report (table row 1), including builds, gates and reverted attempts. Report how long each phase took.
| User said | Goal | Budget (--budget-h) |
|---|---|---|
| Nothing, end-to-end job ("get X working, optimize, report") | The roofline TARGET per headline metric, then stretch | The model's roofline budget for the whole job (e2e_budget.py MODEL.gguf: fixed agent work + optimization + the measured workload at this model's decode/prefill speed). qualify.sh passes what is left after the port and qualification, minus the final gates + report (at least 10 min) |
| Nothing, existing port ("optimize this model") | TARGET, then stretch | 30 min |
| A time only ("spend 3 hours", "quick pass", "overnight") | TARGET, then stretch | As stated. "Quick" ≈ 0.5 h, "thorough" ≈ 4 h, "overnight" ≈ 8 h, "don't work all night" caps it |
| A target only ("+50 % decode", "70 tok/s") | The user's target (--goal decode_tps=N) | No fixed cap. The rate controller still stops when no path can reach the target. If the projected time is more than ~2 h, say so with the numbers as soon as it is known |
| Both | The user's target | As stated. If the projected time exceeds the budget, say so early: give what the budget buys, and what the target would take |
In every case:
decode/prefill topics (kb.py route --topic decode,prefill)
that have a measured gain on a similar model are the cheapest ms/h there is. Apply
them in catalog order before inventing new ones (skipping them for untested ideas cost
a trial 1–2 % decode).qualify.sh already subtracts it from the budget it computes; by hand, --reserve-min,
default 10). Never overrun the budget by starting an attempt that cannot finish its
gates in time.cfg.json. The cfg supplies sliding layers, KV sharing
(kv_layers) and head_dim_swa, which the GGUF may not spell out.
qwen4exp needs no cfg: a per-layer-embedding table costs 16 rows (90 B) per token, not its 27 GiB; sparse indexed attention
reads indexer.top_k positions plus the indexer's compressed keys (an estimate); hyper-connection matrices stream like any weight.pick_llamacpp.sh), measured with perf.py --kind llama into
bench/perf_log.jsonl. roofline.py --baseline bench/perf_log.jsonl reads the
latest llama.cpp rows from it.T=~/loom/.tools/bin/python; R="${LOOM_SKILL_DIR}"
# qualify.sh runs this for you, with the budget from section 0. By hand:
$T "$R/roofline.py" MODEL.gguf --cfg cfg.json --baseline bench/perf_log.jsonl --ctx 1000,2000,16000 --out bench/roofline.json \
--budget-h 0.5 # the user's budget (section 0); add --goal decode_tps=70 for a user target
Long-context models (context ≥ 128k): add the long sizes to --ctx (e.g.
--ctx 1000,2000,16000,131072) and measure them (perf.py --long), so long prefill
gets a target. It is quadratic in attention and, for hybrids, sequential in the
recurrent layers, and it is what makes the full-context gate slow: Qwen3.5-0.8B
prefilled 2k tokens at ~3,500 tok/s but a 261k prompt at ~400 tok/s before any
optimization. Levers, cheapest first: a larger prefill chunk (build.py --prefill 4096),
flash2 at head_dim 256 in two 128-wide passes instead of reloading Q, and a chunked
parallel scan for gated delta-net layers.
The script prints the bytes read per decode token, broken down by kind, so you can
see where decode time must go:
Per metric it then prints a row:
| Column | Meaning |
|---|---|
| ceiling | Hardware roofline. Decode: the device bandwidth (Strix Halo 228 GB/s, measured) ÷ (weights + KV read per token). Prefill: the device's dense f16 WMMA rate at a power mode (--power; Strix Halo default 85 W: 43.8 TFLOP/s sustained, see Power modes below) ÷ (2·params + causal attention flops) per token; prefill rows print @ 85 W. c4: 4 tokens per weight pass. For MoE, the 4 tokens route to their own experts, so those weights are read for each token. |
| eff | llama.cpp's fraction of the ceiling. This, not Loom, decides how big the win can be. At eff 0.75, the most Loom can gain is about 1.3×. At eff 0.15, 3–6× is on the table, and such results are routinely reported for new architectures, MoE and prefill. |
| TARGET | ceiling × the best efficiency a Loom port has actually reached on this hardware (EFF in the script; sources in the loom-kb roofline topic (kb.py route --topic roofline)). Realistic by construction. |
| margin | TARGET ÷ llama.cpp − 1. Reported as is, with no cap and no label. |
| stretch | ceiling × STRETCH: what the known but not yet built levers should give (GEMM efficiency already seen in isolation, small-op fusion, batched expert gather). |
| at-ceiling | Under 3 % headroom: llama.cpp is near the roofline. Target parity and spend runner time elsewhere. |
Sanity-check the model before trusting it. If llama.cpp's eff is above about
0.95 on any metric, the roofline undercounts. Check for a missed sliding window, KV
sharing, a gathered table counted in full, or a wrong expert count. Fix that before
setting targets.
Devices. --device selects the hardware preset (roofline.DEVICES); --bw / --flops still override it (an override is labelled override).
llama.cpp's MMQ prefill uses int8 WMMA: on gfx11 (Strix Halo, RDNA 3/3.5) iu8 WMMA runs at the SAME rate as f16 (measured, DevLab kbench run 44642983266), so the f16 ceiling holds for every engine there; on gfx12 (R9700) iu8 is twice the f16 rate, so llama.cpp's prefill can approach or pass an f16 ceiling. make_info.py roofline --device takes the same names and records the preset's name on the card.
--device | GPU | bw (streaming) | flops (dense f16 WMMA) |
|---|---|---|---|
strix-halo (default) | Ryzen AI Max+ 395, gfx1151, LPDDR5X-8000 256-bit | 228 GB/s measured streaming read (256 peak) | 43.8 TFLOP/s @ 85 W (default), 48.4 @ 123 W; spec 59 (40 CU x 512 x 2.9 GHz) |
radeon-r9700 | Radeon AI PRO R9700, gfx1201, 32 GB GDDR6 20 Gbps 256-bit | 613 GB/s measured (Loom streaming read on the DevLab R9700S; 640 peak) | 191 TFLOP/s (64 CU x 1024 x 2.92 GHz: RDNA4 doubles the dense f16 WMMA rate per CU; 383 is the sparse figure) |
radeon-r9700s | R9700S: the DevLab radeon-r9700 runners (same memory, 2.35 GHz max clock) | 613 GB/s measured | 214 TFLOP/s (measured peak f16 WMMA on the runner, devlab-kbench gemm_r9700) |
Power modes (compute ceilings). Strix Halo is power-limited: random-data WMMA never holds the spec clock, so the
spec-sheet peak is not a ceiling anyone reaches. A preset's power_modes (device.json roofline) hold the measured
sustained register-only random-f16 WMMA rate per platform power mode; --power picks one (make_info.py roofline --power too), spec gives the spec-sheet peak, and the default is the preset's power_default: for Strix Halo 85w,
the BIOS balanced mode of the DevLab runners where cards are measured. Use --power 123w for a machine in BIOS
performance mode (the hwmon power1_input PPT sensor settles near 123 W instead of 85 W under load). Every compute
ceiling and prefill efficiency is "@ ": roofline.json records power_mode and flops_spec, a card's roofline
device records power_mode and spec_peak_flops. EFF/STRETCH prefill fractions are of the spec ceiling and are
rescaled to the mode (efficiency(compute=...)), so the prefill TARGET in tok/s is the same in every mode. Devices
without power_modes (R9700) use their flops as spec.
The efficiencies (EFF, STRETCH, LAYER_US) were all measured on Strix Halo. On another device, TARGET is an
out-of-sample estimate until a row in the loom-kb roofline topic (kb.py route --topic roofline) measures that device. On the R9700 in
particular: the fixed per-layer cost weighs about 3x more against a 3x faster weight stream, so expect a lower decode
efficiency for small models. The device also has 32 GB of VRAM, which the card's --memory_bytes must fit.
RDNA4 (gfx12) WMMA takes vector<8xf16> lhs/rhs fragments, where RDNA3 (gfx11) takes vector<16xf16>. The starter
kit's GEMM and flash-prefill kernels are written for gfx11, so hrx-loom 0.1.0 rejects them on gfx1201 (AMDGPU/023).
A port for the R9700 needs gfx12 variants of those kernels before any of these ceilings can be approached.
Realistic. TARGET comes from an efficiency some port has already reached here, so it is not a guess. Don't shade it down because the margin "looks too big". A large margin means llama.cpp is leaving the hardware idle.
Impressive. Report each metric as a margin over llama.cpp ROCm. Choose a headline set of 2–4 metrics that matter for the use case:
Lead with the metrics that have the most headroom. Drop at-ceiling metrics from the headline and set them to "≥ parity".
Achievable. Use the gap budget below to name the lever for each headline metric, and mark it tuning (existing kernels, retuned or fused) or new kernel (something the kit lacks: flash attention for head_dim ≠ 128, a new quant format, an MoE gather, GEMM pipelining). A new-kernel target is achievable when that kernel is built. Size it, schedule it, and don't lower the target to avoid it.
Stretch. Once a metric meets TARGET, keep going toward stretch while the stop
rules allow. Any result above TARGET raises EFF for every later port.
Don't ask the user to choose. Announce the targets in one short table (metric, llama.cpp, target, margin, stretch, lever, tuning/new kernel), then start working. The user can override them.
If the user did give a target, still run this. If their target is above the stretch ceiling, say so once with the numbers. If it is below TARGET, say how much more is available and aim for TARGET.
For a throughput metric, gap_ms = 1000/current − 1000/target per token. For
decode, the time at the roofline is 1000/ceiling; everything above it is overhead.
Attribute that overhead with a per-kernel profile (loom-optimize step 2: the
HAL's dispatch timestamps; doubling or skipping a kernel only as a cross-check). Typical buckets:
Feasibility rule. If the overhead you can plausibly remove, summed over the
ablated kernels with the levers you have, is smaller than gap_ms, the target is
not achievable this session. Lower it to what the identified levers give. Record
the new target and the reason in the log.
Optimization returns diminish, so the question is never "is there more to gain?" (there always is, up to the ceiling). The question is how fast this path is closing the gap, compared with the other paths available.
Order is enforced. perf.py exits with an error, naming the command to run, if
it can't find:
llamacpp_pick.json, for a llama.cpp run (so run pick_llamacpp.sh first);roofline.json, for a Loom run.Use --no-campaign only for ablation or ad-hoc builds. The final compare.py /
consistency.py print the audit's FAIL and WARN lines.
Tracking is automatic. Once bench/roofline.json exists, every Loom run of
perf.py (run from bench/) and c4_steady.py --label NAME does three things:
bench/targets.jsonl, with the time and the git commit;[campaign] … -> CONTINUE).Label every build (perf.py URL LABEL), and pass --reverted for a build you
discard: its time still counts. The budget and any user goals come from
roofline.json (set with --budget-h / --goal). To run the controller by hand:
$T "$R/progress.py" bench/roofline.json bench/targets.jsonl --metric decode_tps
It works in ms per token (gains add; percentages don't), as follows:
Act on the verdict: The horizon is what is left of the budget, minus the reserve.
--stall-min. Do the plateau review below before any further attempt.expected ms/h = (ms the lever can remove, from the ablation × the fraction plausibly removable) ÷ (estimated hours, including build, A/B and gates).
Draw the candidates from:
kb.py route prints for the model and device (loom-optimize);bench/decisions.jsonl
whose rejection reason no longer holds. For example, fusing the norm into the
matvec lost when the matvec was under-filled, and may win now that it isn't.
To fork, branch from that decision's commit (git worktree add ../fork-X <commit>),
then build it with its own --model-id and serve it next to the best build
(loom-kb topic optimize-loop, "Fast iteration"). Choose an
earlier commit when a later choice blocks the lever, for example a layout that
prevents a fusion.Record decision points in bench/decisions.jsonl, written as you go and not
reconstructed at the end, whenever you choose one
design over another:
{"ts", "commit", "decision", "chosen", "rejected": [{"option", "measured", "why"}]}.
The rejected options, with their measured numbers and the reason, are what makes a
fork cheap to evaluate later instead of re-deriving it.
Rules that override the rate:
compare.py + consistency.py. The time spent on gates counts toward the rate.The same ceilings go on every loom-fun model card: roofline.py's model_shape(), ceilings(),
drafted_ceiling() and efficiency() are what loom-benchmark's card/make_info.py roofline calls, so a card's
roofline column and this script never disagree. EFF_DRAFTED is EFF for speculative decoding (against
drafted_ceiling()); loom-fleet flags a card whose metric falls below half of either.
Run audit.py from bench/ before writing the report. It is the definition of
done; see loom-benchmark. It must print AUDIT PASS. Use its headline table
(llama.cpp, Loom, margin, % of ceiling, target, met) in the report.
targets.jsonl) and the stop or pivot decisions.EFF (or EFF_DRAFTED with drafting), update it in roofline.py
and add the row to the loom-kb roofline topic (kb.py route --topic roofline). Do the same for STRETCH if a
port beat it. This is how the targets get more ambitious over time.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
11 skills in this plugin
/loomEntry point for AMD Loom work (hrx-loom SDK, loom-serve, loom-fetch, Loom IR kernels) on AMD GPUs/NPUs such as Strix Halo — installing, serving catalog models, the demo web UI, porting a new LLM to Loom, optimizing it while preserving correctness, and benchmarking against llama.cpp. Use whenever the user mentions Loom, loom-serve, loom-fetch, hrx-loom, .loom files, or evaluating/porting models for Loom./loom-benchmarkCorrectness and performance methodology for Loom models vs llama.cpp ROCm — golden token-by-token comparison with log-prob near-tie analysis, a multi-turn tool-calling (agent) gate, a native-context admission check, batching consistency, decode/prefill/long-context/concurrency throughput on real-text workloads, and how to report results honestly (tables, executive artifact). Use for "benchmark", "compare with llama.cpp", "is the port correct", "performance report"./loom-demo-uiStart and use the Loom Playground web UI (chat with streaming reasoning and tok/s, ASR with mic recording, TTS, image generation, embedding similarity) that proxies to one or more running loom-serve instances and discovers their models automatically. Use when the user wants a browser demo/UI for Loom models./loom-fleetRuns loom-skills fleet work - a targeted fix to one model, family, GPU or quant (scoped change, sampled DevLab A/B, promotion), a campaign (new GPU, many models, a refactor, regenerating cards), populating or extending a Hugging Face org with new models (pick the top models, port and publish each, sweep gates on DevLab), publishing, staging and promoting regenerated cards, and improving the loom skills themselves against the KPIs with fresh-agent trials. Use for "improve the loom skill", "make the loom skill faster or more reliable", "targeted fix", "campaign", "populate the org", "polish the HF org", "which models still need cards", "regenerate cards", "publish to staging", "fresh-agent trial", or any change to the skills in this repo./loom-kbRouter for the Loom knowledge base - which facts to read for a given model, GPU and task. Run `kb.py route` with a model slug or config, GGUF or arch name plus device and topic, then read exactly the files it prints (device, quant, arch family, facets, topic). Use before porting, optimizing, benchmarking or rooflining any model, when asking "what is special about gemma4 / qwen35moe / flint", "which tricks apply to this model on the R9700", or when adding a model family, facet, device or scope rule to the knowledge base./loom-migrateMigrates the loom-skills kit, fleet of model cards and skills to a new hrx-loom SDK release - research the release, apply the version entry's mechanical steps (IR renames, program ABI, card schema, install/pin), prove the fleet parses and links under the new SDK, A/B the old cards against the new packages on DevLab, publish qualifying cards directly and stage regressions, and record simplifications and optimization opportunities. Holds one entry per adjacent SDK pair (v0.1.0 to v0.2.0 first) and sweep and rewrite scripts. Use for "new Loom SDK", "migrate to hrx-loom X", "SDK upgrade", "port the fleet to a new SDK", "my package fails to parse or load on the new SDK", or "what changed between hrx-loom versions".npx claudepluginhub loom-fun/loom-skills --plugin loomOther plugins' skills for the same job