Skip to content

Shaders: skip cross-half exchange in active_f64_sum for local waves and groups <= 32 - #461

Open
Fimpos wants to merge 1 commit into
fxceless:mainfrom
Fimpos:fix/active-f64-sum-wave32
Open

Fimpos wants to merge 1 commit into
fxceless:mainfrom
Fimpos:fix/active-f64-sum-wave32

Conversation

@Fimpos

@Fimpos Fimpos commented Nov 25, 2026

Copy link
Copy Markdown

Problem

Lower::active_f64_sum (added in 3bff182 for v_add_f64 whole-wave sums) checked if self.exchange.is_some() directly instead of matching wave_reduction's guard right above it (if !self.local && self.exchange.as_ref().is_some_and(|e| !e.1)).

On 32-lane hosts (NVIDIA), that had two consequences for wave64 compute shaders containing Shape::ActiveF64:

  1. Under with_local_waves / with_local_waves_any (self.local == true), divergent f64 sums still returned Err("a wave reduction where not every lane runs") instead of taking the host wave's own sum, causing shaders such as 5dc3b25986622949 and 6f225b641c5b0708 to fail the local-wave retry (together with Shaders: lower scc_some directly and per host wave under with_local_waves_any #190 / LOCAL_ANY they now lower at WaveSize(32) and pass CreateComputePipelineState instead of falling back to WaveSize(64) -> E_INVALIDARG).
  2. For a wave64 shader with group <= 32 (e.1 == true), one host wave already holds the whole group, so no cross-half exchange should be emitted.

Change

  • crates/victory-shader/src/emit/lower.rs: guard the cross-half exchange in Lower::active_f64_sum with if !self.local && self.exchange.as_ref().is_some_and(|e| !e.1), matching Lower::wave_reduction.
  • crates/victory-shader/src/emit/wave64_tests.rs: add wave64_f64_sum_on_wave32_host_respects_small_groups_and_local_waves, covering both the 64-thread divergent with_local_waves_any path and a 32-thread wave64 group executed on the host GPU.

Verification

  • cargo xtask policy: ok (169 files)
  • cargo clippy -p victory-shader --tests -- -D warnings: clean
  • cargo test -p victory-shader --lib wave64_f64_sum_on_wave32_host_respects_small_groups_and_local_waves: passed on Windows 11 + NVIDIA RTX 5070 (dxil.dll validation + hardware GPU dispatch)
  • Verified with VICTORY_HOST_MAX_WAVE=32 that 5dc3b25986622949 and 6f225b641c5b0708 get past the 0x7e8/0x7f8 a wave reduction where not every lane runs stop (and together with the scc_some / LOCAL_ANY wave32 fixes, both validate with dxil.dll and create D3D12 pipelines on RTX 5070).

Related: #394

(AI-assisted fix & test; built and verified on real RTX 5070 hardware.)

@Yorivel

Yorivel commented Nov 25, 2026

Copy link
Copy Markdown

Tested together with #190 and #156 on an RTX 4090 (32-lane, driver 621.40), on a803c87:

Of the seven wave64 refusals of this scene, four remain: 2da4beb386509b77, 2cc4c197ee29e291, 02384a60fda6f2d0, 6b82bc7d22016cb5. A fifth, 369cbe906ea72764, is handled in #500.

@HAL9000RELOADED

Copy link
Copy Markdown

RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main d510ee4: the new test wave64_f64_sum_on_wave32_host_respects_small_groups_and_local_waves passes on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (#129 (comment)).

@Dathinel

Copy link
Copy Markdown
Contributor

Independent synthetic readback on an RTX 3050 Laptop (Windows D3D12). I applied the active_f64_sum guard to our local Series S branch and adapted the PR fixture to require DXIL validation, successful PSO creation, and actual dispatch. Before the guard, lowering stopped at offset 220 with “a wave reduction where not every lane runs”. Afterward both variants validated and created pipelines. In the 32-thread variant, 1, 4, 16, 31 and 32 active lanes each contributing 1.25 produced exactly 1.25, 5, 20, 38.75 and 40. The 64-thread local variant was checked through pipeline creation only. On this PC WARP reports a maximum wave size of 4 and refuses the required WaveSize(32) PSO. No water rendering or performance comparison in this test. AI-assisted.

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.

4 participants