Repository navigation
[w2] Prep: ROCm CLR agent-scope fence patch for HIP graph replay (env-gated), Dockerfile, build script - #175
Merged
Merged
Conversation
…, Dockerfile and build script Prep only: patch against ROCm/rocm-systems@7da43026 (projects/clr, the CLR of ROCm 10.1.0), Dockerfile.clr-patched, build-clr.sh and README with the correctness argument, failure modes and test plan. Nothing is built or deployed. Assisted-by: Claude Sonnet 5.5
Assisted-by: Claude Sonnet 5.5
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. |
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.
What / why
Prep only (no GPU used, nothing built or deployed, no production image touched): an env-gated patch for the HIP runtime (CLR) so interior kernel packets of a HIP graph replay can use agent-scope (or, measurement-only, no) acquire/release fences, plus a Dockerfile and build script for a throwaway image
rdna3-clr-fence:local. It tests whether cache maintenance is part of the ~2 us per-dependent-launch idle (TheRock#9241).Pinned runtime (read from
rdna3-build:local): ROCm 10.1.0 (TheRock b324869f, 10.1.0rc3), HIP 7.16.26385, CLR =projects/clrof ROCm/rocm-systems @ 7da43026e4f2ef7600433c38c820732f7a205d22 (no tag exists for that pin; fetched by SHA).Important finding (premise check)
In that CLR,
AMD_OPT_FLUSHdefaults to 1, which already gives agent-scope acquire+release on kernel dispatch packet headers for non-gfx12 (gfx1100 included). Graph replay uses headers captured at instantiate time and replays them throughVirtualGPU::dispatchAqlPacketBatchFlat; graph barrier packets use scope NONE. SoHIP_GRAPH_AGENT_FENCE=1is expected to be close to a no-op. Not verified on the binary (needs a GPU). Cheaper first test with the stock runtime:AMD_OPT_FLUSH=0(system scope everywhere) versus default; commands in the README. If there is no difference the task can be dropped without building anything.Patch (tools/rdna3-w2/rocm-clr-fence-patch/clr-agent-scope-fence.patch)
rocclr/utils/flags.hpp: new flagHIP_GRAPH_AGENT_FENCE(default 0).rocclr/device/rocm/rocvirtual.cppdispatchAqlPacketBatchFlat: when set, interior kernel packets get agent fences (1) or none (2, UNSAFE, ceiling measurement only); first packet keeps system acquire, last packet system release; barrier bit untouched; unset = stock.hip_graph*.cpp; that function is the single replay choke point and batches are already split at uncaptured nodes (memcpy, host node, child graph).Env switch
HIP_GRAPH_AGENT_FENCE=1(patched runtime only; 2 = unsafe ceiling). Default off. No change to the llama.cpp sources.Checks done (CPU)
git apply --checkagainst a fresh sparse checkout of the pin: OK.g++ -fsyntax-onlyofrocvirtual.cppinrdna3-build:local(stub X11/GL/EGL headers): rc=0, no new warnings. Full CLR build NOT run (not in this wave).docker build --checkon the Dockerfile: no warnings;bash -n build-clr.sh: OK.Risks
Memory-ordering bugs give silent wrong results; validate with full test2 and KLD (must be exactly 0) before any use. Dockerfile apt list and cmake flags are untested for the full build. Never tag the image
llama-cpp-rocm:*(script refuses). No ggml-org interaction.GPU validation tonight (NOT YET RUN)
Stock runtime first (no image needed):
Only if the user builds the image first (
bash build-bins/w2/rocm-clr-fence-patch/build-clr.sh, CPU, long):Idle: tr.sh with GPURUN_IMAGE set, compared with B0. Abandon if idle drops by less than 30%.
Expected gain (estimate, unproven): at most ~1-2 ms/token on Gemma, ~0.5 ms on Nemotron if fence scope is the cause; given the finding above, likely zero.