Skip to content

startup: keep the wave size in the in-memory compute request - #3519

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:runtime-frozen-request-wave-size
Nov 30, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:runtime-frozen-request-wave-size

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Refs #3224 (part 1 of our claim there).

Draft, held under our open-PR cap (#3514).

Why

The in-memory compute request copy (FrozenComputeRequests::put, called from src/startup_stubs/d3d12_draw.inl:879) did not set ComputeRequest::wave32, so the field kept its default of true. The disk reader read_compute_request derives it from state block A, dword 4 bit 20 (sa[18] & 0x10; set = wave32, clear = wave64).

Wave64 programs taken from the in-memory copy were therefore analysed as wave32 and refused natively with "unbound numeric SGPR" on the high half of a 64-bit compare pair.

In one long local run of the application, most compute dispatches left without a translation came from such programs. No counts were recorded.

What

  • src/shader_compute_request.cpp:335: new compute_request_wave32(state_a) (declared at src/shader_compute_request.h:59). Same expression as before. It returns true when the block is not 28 bytes; shape validation rejects that case.
  • src/shader_compute_request.cpp:322: read_compute_request calls the helper after validate_compute_request_shape. Behaviour unchanged.
  • src/frozen_compute_requests.h:38: put derives wave32 from request.sa before taking the lock. Its only caller builds the request without wave32, so nothing is overwritten.

wave32 was the only ComputeRequest field the in-memory copy omitted:

Field In-memory copy Disk reader
code, data, root, description, sa, sb copied read from the capture parts
key hashed at publication marker stem checked against the content hash
wave32 default true (before this change) derived from state block A

Tests

native_frozen_request now puts one request with bit 20 clear and one with it set through the production put/take path, and asserts wave32 on each after take.

Mutations, each run against native_frozen_request:

Mutation Result
put path sets request.wave32 = true fails: "wave64 state was lost in the frozen request"
decode bit test inverted (== 0) fails: same message

Regression run, dev preset with X2W_WITH_OPUS=OFF:

  • ctest -R '^native_frozen_request$': passed.
  • ctest -R '^(startup_compute_|native_compute_)' -j 4: 212 tests, 198 passed, 11 skipped, 3 failed.

The 3 failures also occur with the base sources (ff9dcef) rebuilt in the same tree:

  • startup_compute_builder_gate_runtime (builder mode exit 3)
  • startup_compute_dispatch_cube_warp ("debug layer not enabled")
  • startup_compute_dispatch_cube_hardware ("debug layer not enabled")

Not covered

No long-run re-measurement of the application with this change yet.

@Leyukaka
Leyukaka marked this pull request as ready for review November 29, 2026 22:31

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed babe3170 by reading the diff; not built or run. I also checked one of our existing native-only runs against it.

Verdict: approve. put now derives wave32 with the same expression as the disk reader, and ComputeRequest::wave32 was the only field the in-memory copy left at its default. No MUST.

Our run backs the claim. Native-only run446: main 44a3ad5a + #3506 #3516 #3464 #3521 #3097 #3527 + local profiling counters; 190 s fresh start; Windows 10 19045. It logged compute request snapshots: hits 58, so the frozen path was used. It refused 16 slot-67 keys natively, and 12 of them as unbound numeric SGPR sN (11 on an odd SGPR, the high half of a pair). For all 12, state block A has bit 20 of dword 4 clear (wave64). Several have 32 threads (8×4), which is the narrow-wave64 case. I did not rerun with this change.

  • NIT Say in the body that the result depended on the path: the same key got wave64 analysis on a frozen-pool miss (disk reader) and wave32 on a hit. That explains why a key could translate in one run and refuse in the next.
  • Checked, no finding:
    • Old wrong-wave live translations leave nothing stale behind. Only the runtime used the frozen copy, and it publishes no .csir or manifest. Offline compile_dxil and pack entries went through the disk reader. The DXC bytecode cache is keyed by the new IR.
    • compute_request_wave32 returns true for a non-28-byte block, but every caller validates the shape (take path at d3d12_compute_dispatch.inl:495, the disk reader before the call).
    • The container path takes the wave size from the stage record, not from this field.

Tests: native_frozen_request now puts a wave64 and a wave32 request through the real put/take path and checks each, and the two mutations show both are reached. CI did not run it (not in the Windows pr filter), although it needs no GPU. The only result is the author's local run.

@R0Y00
R0Y00 merged commit 7a2c2e2 into R0Y00:main Nov 30, 2026
5 checks passed
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.

3 participants