Repository navigation
hrx: sleep through long stream waits instead of spinning a CPU core - #44
Merged
bong-water-water-bong merged 1 commit intoSep 29, 2026
Merged
Conversation
The per-token wait (hrx_stream_wait -> ROCr hsa_signal_wait_scacquire on the
stream timeline) never sleeps: the timeline advances with every completed
command (~900 per 27B decode token) and each advance returns the KFD event
ioctl at once. The waiting thread ran a full core the whole token (35% user
+ 65% system, 30 context switches in 6 s), adding ~10 W to the APU package
and the difference between ~74 C and 90-93 C during 27B decode on Strix Halo.
runtime/hrx-sleeping-wait.{h,cpp} (our file): when a wait is expected to be
long (the shortest of the last four waits at the call site is over 20 ms),
sleep through 80% of it, then finish with the normal hrx_stream_wait. Shorter
waits are unchanged: sleeping through 3-10 ms tokens cost small models 2-5%
(host work between tokens then runs on a clocked-down core). Hooked into the
graph-replay wait and backend synchronize. ONEBIT_HRX_BLOCKING_WAIT=1 turns
it off.
Qwen3.8-27B UD-Q4_K_XL, HRX0 tg384, A/B interleaved: waiting thread 600 ->
~120 ticks per 6 s; package 133-137 -> 124-129 W; Tctl during decode 83-89
-> 71-74 C (peaks 85-91 -> 74-76); decode 12.11-12.12 -> 12.06-12.07 tok/s
(-0.4%). Qwen3-0.6B (323.7-324.7 vs 323.5-323.9) and ZAYA1-8B (95.0-95.3 vs
94.9-95.2) unchanged. ZAYA prefill wikitext PPL 41.9971 (unchanged).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
merged commit Sep 29, 2026
6617e78
into
1bit/hrx-vulkan-patched
10 of 24 checks passed
This was referenced Sep 29, 2026
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.
This fixes a CPU core that stayed busy for the whole of every decode token on HRX, heating the APU.
Cause: the per-token wait is
hrx_stream_wait, which goes to ROCr'shsa_signal_wait_scacquireon the stream timeline, and it never sleeps.On Strix Halo that costs about 10 W of package power. It is the difference between 74 °C and 90–93 °C during 27B decode; runs were hitting our 93 °C bench guard, and the box has already power-cycled once on a thermal trip.
Fix (
runtime/hrx-sleeping-wait.{h,cpp}, our file):hrx_stream_wait. "Long" means the shortest of the last four waits at that call site is over 20 ms.ONEBIT_HRX_BLOCKING_WAIT=1turns it off.Results, A/B interleaved on HRX0 (Strix Halo, gfx1151):
ZAYA prefill wikitext PPL is unchanged at 41.9971.
🤖 Generated with Claude Code