Repository navigation
RR Preset F: enable bit-exact OFX_FUSE+OF_UNIF on output.* and OFX_FUSE+OFX_NOCHK on Fast mode output.*.f - #302
Open
phantoslayer21 wants to merge 11 commits into
Open
phantoslayer21 wants to merge 11 commits into
phantoslayer21 wants to merge 11 commits into
Conversation
…SE+OFX_NOCHK on Fast mode output.*.f
…k loop and unroll / prefetch defaults (-21 us body, byte-identical) The relaxed body (modes accurate and fast) already runs E1 / D1-F / D1-R with RR_L1R2 (L01_MRGU 4, L01_UNRALL 28, L01_FPF 8, L01_UNR2MASK 28). The exact step-E body (RR_Z 2, RR_STEP 0) now takes the same loop-shape and issue-order defaults. They are structural: the same operations in the same order, so the output bits cannot change. L01_MDPF is a no-op there (relaxed body only); the step X / Z / XF kernels keep their DXIL. Windows AMD DX12 (RX 9070 XT, rr_test_host perf 1440p Quality 1706x960 -> 2560x1440, 250 frames, windows from frame 51, 6 interleaved ABBA rounds, medians): exact total 11149 -> 11130 us (body 7526 -> 7505 us); fast and accurate unchanged (6825 / 7463 us, the kernels are the same). Outputs and the arena dumps' outputs are byte-identical to v0.6.5 and to the previous state in all three modes (synthetic scenarios A and B at 48x30 and 1280x720, wild and non-finite inputs).
…3 VGPRs), fused store for plain mode, no redundant arena write of the fused main output - resolve.fast3 / resolve.fast3.x: RF_SPEC 3 = the plain configuration (flags & 15 == 0, binary16 x4 output): no render-size reads, no render tile, no format switches; same bits as resolve.fast / resolve.fast.x (resolve.fixup keeps the slow pixels). 162 / 191 -> 43 / 55 VGPRs. - rr_runtime: plain frames dispatch resolve.fast3 and fuse rt.store into the resolve like RF_SPEC 2 (WG_RR_RES3=0: the old route). - with the store fused (RF_SPEC 2 and 3) the fast resolve skips the main output's arena write (parameter word 16 = 2); WG_RR_ALIAS=0 test runs keep it (word 16 = 1); WG_RR_RESARENA=1 brings it back.
…hole-record stores, body LDS overlay for the relaxed body, output.fast.f OFX_PH1W / OFX_LD3 / OFX_QST), each behind an A/B mask R4.1a head.fast.rx: RR_HQ8S 1 quantises step 1's q / v^T tiles per head (RR_Q8 decides its wave-uniform clamp test per group and both paths give Q8's bits for every value; 99 -> 95 VGPRs, 0 spills) and RR_HSTM 1 writes each record whole from the hf0 lane (b128 / b64 / b32 stores of the same values at the same addresses). The other head kernels' DXIL is unchanged. R4.2b body: the exact body's LDS overlays (MY in head 0's exchange buffer, UP in head 1's) now also for the relaxed body (RR_OVL, rr_block_fast.hlsl E1 / D1-F and rr_block_c32.hlsl D0-F incl. its wave64 form): LDS 12288 / 12288 / 10240 -> 8192 B. R4.2c: stagee.D4-F / D4-R declare 26624 B (rr_l[3328] u64) in the DXIL; RGA's 65536 is the driver's allocation of the 192-VGPR-capped kernel, nothing to overlay. R4.3 output.fast.f: OFX_PH1W (PH1 pool inside each wave64, no groupshared copy / barrier), OFX_LD3 (b64 / b32 motion loads), OFX_QST (12-byte Q store) on the fast kernel alone (output.prep.f / output.fallback.f untouched; OFX_NOCHK kept: the fallback still serves !fits / insane / pflags quads). Runtime: WG_RR_W4 (hex, default 7; bit 0 head, bit 1 body, bit 2 output) selects the fc16c9d kernels head.fast.rx0, stagee0.{E1,D1-F,D0-F}, output.fast.f0 (byte-identical DXIL to the previous kernels).
… and output levers stay as opt-in A/B bits Paired ABBA timing at 1440p Quality (1706x960 -> 2560x1440, fast, 1500 frames, 8 rounds, same-process-order alternated): bit 1 (body RR_OVL) -78 us layer / -83 us plain (body -98 / -100 us); bit 0 (head.fast.rx 95 VGPRs) +2 us, no gain; bit 2 (output.fast.f OFX_PH1W/LD3/QST) +12 us layer / +10 us plain (output stage +10 us). Mask 7 gave only -62 / -70 us. Outputs and arenas are byte-identical to fc16c9d for every mask checked (fast / accurate / exact, small and mid, alias on / off).
… D1-F, E1), design D, each behind an A/B mask
head.fast.rx.w64 (head/dx12/rr_d0r_w64.hlsl) and stagee.{D1-R, D1-F, E1}.w64 (kernels/rr_block_c64_w64.hlsl) run one window
as two wave64 waves, each holding two token tiles of the window, so every weight / bias / key-value fragment is loaded once
for both tiles (as stagee.IN0 / D0-F). Every value is computed by the operation of the wave32 kernel; the head's row sum Z
keeps wave32's sequential dot2add chain (the other half's words come from lane ^ 32) and its tail runs per 32-lane half.
RGA gfx1201: head 95 -> 91 VGPRs, D1-R 143 -> 120, D1-F 127 -> 120, E1 144 -> 120; LDS 8192 B, no spills, no scratch.
Runtime: WG_RR_W4B (hex, default 0xf; bit 0 head, 1 D1-R, 2 D1-F, 3 E1), 0 = the wave-4 frame. Bit 0 does not depend on
WG_RR_W4 bit 0 (WG_RR_W4 stays at its default 2); bits 1-3 need WG_RR_W4 bit 1, the body lever.
Paired ABBA at 1440p Q (1706x960 -> 2560x1440, fast, 1500 warmed frames, 8 rounds, vs WG_RR_W4=2 WG_RR_W4B=0), total us
layer / plain: 0xf -178 / -175, bit 0 -71 / -71, bit 1 -45 / -44, bit 2 -42 / -39, bit 3 -25 / -23 (the bits add up).
Byte checks (fast / accurate / exact, small and mid, plain / layer / opacity / alpha, alias on and off): 0 output diffs.
…ed Q8 + weight prefetch, output.fast.f_ph1w), WG_RR_W4C defaults to 0x19
stagee.{E2, D2-F, D2-R, E3, D3-F, D3-R, D4-F, D4-R}.w64 (kernels/rr_block_wide_w64.hlsl, design D: one wave64 = the two token
tiles of two wave32 waves, shared weight / bias / key-value fragments), stagee.IN0.w4c (RR_DEFER, Dd / Wo prefetch, interleaved
front-end MLP + act2_4) and stagee.D0-F.w4c (prefetch) from rr_block_c32.hlsl's wave64 path, output.fast.f_ph1w (OFX_PH1W alone).
Same operations per value as the wave32 kernels; the 161 earlier kernels keep their DXIL (kernels.json sha256 identical).
WG_RR_W4C bits 0-5, default 0x19 (bits 0, 3, 4: level-2 wide stages, IN0.w4c, D0-F.w4c). Bits 1, 2, 5 stay as opt-in A/B bits.
Paired ABBA at 1440p Q (1706x960 -> 2560x1440, fast, 1500 warmed frames, 8 rounds), total us vs WG_RR_W4C=0, layer / plain:
bit 0 -20 / -20, bit 1 +23 / +24, bit 2 +6 / -1, bit 3 -6 / -8, bit 4 -1 / -2, bit 5 +8 / +9, all six +7 / +1;
0x09 -28 / -27, 0x19 -29 / -29 (8 of 8 rounds each). The kernels of the opt-in bits are byte-identical in output but not faster
(level 3 body +26 us, output ph1w +5 us in its own stage).
Scaling, PR #302 vs this commit (fast, 4 rounds, all rounds win), total us layer / plain: 1080p Q -13 / -11, 1440p Perf -11 / -12,
1440p Q -31 / -31, 1440p DLAA -67 / -66, 4K Q -64 / -67 (the body stage moves, input / head / output / resolve do not).
Byte checks (fast / accurate / exact, small and mid, alias on and off, W4C default / 0 vs PR #302): 0 .out and 0 .aout diffs
(the .arena of mid frames 0-2 varies run to run on the PR #302 build too).
…l, branchless Q8, packed FP16 body, WG_RR_W5=0x1f)
Fast mode only (VG_OUT alternatives); exact and accurate modes compile and
dispatch the exact same 172 wave-4c kernels unchanged (WG_RR_W5 effective
mask is 0 outside MODE_FAST).
- head.fast.rx.f.w64 (RR_HFAST_ALU=1): replaces 13 random LUT gathers with
bounded FP32 ALU transcendentals (deriving head.k_s2 from head.rho when
missing in older packed models), removes slow-path Q8 / wave votes, skips
dead CANDW store & atomic when scratch is present, keeps Cnet history exact.
RGA gfx1201: inst 4302->3126 (-27.3%), vmem 114->101, 0 spills.
- stagef.{IN0,D0-F,E1,D1-F,D1-R,E2,D2-F,D2-R}.w64 (RR_Q8_FAST=1 + L01_B16R,
plus RR_FOLD_B32=1 on IN0): branchless clamped Q8 + packed half2 body
elementwise/attention, keeping matrix chains in FP32.
RGA gfx1201: inst -39% to -67% across all 8 stages, VGPR -2 to -53 (E2
180->127, D2-R 173->124), 0 spills across all 9 wave-5 kernels.
- WG_RR_W5 creation env mask (hex, default 0x1f; 0 = wave-4c frame for A/B).
…dy speedup (WG_RR_W5=0x7f) Fast mode only (all 13 kernels in VG_OUT alternatives); exact and accurate modes keep 172/172 wave-4c kernels 100% bit-identical (0 removed, 0 changed; w5_effective() returns 0 outside MODE_FAST). Root-cause fixes for wave-5 (b416f30) body bugs/regressions: - Removed broken L01_B16R packed-f16 body path from rr_block_{c32,c64_w64, wide_w64}.hlsl, rr_fast.hlsli, and gpu/stage.py (caused 4-12% FP8 RMS error and +47/+66 us regressions via RTZ FP16 + disabled RR_B32/RR_WIL). - Fixed wave-5 E2.merged non-finite bug (~10% entries) in rr_block_wide_w64.hlsl and rr_block_c64_w64.hlsl: under RR_Q8_FAST=1 (no Q8 wave vote), LLVM hoisted if (cin) (s_and_saveexec_b64) above cross-lane merge v_wmma instructions (NAR=48). Added convergent WaveActiveAnyTrue anti-sink guard before if (cin), reducing narrow-EXEC WMMAs to NAR=0 on all stagef.* kernels. Wave-5b fast-only levers (WG_RR_W5 hex mask, default 0x7f; 0 = wave-4c frame): - Bit 0 (0x01) head.fast.rx.f.w64 (RR_HFAST_ALU=2): per-head Q8 + native f16 + single-mul rr_od255 on top of verified wave-5 ALU head (VGPR 91->84, INST 4302->3121 [-27.5%], VMEM 115->101, 0 spills, NAR=0; exact Cnet history). - Bit 1 (0x02) output.fast.w5 (OFX_W5_ALU=1 on output.fast.f0 base): native f16, FMA bilinear, 16-tap half exp2, 3-cmp max for OF_REPROJ_MAX=1, folded Cf/Df, simplified of_code10 (0 ULP), skips output.fallback.f + UAV barrier when CPU tile-fit check holds (VGPR 79->74, INST 2155->1640 [-23.9%], 0 spills). - Bit 2 (0x04) resolve.fast2.w5 / resolve.fast3.w5 (RFX_W5_ALU=1): f32 1-Newton uniforms (0 FP64), uint2 half4 taps, branchless bilinear, FP16 3x3 layer clamp before U.E (bit-exact), direct rf_gout store, skips resolve.fixup when RF_SPEC 2/3 & tile-fit preconditions hold (fast2: VGPR 80->70, INST 4635->2562 [-44.7%], VMEM 91->68; fast3: VGPR 43->43, INST 2477->1324 [-46.5%], VMEM 62->43). - Bit 3 (0x08) input.features.w5 (RR_IN_W5_ALU=1, wave64): eliminates all 5120 B LDS (5120->0 B, DS 28->10), vectorized tx4/tx3/tx2 fetches, RR_IN_DLANE=1, RR_IN_MDD=1, folded history decode & FMA bmix (VGPR 59, SGPR 73->51, INST 3763->3307 [-12.1%], 0 spills). - Bits 4..6 (0x10 L2, 0x20 L0, 0x40 L1) stagef.{E2,D2-F,D2-R,IN0,D0-F,E1,D1-F, D1-R}.w64: pure f32 RR_B32=1 + branchless clamped RR_Q8_FAST=1 (0% RMS error for finite values in [-448, +448], INST -47% to -71%, E2/D2 VGPR 180/169/173 -> 136/139/136, IN0 VGPR 92->88, 0 spills, NAR=0 across all 8 stages).
…put, SRV-only input)
Adds 6 independent Fast-mode-only Wave 5c levers behind WG_RR_W5 (default 0xfff,
bits 0..11; VG_OUT alternatives only so Exact, Accurate, and WG_RR_W5=0 remain
100% unchanged and all 172 Wave 4c DXILs stay SHA-256 bit-identical):
- Bit 3 (0x008) input.features.w5c: drops Wave 5b input.features.w5 (which had an
in_nan0(float3) truncation bug and regressed latency) and restores rr_in_math.hlsli
and rr_input.hlsl cleanly, replacing bit 3 with wave64 input.features.lite +
RR_IN_SRV_ONLY=1 (CPU-guarded direct SRV reads, bit-identical to input.features.lite,
57 VGPR, 5120 B LDS, -17.4% INST, -65.1% VLD, -41.4% IMG).
- Bit 7 (0x080) Body L3 stagef.{E3, D3-F, D3-R} & Bit 8 (0x100) Body L4/L5
stagef.{E4, E5, D4-F, D4-R}: pure-f32 RR_B32=1 + branchless clamped RR_Q8_FAST=1
wave32 kernels with convergent merge guard in rr_block_wide.hlsl (NAR=0), plus
RR_B32G4=1 / RR_PRE=14 at L4/L5 eliminating all scratch/LDS spills (D4-F/D4-R
LDS 65536->26624 B, SCR 160/112->0 B, VGPR 192->153..160, INST -50%..-60%).
- Bit 9 (0x200) pool.main.w5: hardware f32 mad/mul with exact tables (0 FP64,
0 CVT, -69.3% INST, bit-identical to quarter_pool).
- Bit 10 (0x400) resolve.fast2.w5c / resolve.fast3.w5c: RF_QN=28 / RF_QO=896 with
wave-uniform s1==3 skip; fast2 adds CPU-guarded RFX_RP=16 (RF_RS=1, 12.8 KB LDS
-> 5 WGs/CU), RFX_LLDS=1 (layer bilinear taps from LDS, -33.8% VLD), RFX_QLD=1,
32-bit MV load, and rolled 3x3 clamp (67 VGPR).
- Bit 11 (0x800) output.fast.w5c: OFX_W5_ALU=1 + OFX_W5C=1 (rolled 5-tap of_reproj
and on-demand oxk/oxxk in 16-tap loop) + OFX_PH1W=1 + OFX_LD3=1, cutting VGPR
74->55 (+50% occupancy), LDS 10272->7200 B, VLD 41->21, BAR 4->2.
Verified CPU-only on gfx1201 RGA (all 24 Wave 5b/5c kernels SCR=0, VSP=0, SSP=0,
scratch_ops=0, NAR=0), 172/172 Wave 4c DXIL SHA-256 bit-identical, runtime unit
tests, modes_self_check, and CPU numerical equivalence checks.
…0 opt-in), GPU-verified results
Paired GPU timing on RX 9070 XT (D3D12), 1440p Quality, 6 ABBA rounds against the wave-4c build:
plain 6.369 -> 5.760 ms, layer 6.600 -> 5.963 ms.
- bit 8 (stagef.{E4,E5,D4-F,D4-R}, 0x100) is not byte-identical to wave 4c (34.7..38.5 dB tone-mapped PSNR on
a small scene, 37 dB on 1440p Q reset frames against accurate): opt-in.
- bit 10 (resolve.fast2/3.w5c, 0x400) is clean but timing-neutral inside the default (+/-2 us paired): opt-in.
- exact, accurate and WG_RR_W5=0 stay byte-identical to wave 4c; the default has 0 NaN / Inf in every output
and history buffer (also at 1440p DLAA).
- README: per-bit timing, per-stage profile, 5-cell scaling table and quality metrics.
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.
Summary
Enables verified output-stage optimizations in
clean/rr_f/runtime/tools/build.py(keepingWG_RR_DFLOWoff by default and keepingOF_REPROJ_MAX=1in Fast mode):output.*): enableOFX_FUSE=1(fused 16-tap phase 1+2 loop) andOF_UNIF=1(uniform scratch words) — 100% bit-exact (output_diff.py --quickPASS across every case).output.*.f): enableOFX_FUSE=1andOFX_NOCHK=1(fast-mode-only; skips subnormal-band fallback check) alongsideOF_HWRCP=1,OF_REPROJ_MAX=1,OF_UNIF=1.output_diff.pyhandlesSystemExitwhen the optional model file is absent;output_prof.pyfalls back cleanly to synthetic constants whenDEFAULT_MODELis unset.Verification (RX 9070 XT
gfx1201, 1440p Quality1706x960 -> 2560x1440)output_diff.py --quick --defines OFX_FUSE=1,OF_UNIF=1: PASS (0 diffs onlinear,CH,Q,PH1,traceacross f16 & f32).output_bench.py(40 reps, same GPU job):output.fast):1.302 -> 1.243 msbest (-59 us),1.561 -> 1.521 msmean (-40 us).output.fast.f):0.894 -> 0.861 msbest (-33 us),1.097 -> 1.051 msmean (-46 us).rr_test_host.exe(250 frames x 2 rounds, steady-state frames 51-250, vs v0.6.5):fast: GPU6.794 -> 6.764 ms(-30 us), output0.736 -> 0.700 ms(-36 us), wall/frame7.090 -> 7.052 ms(-38 us)accurate: GPU7.365 -> 7.361 ms(-4 us), output1.071 -> 1.058 ms(-13 us), wall/frame7.670 -> 7.656 ms(-14 us)exact: GPU11.048 -> 11.032 ms(-16 us), output1.054 -> 1.039 ms(-15 us), wall/frame11.360 -> 11.344 ms(-16 us)tools/ci/check_line_endings.py: 1474 files checked, 0 problems.