Skip to content

[w2] rocm-runtime-knobs: ROCm knob inventory, A/B script and launch-gap microbench (prep) - #168

Merged
rafasmour merged 1 commit into
masterfrom
opt/w2-rocm-runtime-knobs
Dec 4, 2026
Merged

rafasmour merged 1 commit into
masterfrom
opt/w2-rocm-runtime-knobs

Conversation

@rafasmour

Copy link
Copy Markdown
Owner

What

Prep task, no llama.cpp code: scripts only under tools/rdna3-w2/rocm-runtime-knobs/.

  • knobs.txt: the HIP/HSA runtime knob names that really exist in the build image (rdna3-build:local, ROCm 7.16.26385 / core-10.1), from strings libamdhip64.so libhsa-runtime64.so. All 14 knobs of the plan exist; DEBUG_CLR_GRAPH_PACKET_CAPTURE does not.
  • ab.sh + ab-stats.py: interleaved whole-card tg128 A/B (base - knob - base ...) of 24 knob variants (+3 extras found in the library: DEBUG_CLR_AQL_DEV_QUEUE, AMD_DIRECT_DISPATCH, DEBUG_HIP_GRAPH_CLASSIC_PATH). Screen on Nemotron, confirm the survivors on Nemotron/Gemma/Qwen3.8/Qwen4, combine the winners, then check the greedy text hash on Nemotron-DFlash (specbench.py --modes greedy). Each run has timeout 600, a hung run's container is removed, two failed baselines abort.
  • launchgap/: HIP microbenchmark (compiled with hipcc for gfx1100, not run). N dependent kernels in a stream and in a captured hipGraph, three flavours (tiny, full-GPU, 512 B kernel argument); prints host enqueue us/launch, total us/launch and the GPU-side idle between kernels measured with wall_clock64(). sweep.sh runs it for the baseline and every knob.
  • README with run order, runtime (~1 h whole card) and decision rule.

Two deviations from the plan (details in the README)

  1. GPURUN_OPTS='-e HIP_FORCE_DEV_KERNARG=0' does not override the hardcoded =1: gpurun.sh places ${GPURUN_OPTS} before its own -e HIP_FORCE_DEV_KERNARG=1, docker keeps the last one. ab.sh and launchgap/sweep.sh call gpurun.sh -e K=V (applied after) and build the same llama-bench command as lb.sh (which cannot pass -e).
  2. All knobs x all models would be ~3 h, so the screen runs on Nemotron only and only survivors go to the other models (CONFIRM_ALL=1 for the full matrix). BLOCK_TIMEOUT=9000 is needed (gpublock default is 2400 s).

Expected gain (estimate)

Unknown, at most a share of ~2 us per dependent launch (about 1.4 ms/token on Gemma with ~700 launches); realistic 0-3% tg, possibly 0.

Env switch

The knobs themselves (runtime env, via gpurun.sh -e). Nothing changes in production, prodimg/Dockerfile, router-config.ini or any llama-cpp-rocm:* image. A winning knob goes into production only with the user's approval.

Files

tools/rdna3-w2/rocm-runtime-knobs/{README,ab.sh,ab-stats.py,knobs.txt,launchgap/{launchgap.hip,build.sh,sweep.sh}} (the working copies run from build-bins/w2/rocm-runtime-knobs/ and build-bins/tools/launchgap/).

Risks

DEBUG_CLR_* are debug flags and may hang or corrupt: hence the timeout, container removal and the greedy hash gate. Extra knob values are guesses (semantics unknown from strings).

Checked on CPU (no GPU used)

  • knobs.txt generated in a device-less container; bash -n ab.sh; launchgap.hip compiles with hipcc -O2 --offload-arch=gfx1100 -Wall -Wextra, no warnings (not executed).
  • ab.sh control flow self-tested with a fake gpurun.sh/specbench.py (screen, confirm, combo, hash, failed run, knob absent from knobs.txt) and DRYRUN=1.

GPU validation tonight (NOT YET RUN)

R=/home/tom/docker/projects/llama.cpp-RDNA3; K=$R/build-bins/kern; cd $K; B0=$R/build-bins/w2/base-build/bin
BLOCK_TIMEOUT=1800 ./gpublock.sh bash $R/build-bins/tools/launchgap/sweep.sh      # ~10 min, per-launch idle per knob
./gpusmall.sh $K/gpurun.sh -n kern-launchgap $R/build-bins/tools/launchgap/launchgap 2000
./gpusmall.sh $K/gpurun.sh -n kern-launchgap -e KNOB=V $R/build-bins/tools/launchgap/launchgap 2000
BLOCK_TIMEOUT=9000 ./gpublock.sh bash $R/build-bins/w2/rocm-runtime-knobs/ab.sh $B0   # ~1 h whole card

Decision rule: > 1% tg beyond run-to-run spread, no model loses, identical greedy hash.

Hard rules followed

No GPU access, no GPU lock, no /dev/kfd//dev/dri; no production, docker compose or llama-cpp-rocm:* images; nothing touched in ggml-org/llama.cpp; PR not merged.

Assisted-by: Claude Sonnet 5.5

…gap microbench (prep, scripts only)

Inventory of the runtime knobs that exist in the build image's libamdhip64/libhsa-runtime64, an interleaved tg128 A/B script
(ab.sh + ab-stats.py: screen on Nemotron, confirm on four models, combination, greedy-hash check) and a HIP launch-gap microbenchmark
(stream vs hipGraph, GPU-side idle measured with wall_clock64). No llama.cpp code. Nothing was run on the GPU.

Assisted-by: Claude Sonnet 5.5
@rafasmour
rafasmour merged commit f6b8c10 into master Dec 4, 2026
6 of 7 checks passed
@rafasmour

Copy link
Copy Markdown
Owner Author

Reverted from master on 2026-12-04 (w2 build crashed Qwen4-single at >20k ctx; no measured gain). Commit preserved on branch archive/w2-25f0def; will be re-landed individually after GPU validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant