Step-5 Preview 1.59×
Harness: Claude Code · switches: none
- Judged
- 1.59×
- Tier
- N1
- Self-best
- 1.58×
- Rounds
- 32
- Hours
- 10.1
- API cost
- $45.2
- Input tokens · 99.5% cached
- 407 M
- Output tokens
- 1.0 M
- Requests
- 876
§ 02Key levers
- Smaller tiles + rewritten binning
- ✗ stays 16×16, tile size never mentioned in the log; round 4 only hoisted the two reciprocals in duplicateWithKeys out of the loop; round 11 compacted the sort input with
cub::DeviceSelect::Flagged(sort 345 → 225 µs/step, but one more host sync, 222.9 vs 222.5 s, reverted); round 22 concluded that changing which tiles get emitted would change the image - Bypass autograd, activations folded into raster kernel
- ✗ only quaternion normalization made into a standalone Triton kernel outside the rasterizer (round 18, 1.4214 → 1.4822, N1); round 20 considered autograd's grad copies "library internals, can't be changed"
- Lazy Adam (update only visible Gaussians)
- ✗ dense; hand-written bitwise-identical Triton Adam (round 2 1.0484 → 1.2819, round 30 float4 → 1.4983); round 26 only skipped SH coefficients of inactive degrees, no gain (1.4827 → 1.4800)
- Fused loss / SSIM
- tried, reverted: round 19 L1 fused into a Triton kernel, 206.41 vs 206.41 s, no gain; SSIM untouched
- Other main levers
- host syncs removed from the iteration (round 1 → 1.0484; densification stats without boolean indexing → 1.3365), backward per-pixel / per-bucket state interleaved as float4 (rounds 13–14 1.3801 → 1.4214, round 31 1.4983 → 1.5565), forward 1/depth once per Gaussian (→ 1.3754), forward inner-loop address increments (→ 1.5759), 11 grad buffers merged into one
§ ARaw trace
Raw work log34 sections
0.7 hRound 1 — profile the unchanged reference, then remove the mid-iteration host syncs
- Profile (/tmp/r1/profile, steps 7000..7019, 20 steps): GPU busy 9.62 ms/step, CPU span 9.9 ms/step, GPU wall 9.8 ms/step → ~1.1 ms/step of GPU idle per iteration. 177 kernels, 494 CPU ops per step. Top CUDA consumers (share of self CUDA):PerGaussianRenderCUDA(backward) 27 %,renderCUDA(forward) 16 %, Adam 26 %,preprocessCUDA10 %,duplicateWithKeys5 %, fused-SSIM 1.4 %. A timestamp-correlated look at one iteration showed the cause of the idle:(radii > 0).nonzero()ingaussian_renderer/__init__.pyblocks the CPU for 1.4–3.0 ms waiting for the render kernel, and while the CPU then runs the (host-only) loss forward the GPU has nothing queued.loss.item()intrain.pyis a second sync at the same point in the iteration. - Changes (all N0 — no value is changed, only where the work is issued): -gaussian_renderer/__init__.py:visibility_filteris now the boolean maskradii > 0instead of(radii > 0).nonzero(); the consumers (max_radii2Dupdate,add_densification_stats) take the same rows with the same values. -train.py: droppedloss.item()from the per-iteration logging (tqdm postfix only; tensorboard is not installed in the judged environment, sotraining_reportis skipped unless a writer exists), and guarded theiter_start.elapsed_time(iter_end)call so it is not evaluated without a logger. -scene/gaussian_model.py: droppedtorch.cuda.empty_cache()fromdensify_and_prune. - Result:time→ 291.857 s,speedup_vs_frozen_reference1.0484;check --quickPASS (exact items). The gain is much smaller than the 11 % the profile suggested, because the GPU idle is only ~0.6 ms/step in window 1 and ~0.9 ms/step in window 2; windows 2–3 are already GPU-bound (window 3: GPU busy 10.11 ms/step vs wall 10.19 ms/step at N≈2 M). - Second profile at step 25050 (/tmp/r1/profile3, steady state, no densification): GPU busy 10.11 ms/step — backward rasterizer 3.58 ms, Adam 3.05 ms, forward rasterizer 2.64 ms, radix sort 0.23 ms. → the next hotspot is the optimizer step (30 % of the GPU time), and after it the rasterizer (61 %).
0.7 hRound 2 — one fused, bitwise-identical Adam step
- Change (utils/fast_adam.py, new;scene/gaussian_model.py):FusedAdam, atorch.optim.Adamsubclass whosestep()performs exactly upstream's update — the same operations in the same order with the same rounding boundaries — in one pass per parameter tensor with a Triton kernel, instead of torch's seven_foreach_*passes (lerp_, mul_, addcmul_, sqrt, div_, add_, addcdiv_) that stream the whole parameter set through HBM ~18 times instead of 7. - Numerics: verified bitwise identical totorch.optim.Adam's foreach path on the six real parameter shapes over 7 consecutive steps (/tmp/adamtest.py:torch.equalon p, exp_avg and exp_avg_sq, 42/42 OK). The two details that mattered: Triton's/isdiv.full.f32(2 ULP) — both divisions must uselibdevice.div_rn— andsqrtmust uselibdevice.sqrt_rn. - Fallbacks: no triton, or a parameter that is not contiguous / not float32 → the parent's own implementation (called through the *unwrapped*Adam.step, see below). A non-contiguous gradient is copied (layout only). Parameters without a gradient are skipped, exactly as upstream's Adam does — right after a densification the new parameters have no gradient yet and their step is not taken. -create_from_pcd:_xyzis created from a transposed numpy view, so upstream's_xyzis a transposed (stride(1, N)) tensor for the first 600 iterations;.contiguous()makes it dense from the start (values unchanged, per-point shape and dtype unchanged). - Bug found and fixed while integrating (first attempt was INCORRECT,/tmp/r2b/quick): callingsuper().step()from inside the overriddenstep()re-enters the global optimizer-step hooks a second time, becauseOptimizer._patch_step_functionwrapsAdam.stepitself as soon as any Adam exists in the process (the exposure optimizer does that here). Every fallback therefore counted as an extra Gaussian-optimizer step: 24 densification iterations → 24 extra steps, the camera/SH-degree/LR marks all shifted by one step. Fixed by calling the originalAdam.step(__wrapped__) directly. Also fixed:state['step']is normalised to a Python number (the parent's implementation stores a 0-dim CPU tensor), so the fused path can be used after a parent-created state. - Result:check --quickPASS (exact items of the first 3000 steps match the reference: 3000 renders, the same camera order, the same LR/SH-degree marks, the same densification steps, the same dtypes).time→ 238.698 s,speedup_vs_frozen_reference1.2819 (windows 68.5 / 87.8 / 82.3 s vs the reference's 84.5 / 112.5 / 109.0 s). Peak allocated memory unchanged (5.31 GiB). Note: the final Gaussian count is not an exact item; it differs from the frozen record by ~0.1 %, which is inside the reference's own run-to-run variation (the rasterizer's backward accumulates with atomics).
0.9 hRound 3 — profile the current best, then the next hotspot
- Profile of the current tree (see below) — the fused Adam removed ~1.9 ms/step, so the rasterizer is now ~76 % of the GPU time.
0.9 hRound 3 — apply the densification statistics mask without indexing it
tensor[bool_mask](read *and* in-place form) turns the mask into an index list on the host first:aten::nonzero→ a device→host synchronization in the middle of the iteration, then a gather/scatter of only the visible rows. The trace showed 8 of them per iteration, each blocking the CPU for ~250 µs and leaving the GPU idle while the CPU re-issued the backward. Both consumers of the visibility mask are now elementwise:max_radii2D = torch.maximum(max_radii2D, radii)(invisible Gaussians haveradii == 0andmax_radii2D >= 0, so they are untouched) andxyz_gradient_accum += norm(grad[:, :2]) * mask,denom += mask(Gaussians outside the mask have an all-zero screen-space gradient). All bit for bit the values the indexed form produced.time228.949 s → 1.3365 (was 1.2819);check --quickPASS.
1.6 hRound 4 — profile + rasterizer micro-optimizations
Profiles at 1050 / 2050 / 12050 / 25050 (per step, GPU busy vs CPU span): 3.06 / 4.1 / 8.56 / 7.98 ms, with the CPU span always just below — the run is GPU-bound everywhere; the only remaining recoverable time is GPU work. At N≈2.05 M the GPU work per step is 8.56 ms:PerGaussianRenderCUDA2.94,renderCUDA1.51, backwardpreprocessCUDA0.58,duplicateWithKeys0.56, radix sort 0.29, forwardpreprocessCUDA0.17, fused Adam 0.86, small ATen ops ~0.9. Changes (all bitwise identical, in the CUDA sources): -duplicateWithKeys: the two__frcp_rninmax_contrib_power_rect_gaussian_floatdepend on the Gaussian's conic only → computed once per Gaussian instead of once per overlapped tile. -PerGaussianRenderCUDA: pixel coordinates / linear id kept incrementally (the lane's pixel advances by one per iteration); the redundantW <= pix.xre-test inside a block already guarded byvalid_pixelremoved;1/(1-alpha)computed once per pixel instead of once per channel.-T_final / (1 - alpha)stays a division (multiplying by the reciprocal rounds differently). Two bugs were made and fixed on the way (both caught bytime's peak memory dropping to 2.46 GiB — the model stopped growing, whilecheck --quickstill PASSED because that gate compares the *steps* at which the count changes, not the counts): - the pixel advance was placed after the loop'scontinues, so skipped pixels never advanced the counter; -my_warp.thread_rank()is unsigned, so-rank % BLOCK_Xwrapped to 16-(rank%16).time226.025 s → 1.3538;check --quickPASS; the record's final count is 1,094,180 (reference 1,096,177). From now on, any rasterizer change is checked against that number as well.
1.9 hRound 5 — tried to remove the warp shuffles of `PerGaussianRenderCUDA` (failed, reverted)
Hypothesis: the 11shfl_upper iteration (and the 14 single-lane global loads they distribute) were the reason the kernel is latency-bound, and since the forward pass saves the per-pixel state at every 32-Gaussian boundary, each lane could read its own pixel's state directly (coalesced) and drop the shuffles. Implemented, built,check --quickPASSED (steps at which the count changes are robust) buttimeshowed 289.0 s and a peak memory of 6.61 GiB with a final count of 2,274,236 instead of ~1.09 M — the training diverged. Reason: the shuffledTandardo not only carry the saved per-pixel state, they carry the running accumulation across the gaussians of the same bucket at the same pixel; reading the saved state directly drops the contributions of the gaussians before this lane's in the bucket. Reverted (comment kept). Re-timed the reverted tree: 226.7 s → 1.3495, peak 5.31 GiB. Lesson recorded: a rasterizer change must be checked against the record's final count (~1.09 M at step 3000, ~2.03 M at step 30000, peak ~5.3 GiB), not only against the quick gate.
2.1 hRound 6 — where the remaining time is
The GPU has 132 SMs at 1980 MHz → ~1.05 T instructions/s of issue.PerGaussianRenderCUDA(2.97 ms/step, 51071 warps × 287 iterations ≈ 14.65 M warp-iterations) needs ≈ 212 instructions per iteration to explain its time, i.e. it runs at ~100 % of the issue rate: it is instruction-throughput bound, not latency bound, so the only lever left there is fewer instructions.renderCUDA(1.51 ms) is in the same position. The fused Adam (0.855 ms) already moves 3.4 GB/step, i.e. ~4 TB/s — at the memory roofline. The remaining items are the backward's 11torch::zerosgradient buffers (≈0.3 ms of zeroing + launch overhead) and the radix sort over the 4.73 M duplicated keys of which only ~1.63 M are valid.
2.2 hRound 7 — instruction-count attempts on the hot kernels (no gain, reverted)
-__launch_bounds__(32, 16)onPerGaussianRenderCUDA(REG 64 → 87): the instruction count was identical (536 total / 451 in the loop, 17LDC.64reloads of the kernel parameters either way) and the occupancy would drop from 50 % to 36 %. Reverted. -#pragma unrollon the channel loops + dropping theuint2 pixwrapper: the generated code was byte-for-byte the same instruction mix (the compiler already fully unrolled C=3). Reverted. Both kernels are at ~100 % of the issue rate (132 SMs × 4 × 1.98 GHz ≈ 1.05 T inst/s) and neither the loop body nor its scheduling could be shortened without changing the arithmetic.
2.4 hRound 8 — `renderCUDA`: hoist `1 / depth` out of the pixel loop
The forward blending loop evaluated1.f / depths[collected_id[j]]for every pixel of the tile, although the value depends only on the gaussian: all 256 threads of a tile issued the same division (aMUFU.RCPplus its refinement) and the same global load for the same gaussian. It is now computed once per gaussian while the batch is fetched into shared memory (collected_invdepth), which removes a division and a load from the inner loop of every contributing (pixel, gaussian) pair. The multiplication order is unchanged, so the result is bit for bit what it was.time222.47 s → 1.3754 (was 1.3538);check --quickPASS, final count 1,094,037 (reference 1,096,177). Committed as6197c8d. This was found by the same rule as the mask fix: look for work in a per-pixel loop that only depends on the gaussian (the backward already hoists its per-gaussian values —invd,c[ch],xy,con_o— the forward did not).
3.0 hRound 9 — two more attempts at the issue-rate wall (both no gain, reverted)
-PerGaussianRenderCUDA: hoisted the loop-invariantvalid_splatout of the pixel loop and merged the two guarded blocks (the state load and the work) into one. The generated code was unchanged (536 instructions, 451 in the loop — the compiler had already done both), so the tree was left as it was. -preprocessCUDA(backward, 583 µs/step, the only kernel with slack: 84 % of the issue rate): refactored its body into a__device__function and gave each thread two gaussians, hoping the two independent dependency chains would overlap.time226.7 s → 1.3500 (worse than 222.5 s / 1.3754): the register count went *down* (62 → 56), i.e. the compiler kept the loop rolled, so there was no extra ILP, only loop overhead. Reverted. -renderCUDA:__launch_bounds__(256, 4)(REG 32 → 43) did not remove the 8 per-iterationLDC.64reloads of the kernel parameters and would halve the occupancy. Reverted. Measured state of the three big kernels:PerGaussianRenderCUDA99.5 % andrenderCUDA100 % of the issue rate (132 SMs × 4 × 1.98 GHz ≈ 1.05 T inst/s), the fused Adam at the memory roofline (3.4 GB/step ≈ 4 TB/s).duplicateWithKeys(408 µs) andpreprocessCUDAbackward (583 µs) are the only ones with slack, and neither responded to the ILP attempt.
3.1 hRound 10 — final full check of the submitted tree
/tmp/r12/check: status PASS, speedup 1.371, tier N1 (candidate 223.191 s vs the frozen reference 305.993 s; windows 60.75 / 82.60 / 79.84 s). Endpoints: psnr −0.14σ, ssim −1.05σ, lpips +1.29σ, log_count +1.37σ — all within the 3σ bound. Final submission: HEAD6197c8d(clean),/submission/switches.json={"environment": {}}, no background processes,/tmpoutput directories removed.
4.2 hRound 11 — one gradient buffer instead of eleven (kept), and two dead ends
Measured state of the run at step 25050 (N≈2.05 M): CPU span 8.00 ms, GPU wall 8.00 ms, GPU busy 7.79 ms → the GPU is idle only 0.205 ms/step (2.5 %), spread over 138 kernel launches (median gap 1.1 µs). So the wall clock is GPU-bound and the remaining lever is the number of kernels and the bytes they move. - Kept (rasterize_points.cu): the backward's eleventorch::zerosgradient tensors are now slices of one zeroed block (each field 16-byte aligned, which the fused Adam kernel specializes on). Ten fewer allocations, fills and launches per step. Three timings: 222.21 / 222.46 / 221.96 s against 222.47 / 222.99 / 223.19 s before. Full check: PASS, 1.3786, N1 (psnr −0.94σ, ssim −0.03σ, lpips +0.89σ, log_count +0.13σ). - Dead end — compacting the radix sort's input (cub::DeviceSelect::Flaggedon a flag byte written byduplicateWithKeys, then sorting only the ~1.63 M real (gaussian, tile) pairs instead of the 4.73 M slots): the profiled sort+select+scan fell from 345 to 225 µs/step, but the wall clock did not move (222.9 s vs 222.5 s). The extra device→host synchronization needed for the selected count drains the pipeline and costs as much as the sort saves. - Dead end — instruction reductions in the hot loops: merging the two early-exit branches ofPerGaussianRenderCUDA(536→536 instructions, one branch fewer, NaN path preserved exactly),px/pyas selects induplicateWithKeys, and incrementalpixf— all bitwise identical, all below the timing noise (222.4 s vs 222.5 s).
4.7 hRound 12 — final state
Full check/tmp/r22/check: status PASS, speedup 1.3801, tier N1 (candidate 221.714 s vs the frozen reference 305.993 s; windows 60.03 / 82.13 / 79.56 s). A second statistical sample on the same tree (/tmp/r22/n1) also PASSes: psnr −0.31σ, ssim +0.76σ, lpips −2.23σ, log_count +0.80σ — so the −2.49σ psnr reading of the first sample was run-to-run noise. Across the seven full statistical runs of this tree the means are psnr −0.86σ, ssim −0.48σ, lpips −0.14σ, log_count +0.31σ with a run-to-run spread of about 1σ (the same tree gave psnr −2.49σ and −0.31σ), i.e. no measurable systematic bias. Final submission: HEAD7ea249e, working tree clean,/submission/switches.json={"environment": {}}, no background processes. ### Gains by change (vs the frozen reference 305.993 s) | change | total_s | speedup | |---|---|---| | reference | 305.993 | 1.000 | | no mid-iteration host syncs (bool mask, noloss.item(), noempty_cache) | 291.857 | 1.0484 | | + fused bitwise-identical Adam (utils/fast_adam.py,FusedAdam) | 238.698 | 1.2819 | | + densification statistics without indexing the mask | 228.949 | 1.3365 | | + rasterizer micro-optimizations (hoisted reciprocals, incremental pixel ids) | 226.025 | 1.3538 | | +renderCUDA:1/depthonce per gaussian per batch | 222.470 | 1.3754 | | + one gradient buffer instead of eleven | 221.964 | 1.3786 | | + screen-space+0dropped, two DtoD copies made async | 221.714 | 1.3801 | ### What the remaining time is made of (7.74 ms/step of GPU at N≈2.05 M)PerGaussianRenderCUDA2.98 ms andrenderCUDA1.39 ms run at ~100 % of the issue rate (132 SMs × 4 × 1.98 GHz ≈ 1.05 T inst/s); the fused Adam (0.86 ms) is at the memory roofline; the ATen ops (0.75 ms) are the same work the reference does, of which 0.17 ms is the irreducible zeroing of the backward's gradient buffers. The GPU is idle only 0.205 ms/step over 110 kernel launches. ### Directions that did not work, and why - removing the warp shuffles ofPerGaussianRenderCUDA(they carry the per-bucket accumulation across gaussians — the training diverges); -__launch_bounds__tuning,#pragma unroll, merging guarded blocks,px/pyas selects, incrementalpixf, merging the two early exits (all bitwise identical, all below the timing noise — the kernels are at the issue-rate wall); - two gaussians per thread in the backwardpreprocessCUDA(the compiler keeps the loop rolled: 226.7 s vs 222.5 s); - compacting the radix sort's input withcub::DeviceSelect::Flagged(profiled sort+select+scan 345 → 225 µs/step, but the extra device→host synchronization needed for the selected count drains the pipeline and costs as much as the sort saves: 222.9 s vs 222.5 s); - fusing the per-gaussian activations (F.normalize) or the L1 loss into Triton kernels: the savings are real (~0.5–2 %) but both need a reduction order reproduced bit for bit (NormTwoOpsaccumulates((0+x0²)+x1²)+x2²)+x3²sequentially, and the L1 mean reduces 1.6 M elements with a tree), which is where a mistake would silently become N1.
5.0 hRound 13 — interleave the per-bucket state (kept): 1.39x
PerGaussianRenderCUDAis instruction-throughput bound (measured at 99.5 % of the issue rate), and of its ~212 instructions per iteration about 35 are the address computation and the constant-memory reloads for the 14 global loads in the loop. The forward pass saves the per-bucket state in five separate arrays (sampled_T,sampled_ar[3],sampled_ard), so the backward pays five base pointers, five address computations and five parameter reloads per pixel. They are now one array ofSAMPLE_STRIDE = 6floats per (bucket, pixel),[T, ar.r, ar.g, ar.b, ard]: one base pointer and immediate offsets for all five loads. That removes eight instructions from the loop body and three pointer parameters from the kernel.time: 219.57 s / 1.3936 and 220.13 s / 1.3901 on two runs of the same tree, against 221.71 s / 1.3801 before.check --quickPASS, final count 1093770 (reference 1096177). Committed asb0f1c07-equivalent (see git log).
6.2 hRound 14 — interleave the image state too: 1.42x
Same lever as round 13, applied to what the backward pass loads per pixel of its inner loop. Ten of the fifteen loads there had their own base pointer, address computation and constant-memory reload:pixel_colors(three planar arrays),pixel_invDepths,final_Ts,n_contrib,dL_dpixels(three planar arrays) anddL_invdepths. They are now: -pixels, 8 floats per pixel[colour.r, .g, .b, inverse depth, final transmittance], written by the render kernel's epilogue (the twocudaMemcpyAsynccopies of the rendered image into the image state are gone); -dpixels, 4 floats per pixel[dL/dcolour.r, .g, .b, dL/dinverse depth], filled by a small gather kernel at the start of the backward (the loss gradient arrives as two planar arrays). The backward reads both with one base pointer and immediate offsets: **sixteen instructions fewer in the loop body** (528 → 512) and six pointer parameters fewer.time: 215.42 s / 1.4205 and 215.28 s / 1.4214 on two runs, against 220.13 s / 1.3901 before.check --quickPASS, final count 1090602 (reference 1096177). Bug made and fixed on the way: the first version crashed with an intermittent "illegal memory access" (steps 1266/1404/1424, three different CUDA errors) whilecheck --quickon the tree passed for the earlier commits. `compute-sanitizer --tool memcheck` only reported the *pre-existing* out-of-bounds shared write of the upstreamfusedssimCUDA(769 of them, in the reference too), which was a red herring; the real cause was that the patch that adds the render kernel's write of the interleaved array had aborted on a failed string match, so the array was never written and the backward read uninitialized memory. Reproduced with a small harness that mimicsbench/gs_entry.py(render wrapper + model wrapper), fixed, re-verified. ### Gains by change (vs the frozen reference 305.993 s) | change | total_s | speedup | |---|---|---| | reference | 305.993 | 1.000 | | no mid-iteration host syncs | 291.857 | 1.0484 | | + fused bitwise-identical Adam | 238.698 | 1.2819 | | + densification statistics without indexing the mask | 228.949 | 1.3365 | | + rasterizer micro-optimizations | 226.025 | 1.3538 | | +renderCUDA:1/depthonce per gaussian per batch | 222.470 | 1.3754 | | + one gradient buffer instead of eleven | 221.964 | 1.3786 | | + screen-space+0dropped, two DtoD copies made async | 221.714 | 1.3801 | | + interleaved per-bucket state (round 13) | 220.128 | 1.3901 | | + interleaved image state (round 14) | 215.277 | 1.4214 |
6.8 hRound 15 — interleave the last arrays: 1.42x
Two more of the same lever: -n_contrib(uint32) moves into the interleaved pixel struct as a float, so the final transmittance and the contributor count come out of one alignedfloat4next to the colour; - the forward's four per-gaussian shared arrays (collected_id,collected_xy,collected_conic_opacity,collected_invdepth) become one struct of eight floats read as two alignedfloat4s, so the inner loop addresses one base instead of four. A second alignment bug, caught the same way as the first: the first version put the conic at offset 3 of the struct, so*(const float4*)(c + 3)was 12-byte aligned and the run died withCUDA error: misaligned address. Fixed by reordering the struct into two alignedfloat4s:[id, mean.x, mean.y, 1/depth]and the conic. Both float4 loads are now 16-byte aligned.time: 214.56 s / 1.4262 and 215.55 s / 1.4196 on two runs of the same tree, against 215.28 s / 1.4214 before.check --quickPASS, final count 1095751.
7.1 hRound 16 — removing the two now-unused kernel parameters (no gain, discarded)
After round 15 the backward kernel no longer readsfinal_Tsorn_contrib(both live in the interleaved pixel struct), so I removed them fromPerGaussianRenderCUDA's signature and fromBACKWARD::render. The generated code was byte-for-byte the same instruction mix (520 instructions, 25 LDG, 20 LDC, 15 IMAD.WIDE.U32) — the compiler had already stopped reloading them — so the change was discarded and the tree stays at5bd08ed. Current state: HEAD5bd08ed,time215.28 s / 1.4214 and 215.55 s / 1.4196, full check/tmp/r36/checkPASS at 1.4216 (tier N1; psnr −1.8σ, ssim −0.77σ, lpips +0.38σ, log_count +0.02σ).
7.1 hRound 17 — where the remaining time is (measured, 7.48 ms/step of GPU at N≈2.05 M)
| kernel | µs/step | share | state | |---|---|---|---| |PerGaussianRenderCUDA(backward) | 2768 | 37 % | at the issue rate; 520 instructions, loop body ~212 | |renderCUDA(forward) | 1388 | 19 % | at the issue rate; 146 instructions in the inner loop | | fused Adam | 860 | 11 % | at the memory roofline (3.4 GB/step ≈ 4 TB/s) | |preprocessCUDA(backward, SH + covariance gradients) | 588 | 8 % | 84 % of the issue rate | |duplicateWithKeys| 407 | 5 % | 88 % of the issue rate | | ATen (zeroing + per-gaussian activations + loss) | 750 | 10 % | same work as the reference | | radix sort over the duplicated keys | 309 | 4 % | 4.73 M keys, 65 % of them padding | The interleaving lever is now exhausted for the two hot loops: the backward's inner loop addresses four bases (the per-bucket state, the pixel struct, the loss-gradient struct andn_contrib) and the forward's one. The largest remaining single item is the per-gaussian activationF.normalize(_rotation)(three kernels forward, six backward, ~176 µs/step ≈ 2.3 %). Fusing it into a Triton autograd Function would need the reduction order oflinalg_vector_norm(((0+x0²)+x1²)+x2²)+x3², sequential) and the whole backward chain ofdiv → expand → clamp_min → linalg_vector_normreproduced bit for bit, which is where a mistake would silently become N1; it is the next thing to try, not yet done.
7.4 hRound 18 — fuse the quaternion normalization: 1.48x
F.normalize(_rotation)is a composite of six kernels on the (N, 4) tensor (norm,clamp_min,expand_as,divforward;div+expand+clamp_min+linalg_vector_normbackward). Replaced by one Triton kernel each way (utils/quat_norm.py), with the reduction orderlinalg_vector_normuses (((0+x0²)+x1²)+x2²)+x3²), the clamp and expand backwards folded in and the norm saved for the backward. Anything the kernel cannot handle falls back toF.normalize. This is not bit-for-bit the reference (the difference is ~1e-7 relative in both the output and the gradient - I tried and failed to reproduce the composite's exact backward bit for bit), so it is tier N1 and the gates decide:check --quickPASS (final count 1100328, reference 1096177) and the full check PASS at 1.4822 (psnr −1.4σ, ssim −0.38σ, lpips −1.31σ, log_count +0.82σ).time: 206.41 s / 1.4825 and 206.45 s / 1.4822, against 215.28 s / 1.4214 before. The gain (4.3 %) is much larger than the ~1.5 % I expected from the kernel count alone: the backward's six kernels and their HBM round trips go away. ### Gains by change (vs the frozen reference 305.993 s) | change | total_s | speedup | |---|---|---| | reference | 305.993 | 1.000 | | no mid-iteration host syncs | 291.857 | 1.0484 | | + fused bitwise-identical Adam | 238.698 | 1.2819 | | + densification statistics without indexing the mask | 228.949 | 1.3365 | | + rasterizer micro-optimizations | 226.025 | 1.3538 | | +renderCUDA:1/depthonce per gaussian per batch | 222.470 | 1.3754 | | + one gradient buffer instead of eleven | 221.964 | 1.3786 | | + screen-space+0dropped, two DtoD copies made async | 221.714 | 1.3801 | | + interleaved per-bucket state | 220.128 | 1.3901 | | + interleaved image state | 215.277 | 1.4214 | | + interleaved the last per-pixel array and the forward's batch | 215.546 | 1.4196 | | + fused quaternion normalization | 206.448 | 1.4822 |
7.5 hRound 19 — fuse the L1 loss too (no gain, discarded)
l1_loss = torch.abs((image - gt)).mean()is the same kind of composite (sub, abs, mean forward; div, sgn/mul, add backward). Fused into one Triton kernel each way (utils/l1_mean.py): the backward is bitwise identical to the composite and the forward's mean matches bitwise at the real shape (3, 546, 979) — only other shapes differ by ~1e-7 (the reduction order).time: 206.41 s / 1.4824 against 206.41 s / 1.4825 before — no measurable gain, because the mean reduces 1.6 M contiguous elements (6.4 MB) while the quaternion case reduced 8 M elements read with a 16-byte stride (8x the cache lines) plus five intermediates. Discarded; the tree stays atc5eaa8d. That also explains why round 18 gained 4.3 % where the kernel count alone predicted 1.5 %: the win was the avoided HBM traffic (strided reads and intermediates), not the launch count. Current state: HEADc5eaa8d, full check/tmp/r39/checkPASS at 1.4822 (tier N1; psnr −1.4σ, ssim −0.38σ, lpips −1.31σ, log_count +0.82σ),time206.45 s.
7.6 hRound 20 — where the remaining time is now (7.48 ms/step of GPU at N≈2.05 M, after round 18)
| kernel | µs/step | share | state | |---|---|---|---| |PerGaussianRenderCUDA(backward) | 2768 | 37 % | at the issue rate; loop body ~212 instructions | |renderCUDA(forward) | 1388 | 19 % | at the issue rate | | fused Adam | 860 | 11 % | at the memory roofline (3.4 GB/step ≈ 4 TB/s) | |preprocessCUDA(backward: SH + covariance gradients) | 588 | 8 % | compute bound (1.7x the HBM roofline) | |duplicateWithKeys| 407 | 5 % | 88 % of the issue rate | | radix sort | 309 | 4 % | 4.73 M keys, 65 % padding | | ATen (all of it) | 333 | 4.4 % | of which ~216 µs is autograd's own copy of the gradients intoparam.grad| Round 18 removed ~420 µs of ATen work by fusing the quaternion normalization; the ATen total fell from 750 to 333 µs/step. What is left there is mostly autograd's gradient accumulation (the engine copies the gradients instead of stealing them, ~216 µs/step), which is library internals and cannot be removed from the tree.
7.7 hRound 21 — confirmation run
timeof HEADc5eaa8d: 206.375 s / 1.4827 (windows 56.12 / 76.46 / 73.80 s), matching the two earlier timings of the same tree (206.410 / 206.448 s) and the full check's 206.448 s. The submission is stable at 1.48x with a passing full check (/tmp/r39/check, PASS, tier N1). Nothing new was changed in this round: the remaining GPU time is 7.48 ms/step, of which the two rasterizer kernels (4.16 ms) are at the hardware issue rate and the fused Adam (0.86 ms) is at the memory roofline; the only items left with headroom arepreprocessCUDAbackward (588 µs, compute bound) andduplicateWithKeys(407 µs, 88 % of the issue rate), both of which need custom kernel work rather than a layout or fusion change, and the radix sort (309 µs) whose input is 65 % padding that cannot be dropped without a second pass of the opacity test.
7.7 hRound 22 — `duplicateWithKeys` instruction mix (no change)
The kernel is 608 instructions with a 183-instruction inner loop: 36 FMUL, 21 FFMA, 20 FADD, 9 LOP3, 7 int→float conversions, 6 comparisons, 6 saturating multiplies and 10 BSSY/BSYNC. The 77 floating-point instructions are themax_contrib_powerevaluation itself (the closed-form maximum of the quadratic over the tile), which is what decides which tiles a gaussian is emitted into — it cannot be simplified without changing which tiles are emitted, i.e. without changing the image. The remaining 12 % of headroom is memory latency (the conic and the per-gaussian loads), not instruction count. No change was made; the tree stays atc5eaa8d(1.4827 bytime, full check PASS at 1.4822).
8.1 hRound 23 — manual 2-way interleave of the backward preprocess (bug, then a numerics
8.3 hRound 24 — allocator configuration (no gain, not adopted)
Screened twoTORCH_CUDA_ALLOC_CONFsettings throughtime --config(there is nosweepsubcommand in this bench): | setting | total_s | speedup | peak reserved | |---|---|---|---| | (none, current) | 206.375 | 1.4827 | 36.4 GiB | |expandable_segments:True| 206.286 | 1.4833 | 36.4 GiB | |max_split_size_mb:128| 207.084 | 1.4776 | 37.6 GiB | Both are inside the run-to-run noise (the three timings of the same tree span 206.38–206.45 s), andmax_split_size_mbis slightly worse. The caching allocator is not a bottleneck: the reserved/allocated ratio (36 GiB against 5.5 GiB) costs nothing measurable, because the buffers are reused across iterations once the size stabilises. No change adopted;switches.jsonstays{"environment": {}}.
8.3 hRound 25 — fuse the densification statistics (numerics differ, abandoned)
The last "five kernels into one" candidate:max_radii2D = max(max_radii2D, radii),xyz_gradient_accum += norm(grad[:, :2]) * (radii > 0)anddenom += (radii > 0)are five kernels over the whole point set, once per iteration inside the densification window. A Triton kernel that does all three in one pass reproducesdenomandmax_radii2Dbit for bit, but notxyz_gradient_accum:linalg_vector_normdoes not compute plainsqrt(g0² + g1²)— it uses the scaled formulation for overflow/underflow safety, so the accumulator differs by ~5e-7 relative. Combined with a measured gain of only ~0.2 %, that is not worth an N1 change; abandoned. (utils/dens_stats.pywas written and validated against the composite but not kept.) Current state: HEADc5eaa8d, clean, full check PASS at 1.4822 (tier N1),time206.4 s.
8.5 hRound 26 — skip the SH coefficients that are provably always zero (no gain, abandoned)
The fused Adam moves 7 arrays (3.38 GB/step) and is at 3.93 TB/s, so the only way to move less is to touch less: the spherical-harmonic coefficients beyond(active_sh_degree + 1)^2have an all-zero gradient (the backward SH kernel only writes the used coefficients) and therefore all-zero moments, so their Adam update is provably exactly zero. A strided variant of the fused kernel updates only the first(d+1)² × 3floats of every 45-float row of_features_rest. Validated bitwise: the strided kernel reproduces the full kernel's p/exp_avg/exp_avg_sq for the processed coefficients and leaves the tail untouched, and after a 100-step run with no densification_features_rest(the one parameter whose gradient is identically zero at degree 0, hence deterministic) is bitwise equal to the reference's. The other five parameters differ, but so do two runs of the *same* tree — the rasterizer's atomics.time: 206.754 s / 1.4800 against 206.375 s / 1.4827 — no gain: the integer div/mod the strided indexing needs costs as much as the traffic it saves. Abandoned; the tree stays atc5eaa8d. (Also fixed on the way:_features_dchasdim() == 3too, so the "only the SH parameter" test has to beshape[1] * shape[2] > sh_coeffs * 3, notdim() == 3.) Current state: HEADc5eaa8d, clean, full check PASS at 1.4822 (tier N1),time206.4 s.
8.6 hRound 27 — final consolidation
Nothing changed. Final audit of the submission: - HEADc5eaa8d, working tree clean, six commits onoptsince the reference0a6e4af. -/submission/switches.json={"environment": {}}(the two allocator settings screened in round 24 were not adopted). - All the files gate 0 requires are present, no background processes,/tmpscratch removed. -timeof this tree: 206.375 / 206.410 / 206.448 s → 1.4827; full check/tmp/r39/checkPASS, speedup 1.4822, tier N1. ### What was tried and did not work (for the record) | direction | why it did not work | |---|---| | removing the warp shuffles ofPerGaussianRenderCUDA| they carry the per-bucket accumulation across gaussians; the training diverges | |__launch_bounds__,#pragma unroll, merging the guarded blocks,px/pyas selects, incrementalpixf, merging the two early exits | all bitwise-identical, all below the timing noise (the kernels are at the issue-rate wall) | | two gaussians per thread in the backwardpreprocessCUDA| a doubledstrideskipped half the gaussians (caught by the full check), and with the stride fixed the compiler emits different arithmetic, so the result is not bitwise identical | | compacting the radix sort's input withcub::DeviceSelect::Flagged| the extra device→host synchronization for the selected count costs as much as the sort saves | | fusing the L1 loss | no measurable gain (1.6 M contiguous elements, unlike the strided quaternion case) | | fusing the densification statistics |linalg_vector_normuses a scaled formulation, so the accumulator is not bitwise | | skipping the always-zero SH coefficients in Adam | the strided indexing's div/mod costs as much as the traffic it saves | |TORCH_CUDA_ALLOC_CONFsettings | inside the run-to-run noise |
8.6 hRound 28 — final measurement of the remaining idle
A last profile of the steady state (step 25050, N≈2.05 M) to see whether any recoverable
slack is left:
| quantity | per step |
|---|---|
| CPU span | 7.354 ms |
| GPU wall (first to last kernel) | 7.156 ms |
| GPU busy (sum of kernel durations) | 6.994 ms |
| GPU idle | 0.162 ms (2.3 %) |
The idle is spread over 1167 kernel launches with a median gap of 1.1 µs (p90 2.1 µs) — i.e.
it is launch overhead, not a stall: only 31 of the 1167 gaps exceed 8 µs and together they are
0.04 ms/step. The CPU is 0.2 ms *ahead* of the GPU, so nothing is waiting on the host.
The run is 97.7 % GPU-busy with the CPU ahead of it, so the only remaining lever is the GPU work
itself, and every kernel that matters is at a hardware limit: the two rasterizer kernels at the
issue rate (measured in rounds 13–16 and 22), the fused Adam at 3.93 TB/s, the forward
preprocessCUDA at ~4 TB/s. Nothing further was changed.8.7 hRound 29 — the exposure optimizer and the fused quaternion kernels (no change)
Checked the two remaining Triton kernels in the profile. The fused quaternion normalization now costs 45 µs (forward) + 51 µs (backward) per step, down from ~176 µs for the six-kernel composite — the gain round 18 measured. Its forward is 2.5× off the HBM roofline, which is the price of the four strided 4-byte loads that the sequential reduction order requires (linalg_vector_normaccumulates((0+x0²)+x1²)+x2²)+x3²), so it cannot be vectorised into onefloat4load without changing the numerics. The exposure optimizer's Adam step does not appear above the profile's cut-off (it steps 2,628 parameters), so there is nothing to fuse there either. No change; the tree stays atc5eaa8d.
8.6 hFinal state (unchanged since round 28)
HEADc5eaa8d, clean;switches.json{"environment": {}}; full check/tmp/r39/check**PASS, speedup 1.4822, tier N1;time206.4 s against the frozen reference 305.993 s (1.48×**); 97.7 % GPU-busy with the CPU 0.2 ms ahead.
9.2 hRound 30 — the Triton kernels' accesses were scalar (N0)
A shapes profile of the steady state (steps 7000–7019, N = 1.69 M) re-budgeted the step (7.2 ms):PerGaussianRenderCUDA2.49 ms,renderCUDA1.48 ms, the fused Adam 0.70 ms, forwardpreprocessCUDA0.50 ms,duplicateWithKeys0.34 ms, the radix sort 0.25 ms, and ~1.2 ms of everything else. Both rasterizer kernels sit at the issue-rate wall (205 and 147 SASS instructions per loop iteration, of which 26 are the forward's actual FP work), the Adam moves 2.1 GB per step at 4.2 TB/s, and the two preprocess kernels are at the issue rate too — so the only kernels off their hardware limit were my Triton ones. The Adam's PTX turned out to be 32 scalarld.global.b32and 24 scalarst.global.b32. Triton widens a masked access to 128-bit only when it can prove the mask is constant across the vector, which foroffs < nneeds n known divisible by 16; withdo_not_specializeon the element count it never is. The same was true of the quaternion normalisation, whose four components were loaded with a 16-byte stride. -utils/fast_adam.py: the kernel is split per program into a full-block path (no mask →ld.global.v4.b32) and a masked tail path; the branch is uniform, so nothing diverges. -utils/quat_norm.py: the four components are loaded and stored as one(BLOCK, 4)tile and peeled off withtl.split/tl.join, which keeps the left-to-right reduction order (((0+x0²)+x1²)+x2²)+x3²) bit for bit. Both were checked bitwise against the previous kernels (sizes 1, 3, 255, 256, 1000, 4096, 123457; the Adam also againsttorch.optim.Adam) andcheck --quickPASS.profile:_qnorm_fwd38.0 → 16.6 µs/step,_qnorm_bwd43.5 → 24.7 µs/step,_adam_fused_kernel695 → 656 µs/step (it was already at the HBM roofline, so only the issue count fell).time: 204.223 s, speedup 1.4983 (was 1.4827), i.e. the 79 µs/step the profile predicted.
9.9 hRound 31 — the backward kernel's per-pixel state fetch: 11 loads → 2 (N1)
A shapes profile of the steady state re-budgeted the step at 7.2 ms (PerGaussianRenderCUDA2.50,renderCUDA1.48, the fused Adam 0.70, the forwardpreprocessCUDA0.50,duplicateWithKeys0.34, the radix sort 0.25, the rest ~1.2). SASS accounting then separated the two rasterizer kernels: the backward's 174-instruction loop body × (BLOCK_SIZE+31) iterations × the bucket count reproduces its measured 2.50 ms to within a percent, i.e. it is *exactly* at the issue-rate wall, while the forward is not (removing 8 of its 82 inner-loop instructions there changed nothing measurable — that attempt, widening the per-gaussian colour to a float4, was reverted). So the round went at the backward. The block lane 0 runs every iteration to fetch the state of the pixel it works on cost 29 of the 174 instructions, eleven of them global loads: - the per-bucket state[T, ar.r, ar.g, ar.b, ard]was five strided scalar loads;[T, ar.r, ar.g, ar.b]is now one float4 (SAMPLE_STRIDE4) and the inverse depth has its own array → two loads. - the pixel's loss gradient arrived as two planar arrays and was read with three loads of strideH*Wplus one;pack_dpixels(present but never called) now interleaves them into one float4 per pixel → one load. Loop body 174 → 164,LDG.E.CONSTANT12 → 4,LDG.E.1281 → 3. Validation: the forward's image and radii are bitwise identical to the previous build; the backward's gradients differ from it by *less* than the run-to-run spread of the atomic accumulation (means3D 6.1e-5 vs 7.4e-4, opacity 6.1e-5 vs 2.1e-4, rotations 1.4e-4 vs 2.2e-4, sh 1.8e-4 vs 2.4e-4), andcheck --quickPASS.profile:PerGaussianRenderCUDA2.500 → 2.269 ms/step.time: 196.595 s, speedup 1.5565 (was 1.4983).
10.1 hRound 32 — the forward's inner loop recomputed three addresses every round (N0)
Round 31's lesson was thatrenderCUDAis *not* bound by its instruction count at the margin: removing eight instructions from its conditional body there changed nothing measurable (that attempt, a float4 per-gaussian colour, was reverted). It is bound by what it executes every round. Reading its SASS, three addresses were recomputed on each of theBLOCK_SIZErounds: the shared-memory window base (twoS2URspecial-register reads), the gaussian's slot incollected, and the per-bucket state slot (which also needed thebbmmultiply and two 64-bit address computations). The gaussian's slot is now a running pointer advancing byGAUSSIAN_STRIDE, and the per-bucket state is written through two running pointers advancing byBLOCK_SIZEpixels per bucket. Kernel 456 → 440 SASS instructions. Validation: the forward's image and radii are bitwise identical, the backward's gradients differ by less than the run-to-run atomic spread,check --quickPASS.profile:renderCUDA1.471 → 1.331 ms/step.time: 194.176 s, speedup 1.5759 (was 1.5565).