Gemini 4 Carbon 2.99×

Harness: Antigravity · switches: none

Judged
2.99×
Tier
N1
Self-best
3.00×
Rounds
18
Hours
10.0
API cost
$106
Input tokens · 96.2% cached
243 M
Output tokens
1.1 M
Requests
868
Sequence packing
✓ round 2 LLAVA_UNPAD_LLM (plus LLAVA_SPARSE_LM_HEAD for labeled positions only, recompute cut 22 → 12 layers), 2447.4 → 1552.8 ms
Recompute / activations
✓ round 1 recompute 22/32 layers, round 2 12; round 3 LLAVA_GRAD_CKPT=0 after fused kernels dropped the big saved tensors, peak memory actually 119.08 → 114.77 GiB
Optimizer
✓ round 1 fused AdamW cut into ≤1e9-element views (avoids the 231 overflow); round 4 LLAVA_FAST_ZERO2 single-pass Triton AdamW reads bf16 grads, writes bf16 weights (~115 → 23.9 ms); round 11 16 chunks overlapped with P2P weight exchange (standalone 45.07 → 33.04 ms); round 19 LLAVA_IPC_ADAMW one kernel writes both the local GPU and, over NVLink IPC, the peer GPU (35.45 → 26.13 ms)
Communication & libraries
✓ ZeRO-2 (round 1, reproduces the zero.Init RoPE cache); round 6 NCCL_PROTO=Simple + all-reduce with AVG; round 8 torch 2.1.2 kept, only cuBLAS 12.8 swapped in via LD_PRELOAD (1064.9 → 1021.1 ms); round 10 self-built FA3 (1002.8 → 979.7 ms); round 14 reduce-scatter over odd/even-layer partitions (965.1 → 961.1 ms); round 16 dW GEMMs write straight into the reduce-scatter buffer (with CLIP fusion 956.4 → 944.0 ms)
Other main levers
round 3 Triton fused RMSNorm + residual (174.4 → 19.7 ms), QK RoPE (101.7 → 8.4 ms), SwiGLU (35.3 → 19.0 ms); CLIP runs 23 layers with FlashAttention (34.29 → 14.50 ms); QKV and gate/up merged GEMMs over adjacent views in the ZeRO-2 flat buffer (1021.1 → 1006.9 ms); each step's 32 samples re-split across the two GPUs by estimated FLOPs (961.1 → 956.4 ms); persistent grad buffers, loss .item() moved from before to after backward (944.0 → 933.8 ms); ends at 922.8 ms/step (round 20)
Raw work log22 sections
0.0 hRound 1: Baseline Profile & L0 Distributed / Memory-Saving / Optimizer Switches
- Start time: 2026-11-19T19:06:00Z
- End time: 2026-11-19T20:19:52Z
- Baseline profile findings (/tmp/r1/profile/profile_tree.md, 2 steps):
  - Total Rank 0 GPU kernel time: 2882 ms/step (2561.3 ms compute + 320.9 ms NCCL; Rank 1 NCCL wait+comm 1675.2 ms/step).
  - Top hotspots: 4b_bwd_grad 1162.4 ms (45.4%), 4a_bwd_recompute_fwd 609.4 ms (23.8%), 2_llm_fwd_layers 228.5 ms (8.9%), ZeRO-3 AllGather 235.5 ms + ReduceScatter 84.4 ms, non-GEMM elementwise/copy 985.3 ms (including unfused _foreach AdamW 65.2 ms + copies 34.3 ms, FlashAttn unpad/pad 55.4 ms).
- Changes made (2c6128b):
  - LLAVA_ZERO_STAGE=2 (scripts/zero2_opt.json: stage: 2, overlap_comm: true, contiguous_gradients: false, sub_group_size: 1e12, reduce_bucket_size: 5e8), exact zero.Init RoPE cache reproduction.
  - LLAVA_GRAD_CKPT=22 + PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True.
  - LLAVA_FUSED_ADAMW=1: chunked zero-copy <=1e9-element views for torch._fused_adamw_.
- Results:
  - check --quick (/tmp/r1/quick/check.json): PASS (tier N1, 0 exact failures, 25/4724 minor diagnostic violations).
  - time (/tmp/r1/time/time_tree.json): 2447.4 ms/step, speedup_vs_frozen_reference = 1.1292, window_spread = 0.0038, peak_memory_allocated_gib = 129.62.

---
1.2 hRound 2: Unpadded Packed 1D LLM + Supervised-Only LM Head + Lower Gradient Checkpointing
- Start time: 2026-11-19T20:19:55Z
- End time: 2026-11-19T20:38:45Z
- Round 2 profile findings (/tmp/r2/profile/profile_tree.md, 2 steps):
  - GPU kernel time: 2344 ms/step (down from 2882 ms/step; AllGather down 10x to 22.0 ms/step).
  - Top hotspots:
    1. Padded LLM GEMMs (sm90_xmma_gemm = 1296.5 ms/step, 55.3%) + padded elementwise/norm/RoPE/SwiGLU (~880 ms/step, 37.5%) operating on 31%–64% zero padding tokens.
    2. Per-layer _get_unpad_data host syncs (aten::nonzero blocking 1357.4 ms/step, aten::item 49.8 ms/step) + IndexFirstAxis / pad_input (~95 ms/step).
    3. Remaining 22/32 checkpointed layers (CheckpointFunctionBackward 1193.5 ms/step).
- Changes made:
  - LLAVA_UNPAD_LLM=1: Single compact DtoH metadata sync per micro-batch, single batched embed_tokens call across all samples, packed [1, total_nnz, 4096] execution through all 32 LlamaDecoderLayers, direct zero-transpose unsqueeze_dim=2 RoPE + flash_attn_varlen_func with precomputed (cu_seqlens, max_seqlen) (0 unpad_input/pad_input, 0 nonzero/.item() syncs inside layers).
  - LLAVA_SPARSE_LM_HEAD=1: Filter hidden_states to supervised label positions (shift_labels != -100, ~10% of tokens) before lm_head and fp32 cross-entropy.
  - LLAVA_GRAD_CKPT=12: Lowered checkpointed layers from 22 to 12 (leaving 20 GiB HBM headroom including Gate 2's deterministic FlashAttn workspace).
- Results:
  - check --quick (/tmp/r2/quick/check.json): PASS (tier N1, 0 errors, 0 exact failures, 25/4724 minor diagnostic violations).
  - time (/tmp/r2/time/time_tree.json): 1552.8 ms/step, speedup_vs_frozen_reference = 1.7797 (windows [15.795s, 15.262s], window_spread = 0.0121, peak_memory_allocated_gib = 119.08, step-1 loss diff 7e-5, step-24 loss 0.9654 vs ref 0.9646).

---
1.2 hFull Check #1 (After Round 2)
- Start time: 2026-11-19T20:39:00Z
- End time: 2026-11-19T20:46:28Z
- Result (/tmp/r2/full_check/check.json): PASS (tier N1, speedup = 1.7787, 1553.7 ms/step vs 2763.6 ms/step, peak_memory_allocated_gib = 119.08).
  - Gate 0: PASS (reference partition)
  - Gate 1: PASS (1553.7 ms/step, windows [15.74s, 15.335s], 1.7787x)
  - Gate 2: NOT_BITWISE (0 errors, 0 exact failures, 25/4724 minor diagnostic deviations)
  - Gate 3: PASS (train_loss_last20_canonical bias +0.000275 = +0.087σ vs 3σ = 0.009458; probe_loss_last20 bias -0.000242 = -0.084σ vs 3σ = 0.008624; trajectory wall 131.4s).

---
1.7 hRound 3: Profile R2 & Custom Fused Triton Kernels (RMSNorm + Residual, RoPE, SwiGLU) + Full Removal of Gradient Checkpointing
- Start time: 2026-11-19T20:47:15Z
- End time: 2026-11-19T21:17:30Z
- Profile of R2 (/tmp/r3/profile/profile_tree.md):
  - 1612 ms/step Rank 0 GPU kernel time: GEMMs 1007.7 ms/step (including 12/32 recomputed forward layers ~98 ms), non-GEMM elementwise/copy/cat/silu/reduce 461.5 ms/step (LlamaRMSNorm ~160 ms, RoPE + CatArrayBatchedCopy ~92 ms, SwiGLU ~56 ms, residual adds), FusedAdamW 58.0 ms/step, DeepSpeed scaled_global_norm + cast/unscale/copy ~55 ms/step, CLIPVisionTower 34.75 ms/step, and cross-rank NCCL AllReduce straggler wait (50.3 ms r0 vs 318.5 ms r1).
- Changes implemented (llava/train/triton_ops.py + llava/train/opt_patches.py):
  - LLAVA_FUSED_OPS=1:
    - fused_rms_norm & fused_add_rms_norm: Custom fixed-config Triton kernels (fwd + deterministic grouped-CTA bwd, fp32 variance/reduction, zero [N, 4096] fp32 saved tensors, fused post-attention residual add + RMSNorm + backward branch grad sum). Reduced 32-layer norm+add time from 174.4 ms to 19.7 ms (8.8x).
    - fused_qk_rope: Custom single-launch Triton kernel rotating Q and K together (fwd + bwd, 0 bytes of [N, 4096] saved activation tensors, bitwise identical to PyTorch apply_rotary_pos_emb). Reduced 32-layer RoPE time from 101.7 ms to 8.4 ms (12.1x).
    - fused_swiglu: Custom Triton kernel (silu(gate) * up fwd + bwd, eliminating [N, 11008] silu(gate) saved tensor, achieving 89.4% of Hopper HBM3e peak bandwidth). Reduced 32-layer SwiGLU time from 35.3 ms to 19.0 ms (1.85x).
  - LLAVA_GRAD_CKPT=0: Eliminated all remaining activation checkpointing (0/32 layers recomputed); because the fused Triton kernels cut saved activations by >35 GiB across 32 layers, peak allocated memory actually decreased from 119.08 GiB to 114.77 GiB!
- Verification:
  - time (/tmp/r3/time/time_tree.json): 1182.5 ms/step (2.3371x speedup vs frozen reference 2763.6 ms/step), window_spread = 0.0153, logged_loss_first_step_rel_diff = 0.0, logged_loss_max_rel_diff = 0.0028, peak_memory_allocated_gib = 114.77, problems = [].
  - check --quick (/tmp/r3/quick/check.json): PASS (tier N1, 0 exact failures, 27/4724 minor diagnostic deviations).

---
2.8 hRound 4: Profile R3 & Fused Triton ZeRO-2 AdamW + 2-Slot Event-Bounded Backward Overlap
- Start time: 2026-11-19T21:18:00Z
- End time: 2026-11-19T21:55:00Z
- Profile of R3 (/tmp/r4/profile/profile_tree.md):
  - 1246 ms/step Rank 0 GPU kernel time: cuBLAS SM90 GEMMs 865.7 ms (69.5%), FlashAttn2 74.9 ms (6.0%), our 4 custom Triton LLM ops 44.5 ms (3.6% total!), FusedAdamW 58.8 ms + DeepSpeed Stage 2 scaled_global_norm (.double() 17.2 ms, norm 7.8 ms, 152× aten::item syncs) + .to(fp32) (10.2 ms) + mul_(1.0) (6.3 ms) + bf16.copy_(fp32) (9.4 ms) + 14 per-bucket torch.cuda.synchronize() stalls inside allreduce_and_copy when contiguous_gradients: false, CLIPVisionTower ~35 ms/step, and Rank 1 AllReduce straggler wait (225.8 ms vs 48.4 ms r0).
- Changes implemented (llava/train/triton_ops.py + llava/train/opt_patches.py):
  - LLAVA_FAST_ZERO2=1:
    - triton_zero2_adamw_step: Single-pass int64-indexed Triton AdamW kernel over 3.37B elements reading bf16 flattened gradients directly, updating fp32 master weights + exp_avg + exp_avg_sq in registers, and writing bf16 partition weights in the same pass (23.9 ms/step at 3.95 TB/s = 82.3% HBM3e peak, down from ~115 ms/step), while skipping unused scaled_global_norm (clip_grad == 0.0, bf16) and mul_(1.0). Properly initializes step counter from state["step"] (which initialize_optimizer_states pre-advances to 1).
    - fast_allreduce_and_copy: Replaced DeepSpeed's per-bucket torch.cuda.synchronize() inside allreduce_and_copy with CUDA stream event ordering (stream.wait_stream(cur_stream) + record_stream(stream)) bounded by a 2-slot event ring so reduction_stream never queues >2 bucket buffers (peak_memory_reserved_gib dropped from 125.05 GiB to 118.64 GiB).
    - Also disabled redundant gradient_checkpointing flags on frozen vision_tower submodules.
- Verification:
  - time (/tmp/r4/time/time_tree.json): 1094.7 ms/step (2.5245x speedup vs frozen reference 2763.6 ms/step), window_spread = 0.0161, peak_memory_allocated_gib = 114.77, peak_memory_reserved_gib = 118.64, problems = [].
  - check --quick (/tmp/r4/quick/check.json): PASS (tier N1, 0 exact failures, 27/4724 minor diagnostic deviations — 0 additional deviations over Round 3).

---
3.0 hRound 5: Fast CLIP Vision Tower (23/24 Layer Truncation + Fused QKV + FlashAttention2 + Bitwise Triton QuickGELU)
- Start time: 2026-11-19T21:55:50Z
- End time: 2026-11-19T22:05:20Z
- Motivation from R4 Profile:
  - CLIPVisionTower accounted for ~34.75 ms/step (12.2 ms eager bmm attention + 4.2 ms softmax + 2.8 ms scale + 2.0 ms contiguous() copies + 2.5 ms QuickGELU + dead Layer 23 + dead post_layernorm since mm_vision_select_layer == -2).
- Changes implemented (llava/train/triton_ops.py + llava/train/opt_patches.py):
  - LLAVA_FAST_CLIP=1:
    - Truncated CLIPEncoder execution at len(layers) + select_layer + 1 = 23 layers, skipping dead Layer 23, encoder_states tuple construction, and post_layernorm.
    - Cached fused QKV weight/bias in attn.__dict__["_llava_qkv_cache"] (preserving named_parameters() and named_buffers() unchanged) and ran flash_attn_qkvpacked_func directly on [B, 577, 3, 16, 64] with zero transposes or contiguous copies.
    - Added bitwise-matching triton_quick_gelu (x * sigmoid(1.702 * x)) in triton_ops.py.
    - Standalone Hopper benchmark cut CLIPVisionTower [16, 3, 336, 336] wall time from 34.29 ms to 14.50 ms (2.37x).
- Verification:
  - time (/tmp/r5/time/time_tree.json): 1075.2 ms/step (2.5703x speedup vs frozen reference 2763.6 ms/step), window_spread = 0.0178, logged_loss_first_step_rel_diff = 0.00036, logged_loss_max_rel_diff = 0.0016, peak_memory_allocated_gib = 114.91, peak_memory_reserved_gib = 118.84, problems = [].
  - check --quick (/tmp/r5/quick/check.json): PASS (tier N1, 0 exact failures, 34/4724 minor diagnostic deviations).

---
3.0 hFull Check #2 (After Round 5)
- Start time: 2026-11-19T22:06:00Z
- End time: 2026-11-19T22:12:35Z
- Result (/tmp/r5/full_check/check.json): PASS (tier N1, speedup = 2.5674, 1076.4 ms/step vs 2763.6 ms/step).
  - Gate 0: PASS (reference partition)
  - Gate 1: PASS (1076.4 ms/step, 2.5674x)
  - Gate 2: NOT_BITWISE (0 errors, 0 exact failures, 34/4724 minor diagnostic deviations)
  - Gate 3: PASS (train_loss_last20_canonical bias -0.000065 = -0.020σ vs 3σ = 0.009458; probe_loss_last20 bias -0.000162 = -0.056σ vs 3σ = 0.008624).

---
3.4 hRound 6: Profile R5 & NVLink-18 Collective Polish (`NCCL_PROTO=Simple`, `ReduceOp.AVG`, Partition-Filtered Grad Copy) + 64-Op Cross-Layer `FusedAddRMSNorm`
- Start time: 2026-11-19T22:14:00Z
- End time: 2026-11-19T22:28:40Z
- Profile of R5 (/tmp/r6/profile/profile_tree.md):
  - 1138 ms/step Rank 0 GPU kernel time: cuBLAS SM90 GEMMs 870.1 ms (76.5%), FlashAttn2 (LLM+CLIP) 78.2 ms (6.9%), custom Triton ops 45.9 ms (4.0%), Triton ZeRO-2 AdamW 24.5 ms (2.2%), NCCL AllReduce 49.4 ms + AllGather 25.2 ms (running RING_LL instead of Simple over NVLink-18!), div_(2.0) 10.4 ms, and remaining inter-layer residual CUDAFunctor_add 15.0 ms.
  - Also microbenchmarked runtime-concatenated QKV (CatLinear3: 219.8 ms vs 210.5 ms separate) and Gate+Up (CatLinear2: 401.2 ms vs 385.1 ms separate) at M=14500: rejected before end-to-end run because [14500, 4096] SM90 GEMMs are already TensorCore/700W saturated (~665 TFLOP/s).
- Changes implemented (llava/train/opt_patches.py + switches.json):
  - NCCL_PROTO=Simple over 18-link NVLink (NV18), cutting AllGather from 25.2 ms to ~20.3 ms and AllReduce from 50.4 ms to 42.2 ms.
  - Replaced tensor.div_(2.0) + all_reduce(SUM) inside fast_allreduce_and_copy with single-pass dist.all_reduce(..., op=dist.ReduceOp.AVG) (-10.4 ms kernel time / -27 GB HBM traffic) and skipped buf.copy_(synced) for parameters outside the current rank's partition (-13.5 GB HBM traffic).
  - Extended LLAVA_FUSED_OPS=1 in LlamaModel.forward to fuse all 32 post-MLP inter-layer residual adds directly into the next layer's input_layernorm (and final self.norm) via fused_add_rms_norm, fusing 64/64 residual adds across the entire 7B LLM.
- Verification:
  - time (/tmp/r6/time/time_tree.json): 1064.9 ms/step (2.5951x speedup vs frozen reference 2763.6 ms/step, 30.05 samples/s), window_spread = 0.0158, logged_loss_first_step_rel_diff = 0.00036, logged_loss_max_rel_diff = 0.0021, peak_memory_reserved_gib = 118.92, problems = [].
  - check --quick (/tmp/r6/quick/check.json): PASS (tier N1, 0 exact failures, 34/4724 minor diagnostic deviations).

---
3.8 hRound 7: Intra-Step FLOP-Balanced Micro-Batching (`LLAVA_BALANCE_TOKENS=1`) — Tested, Not Activated
- Start time: 2026-11-19T22:30:00Z
- End time: 2026-11-19T22:36:45Z
- Result (/tmp/r7/time/time_tree.json): 1064.9 -> 1062.1 ms/step (-2.8 ms/step, 0.26%, inside the 0.42% reference noise band) while moving repartitioned = true. Left inactive so /submission preserves the exact reference micro-batch partition (repartitioned = false).

---
3.8 hRound 8: Hopper SM90 CUDA 12.8 cuBLAS Upgrade in `/opt/candidate-env`
- Start time: 2026-11-19T22:37:30Z
- End time: 2026-11-19T22:53:25Z
- Motivation:
  - In the Round 6 profile, cuBLAS SM90 bf16 GEMMs accounted for 870.1 ms/step (81.7% of total wall time) on torch 2.1.2+cu121 (cuBLAS 12.1.3), while the host driver is 570.148.08 (CUDA 12.8).
- Changes implemented (/opt/candidate-env + /submission/switches.json):
  - Installed nvidia-cublas-cu12==<ip> and nvidia-nvjitlink-cu12==12.8.61 into /opt/candidate-env and enabled them via LD_PRELOAD in /submission/switches.json (torch 2.1.2+cu121, deepspeed 0.12.6, transformers 4.37.2, and flash-attn 2.5.8 unchanged).
  - Standalone Hopper 32-layer DecoderLayer (fwd+bwd) benchmark dropped from 981.82 ms to 950.99 ms (-30.8 ms).
  - Also benchmarked nvidia-nccl-cu12==2.26.2 (42.7 ms AR / 20.3 ms AG vs 42.2 ms / 20.3 ms built-in with NCCL_PROTO=Simple): no extra gain over NCCL_PROTO=Simple, so omitted.
- Verification:
  - time (/tmp/r8/time/time_tree.json): 1021.1 ms/step (2.7065x speedup vs frozen reference 2763.6 ms/step, 31.34 samples/s), window_spread = 0.0161, logged_loss_first_step_rel_diff = 0.00036, logged_loss_max_rel_diff = 0.0012, peak_memory_reserved_gib = 118.92, problems = [].
  - check --quick (/tmp/r8/quick/check.json): PASS (tier N1, 0 exact failures, 34/4724 minor diagnostic deviations — 0 additional deviations).

---
3.8 hFull Check #3 (After Round 8)
- Start time: 2026-11-19T22:54:15Z
- End time: 2026-11-19T23:00:46Z
- Result (/tmp/r8/full_check/check.json): PASS (tier N1, speedup = 2.7067, 1021.0 ms/step vs 2763.6 ms/step).
  - Gate 0: PASS (reference partition)
  - Gate 1: PASS (1021.0 ms/step, 2.7067x)
  - Gate 2: NOT_BITWISE (0 errors, 0 exact failures, 34/4724 minor diagnostic deviations)
  - Gate 3: PASS (train_loss_last20_canonical bias +0.000247 = +0.078σ vs 3σ = 0.009458; probe_loss_last20 bias +0.000124 = +0.043σ vs 3σ = 0.008624).

---
4.6 hCurrent Summary (Superseded by Round 9 below)
- Round 9 profile logged at /tmp/r9/profile/profile_tree.md.

---
4.6 hRound 9: Zero-Copy Adjacent `Gate+Up` SwiGLU and `QKV+RoPE+FlashAttn` GEMMs (`LLAVA_FUSED_GEMM=1`)
- Start time: 2026-11-19T23:08:30Z
- End time: 2026-11-19T23:40:05Z
- Motivation:
  - In /tmp/r9/profile/profile_tree.md, cuBLAS SM90 nvjet GEMMs accounted for 824.2 ms/step (80.7% of 1021.0 ms wall time) and CUDAFunctor_add (dX_gate + dX_up and dX_q + dX_k + dX_v branch sums) took 9.8 ms/step.
  - Earlier runtime torch.cat of weights/gradients lost +9.4 ms / +16.1 ms due to HBM concatenation copies, whereas DeepSpeed Stage 2 (round_robin_gradients=False default) already places (q_proj.weight, k_proj.weight, v_proj.weight) and (gate_proj.weight, up_proj.weight) immediately adjacent in self.bit16_groups_flat[0].
- Changes implemented (llava/train/triton_ops.py, llava/train/opt_patches.py, /submission/switches.json):
  - Added adjacent_view_2 and adjacent_view_3 zero-copy UntypedStorage views (w_gu [22016, 4096] and w_qkv [12288, 4096]), preserving all nn.Parameter names/shapes untouched.
  - Added 2D strided _swiglu_gu_fwd_kernel and _swiglu_gu_bwd_kernel (BLOCK_N=1024, 100% bitwise identical to unfused fused_swiglu) + _FusedGateUpSwiGLUFn (1 fwd GEMM, 1 dX GEMM, 1 dW GEMM, 0 copies, 0 dX branch adds).
  - Added _FusedQKVRoPEFn (1 fwd GEMM + in-place strided _qk_rope_kernel on qkv[:, 0:2] + flash_attn_varlen_qkvpacked_func + in-place strided backward _qk_rope_kernel on dqkv[:, 0:2] + 1 dX GEMM + 1 dW GEMM, 0 dX branch adds).
  - Eliminated 288 GEMM launches and 96 dX add kernels per step.
- Verification:
  - time (/tmp/r9/time_gemm/time_tree.json): 1006.9 ms/step (2.7446x speedup vs frozen reference 2763.6 ms/step, 31.78 samples/s, Window 1 at 988.6 ms/step), window_spread = 0.0141, logged_loss_first_step_rel_diff = 0.00036, logged_loss_max_rel_diff = 0.002, peak_memory_allocated_gib = 114.91, peak_memory_reserved_gib = 118.88, problems = [].
  - check --quick (/tmp/r9/quick_gemm/check.json): PASS (tier N1, 0 errors, 0 exact failures, 36/4724 minor diagnostic deviations).

---
5.2 hRound 10: Direct Partitioned Gradient Buffer (`LLAVA_DIRECT_GRAD_PART=1`) + Hopper SM90 FlashAttention-3 (`LLAVA_FA3=1`)
- Start time: 2026-11-19T23:44:30Z
- End time: 2026-11-20T03:26:00Z
- Motivation:
  - In LLAVA_FAST_ZERO2, fast_step called self.flatten(self.averaged_gradients[i]) (CatArrayBatchedCopy over 3.37B elements = ~4.5 ms/step exposed GPU time).
  - LLM variable-length FlashAttention-2 (flash-attn 2.5.8) took 75.2 ms/step (58.2 ms bwd + 17.0 ms fwd) without Hopper SM90 TMA + wgmma warp-specialization.
- Changes implemented (/opt/candidate-env, llava/train/triton_ops.py, llava/train/opt_patches.py, /submission/switches.json):
  - Direct Partitioned Gradient Buffer (LLAVA_DIRECT_GRAD_PART=1): Allocated a step-scoped flat partition buffer parts[i] ([partition_size[i]] bf16) at the first backward reduction bucket, copied reduced bucket slices directly into parts[i] on self.reduction_stream, freed per-parameter .grad buffers immediately on the next bucket flush, exposed zero-copy .narrow() views in self.averaged_gradients[i] for Gate 2 safe_get_full_grad, and passed parts[i] directly into triton_zero2_adamw_step (1006.9 -> 1002.8 ms/step, 2.7560x).
  - Hopper SM90 FlashAttention-3 (LLAVA_FA3=1): Compiled minimal-template flash_attn_3-3.0.0b1 (sm_90a, bf16, hdim=128 fwd+bwd using nvcc 12.6.85 + ptxas 12.8.93 + CUTLASS 4.0) into /opt/candidate-env, and added zero-copy _FA3VarlenQKVPackedFn honoring torch.are_deterministic_algorithms_enabled() (61.51 ms -> 37.72 ms = 1.63x faster standalone, 0 RNG state mutation).
- Verification:
  - time (/tmp/r10/time_fa3/time_tree.json): 979.7 ms/step (2.8210x speedup vs frozen reference 2763.6 ms/step, 32.66 samples/s, windows [9.980s, 9.613s]), window_spread = 0.0152, logged_loss_first_step_rel_diff = 0.00087, logged_loss_max_rel_diff = 0.0019, peak_memory_allocated_gib = 114.85, peak_memory_reserved_gib = 120.56, problems = [].
  - Full Check #4 (/tmp/r10/full_check/check.json): PASS (tier N1, speedup = 2.8194, 980.2 ms/step vs 2763.6 ms/step).
    - Gate 0: PASS (reference partition)
    - Gate 1: PASS (980.2 ms/step, 2.8194x)
    - Gate 2: NOT_BITWISE (0 errors, 0 exact failures, 37/4724 minor diagnostic deviations)
    - Gate 3: PASS (train_loss_last20_canonical bias +0.000277 = +0.088σ vs 3σ = 0.009458; probe_loss_last20 bias +0.000115 = +0.040σ vs 3σ = 0.008624).

---
5.7 hRound 11: 16-Chunk Pipelined `AdamW + NVLink P2P` Overlap (`LLAVA_OVERLAP_STEP=1`) + Fused Triton `bf16` Cross-Entropy + Async `DtoH`/CLIP Overlap + Single-Cat Packing
- Start time: 2026-11-20T03:27:30Z
- End time: 2026-11-20T03:54:20Z
- Motivation:
  - After Round 10 (979.7 ms/step), _zero2_adamw_bf16g_kernel (25.2 ms) and AllGather (20.8 ms) ran back-to-back (46.0 ms serialized), F.cross_entropy(logits.float(), labels) allocated [N_valid, 32000] fp32 buffers on the critical path (2.14 ms), packed_llava_forward waited on synchronous DtoH copies and CPU packing before launching CLIP encode_images, and per-row torch.cat(emb_segs) launched 16 redundant CatArrayBatchedCopy kernels before packed_embeds.
- Changes implemented (llava/train/triton_ops.py, llava/train/opt_patches.py, /submission/switches.json):
  - 16-Chunk Pipelined AdamW + NVLink P2P (LLAVA_OVERLAP_STEP=1): Split triton_zero2_adamw_step into 16 contiguous chunks on the compute stream overlapped via CUDA events with 16 batch_isend_irecv P2P exchanges on an auxiliary stream (45.07 ms -> 33.04 ms standalone, 100% bitwise identical, zero self-copy). Also benchmarked CUDA IPC copy_ (209 ms due to non-P2P staging across process devices) and dist.all_gather(list) (76.5 ms), selecting batch_isend_irecv.
  - Fused Triton bf16 Cross-Entropy (fused_bf16_cross_entropy): Online fp32 logsumexp + backward softmax in registers directly from bf16 logits (2.14 ms -> 0.22 ms, 0.00e+00 fp32 loss diff, 0 [N, V] fp32 temporary allocation).
  - Immediate CLIP Launch Overlapped with Auxiliary-Stream Pinned DtoH + Single-Pass packed_embeds Concat: Queued input_ids/labels/attention_mask DtoH onto a dedicated dtoh_stream, immediately launched 23-layer CLIP encode_images(images) on the default stream at t=0 so CPU packing runs in parallel with CLIP GPU execution, and flattened emb_segs directly into packed_embed_parts for a single torch.cat.
- Verification:
  - time (/tmp/r11/time_full/time_tree.json): 968.5 ms/step (2.8535x speedup vs frozen reference 2763.6 ms/step, 33.04 samples/s, windows [9.867s, 9.502s], 1377.8 W across both 700W GPUs), window_spread = 0.0154, logged_loss_first_step_rel_diff = 0.00087, logged_loss_max_rel_diff = 0.0018, peak_memory_allocated_gib = 114.81, peak_memory_reserved_gib = 119.78, problems = [].
  - Full Check #5 (/tmp/r11/full_check/check.json): PASS (tier N1, speedup = 2.8486, 970.2 ms/step vs 2763.6 ms/step).
    - Gate 0: PASS (reference partition)
    - Gate 1: PASS (970.2 ms/step, 2.8486x)
    - Gate 2: NOT_BITWISE (0 errors, 0 exact failures, 37/4724 minor diagnostic deviations)
    - Gate 3: PASS (train_loss_last20_canonical bias +0.000381 = +0.121σ vs 3σ = 0.009458; probe_loss_last20 bias +0.000093 = +0.032σ vs 3σ = 0.008624).

---
6.6 hRound 13: Step-Boundary Idle-Bubble Elimination + Async `bf16` HtoD + Zero-`DtoH` Sequence Packing (`LLAVA_FAST_STEP_BOUNDARY=1`)
- Start time: 2026-11-20T04:18:50Z
- End time: 2026-11-20T04:34:15Z
- Motivation:
  - Chrome trace timeline inspection (/tmp/r13/profile/detail_tree.r0.json) revealed step-boundary CPU stalls, blocking Trainer._prepare_input HtoD transfers (77.4 MB fp32 images + GPU cast), cudaHostAlloc pinned allocations + dtoh_stream.synchronize() + 5 blocking pageable-to-device .to(device) copies in packed_llava_forward, repeated PreTrainedModel.num_parameters / DeepSpeedEngine.zero_grad / DeepSpeedEngine.train(True) / CLIPVisionTower parameter walks, and redundant 23-layer frozen CLIP execution on all-zero dummy images in text-only micro-batches.
- Changes implemented (llava/train/opt_patches.py, llava/train/llava_trainer.py, /submission/switches.json):
  - Cast image.to(torch.bfloat16) in LazySupervisedDataset.__getitem__ inside background CPU DataLoader workers (halving /dev/shm IPC, pin_memory, and PCIe HtoD bytes while keeping batch_digest 100% bitwise identical).
  - Overrode LLaVATrainer._prepare_input / _prepare_inputs to use non_blocking=True on pinned tensors (with a 4-slot reference hold) and attach _llava_cpu references on integer/boolean inputs so packed_llava_forward packs on CPU with 0 DtoH copies and 0 stream syncs.
  - Added a 4-slot CUDA-event-guarded pinned HtoD staging ring for packed metadata (all_text_ids, packed_pos_ids, valid_idx, valid_labels, cu_seqlens), cached PreTrainedModel.num_parameters, skipped redundant DeepSpeedEngine.zero_grad / train(True) / CLIPVisionTower parameter walks, and bypassed frozen 23-layer CLIPVisionTower when (ids_cpu == IMAGE_TOKEN_INDEX).any() is False while preserving mm_projector autograd hooks via a [1, 1, 1024] zero feature.
- Verification:
  - time (/tmp/r13/time_2/time_tree.json): 965.1 ms/step (2.8637x vs frozen reference 2763.6 ms/step, window_spread = 0.0097).

---
6.6 hRound 14: Alternating-Layer Balanced ZeRO-2 Partition + Coalesced `ReduceScatter` (`LLAVA_REDUCE_SCATTER=1`)
- Start time: 2026-11-20T04:35:00Z
- End time: 2026-11-20T04:47:00Z
- Motivation:
  - Telemetry (/tmp/r13/time_2/power_tree.csv) showed both Hopper GPUs pinned against the 700W hardware TDP power cap (1380.0 W total = 690 W/GPU, throttling SM clocks from 1980 MHz to 1365–1485 MHz), making step time directly proportional to Joules/step. Microbenchmarking 1 GB bf16 NCCL collectives measured ReduceScatter(AVG) at 1.940 ms (515.4 GB/s) vs AllReduce(AVG) at 2.985 ms (335.0 GB/s), with half the NVLink and HBM write traffic.
- Changes implemented (llava/train/opt_patches.py, llava/train/llava_trainer.py, /submission/switches.json):
  - Added reorder_decay_params_for_reduce_scatter ordering bit16_groups[0] into even transformer layers (30, 28, ..., 0, preserving [down, gate, up, o, q, k, v] within-layer order so LLAVA_FUSED_GEMM=1 zero-copy Gate+Up and QKV views remain active on all 32 layers) + embed_tokens + mm_projector.2 on Rank 0, and lm_head + odd transformer layers (31, 29, ..., 1) + mm_projector.0 on Rank 1.
  - Built _ensure_all_rank_frags and _coalesce_1d in fast_allreduce_and_copy so every backward bucket sorts Rank 0 and Rank 1 fragments deterministically by destination partition offset, coalesces adjacent storage views (dw_gu, dw_qkv, and contiguous parts[0] destination ranges), and executes symmetric dist.reduce_scatter_tensor(..., op=dist.ReduceOp.AVG) directly into parts[0] whenever total_r0 == total_r1.
  - Standalone 2-GPU bitwise test (/tmp/r14/verify_rs.py) confirmed max_grad_diff = 0.0, max_param_diff = 0.0, max_ea_diff = 0.0.
- Verification:
  - time (/tmp/r14/time_1/time_tree.json): 961.1 ms/step (2.8754x speedup vs frozen reference 2763.6 ms/step, 33.29 samples/s, windows [9.787s, 9.435s]), window_spread = 0.0144, logged_loss_first_step_rel_diff = 0.00087, logged_loss_max_rel_diff = 0.0015, peak_memory_allocated_gib = 115.78, problems = [].
  - check --quick (/tmp/r14/quick_check/check.json): PASS (tier N1, 0 errors, 0 exact failures, exact same 37/4724 diagnostic deviations as Full Check #5 because Rounds 13–14 are 100% bitwise identical to Round 11).

---
6.8 hRound 15: Batched SentencePiece Joint FLOP- & Label-Balanced Intra-Step Micro-Batching (`LLAVA_TRUE_BALANCE=1`)
- Start time: 2026-11-20T04:48:15Z
- End time: 2026-11-20T04:59:00Z
- Motivation:
  - Comparing Rank 0 vs Rank 1 Chrome traces revealed Rank 1 spending 271.2 ms/step spinning inside ncclKernel waiting for Rank 0, because upstream LazySupervisedDataset.modality_lengths uses rough whitespace word count without image tokens, leaving 1.316% mean (8.527% max) true FLOP imbalance and 7.94% (23.36% max) supervised label-count imbalance across timed steps 5..24.
- Changes implemented (llava/train/llava_trainer.py, /submission/switches.json):
  - Added _compute_dataset_true_costs executing a single batched C++ sp.EncodeAsIds(all_turns) call (148 ms once at startup for all 26,618 turns of timing.json) to estimate each sample's packed sequence length L_i = min(model_max_length, 42 + 575 * has_img + sum_turns) and supervised GPT label count est_lab_i, with quadratic attention FLOP cost C_i = L_i + 0.055 * L_i^2 / 1000.
  - Added _balance_megabatch_2way inside LengthGroupedSampler.__iter__ preserving upstream's exact torch.randperm RNG calls and exact 32-sample per-step multisets, while repartitioning each 32-sample megabatch into two 16-sample micro-batches via greedy + O(1)-delta 2-opt swaps minimizing |C_0 - C_1| / (C_0 + C_1) + 0.15 * |L_0 - L_1| / (L_0 + L_1). Across timed steps 5..24, true FLOP max-over-mean imbalance dropped 1.316% -> 0.029% (max 8.527% -> 0.093%) and label skew dropped 7.943% -> 0.522%.
- Verification:
  - time (/tmp/r15/time_1/time_tree.json): 956.5 ms/step (2.8892x speedup vs frozen reference 2763.6 ms/step, 33.45 samples/s, windows [9.772s, 9.359s]), window_spread = 0.0209, peak_memory_allocated_gib = 115.06, problems = [].
  - Full Check #6 (/tmp/r15/full_check/check.json): PASS (tier N1, speedup = 2.8897, 956.4 ms/step vs 2763.6 ms/step).
    - Gate 0: PASS (every optimizer step trains on the exact reference sample multiset)
    - Gate 1: PASS (956.4 ms/step, 2.8897x, windows [9.752s, 9.375s])
    - Gate 2: NOT_BITWISE (0 errors, 0 exact failures)
    - Gate 3: PASS (train_loss_last20_canonical bias +0.002657 = +0.843σ vs 3σ = 0.009458; probe_loss_last20 bias +0.000232 = +0.081σ vs 3σ = 0.008624).

---
7.1 hRound 16: Zero-Copy Direct-to-`ReduceScatter` `dW` GEMMs (`LLAVA_DIRECT_DW=1`) + Fused CLIP `Bias+Add+LayerNorm` & `Bias+QuickGELU` (`LLAVA_FAST_CLIP_LN=1`)
- Start time: 2026-11-20T05:00:55Z
- End time: 2026-11-20T05:18:20Z
- Motivation:
  - Profile breakdown (/tmp/r13/profile/profile_tree.md) showed CatArrayBatchedCopy<bf16> taking 15.2 ms/step (25.9 GB HBM read/write during 700W-capped backward GEMMs) to flatten per-parameter .grad tensors into reduction buckets, plus FillFunctor<bf16> (1.1 ms) + vectorized_layer_norm_kernel (1.2 ms) + residual adds across CLIP's 23 layers (159 extra kernel launches per step).
- Changes implemented (llava/train/triton_ops.py, llava/train/opt_patches.py, /submission/switches.json):
  - Zero-Copy Direct-to-ReduceScatter dW GEMMs (LLAVA_DIRECT_DW=1): Added a 3-slot CUDA-event-guarded pair buffer ring ([2 * L_lin] = 404.75M bf16 elements) and _DirectLinearFn + out_dw support in _FusedGateUpSwiGLUFn / _FusedQKVRoPEFn. During backward, all 4 dW GEMMs (down_proj, gate+up, o_proj, q+k+v) of even layer 2p write directly into pair_buf[slot][0 : L_lin] and odd layer 2p+1 write directly into pair_buf[slot][L_lin : 2*L_lin], while 548 KB of RMSNorm/bias grads are deferred to fast_epilogue. Each 14-parameter 2-layer pair flushes via dist.reduce_scatter_tensor(parts[0][dst], pair_buf[slot], op=AVG) with 0 param.grad allocations, 0 CatArrayBatchedCopy, and 0 rs_out copies (max_grad_diff = 0.0, max_param_diff = 0.0 verified in /tmp/r16/verify_r16.py).
  - Fused CLIP no_grad Kernels (LLAVA_FAST_CLIP_LN=1): Added _bias_add_layer_norm_fwd_kernel and _bias_quick_gelu_fwd_kernel fusing linear bias epilogues, residual additions, cross-layer LayerNorms, and QuickGELU in-place across CLIP's 23 layers (159 kernel launches and 69 FillFunctor bias broadcasts eliminated per step).
- Verification:
  - time (/tmp/r16/time_1/time_tree.json): 944.1 ms/step (2.9271x speedup vs frozen reference 2763.6 ms/step, 33.89 samples/s, windows [9.679s, 9.204s]), window_spread = 0.0281, logged_loss_first_step_rel_diff = 0.00058, peak_memory_allocated_gib = 119.57, problems = [].
  - Full Check #7 (/tmp/r16/full_check/check.json): PASS (tier N1, speedup = 2.9274, 944.0 ms/step vs 2763.6 ms/step).
    - Gate 0: PASS (exact reference per-step sample multisets)
    - Gate 1: PASS (944.0 ms/step, 2.9274x, windows [9.668s, 9.213s])
    - Gate 2: NOT_BITWISE (0 errors, 0 exact failures)
    - Gate 3: PASS (train_loss_last20_canonical bias +0.003035 = +0.963σ vs 3σ = 0.009458; probe_loss_last20 bias -0.000018 = -0.006σ vs 3σ = 0.008624).

---
7.8 hRound 18: Persistent Grad/Pair Buffers (`LLAVA_PERSIST_BUFS=1`) + Async `DataLoaderShard` HtoD + Zero-Sync `DeepSpeedEngine.backward` + CLIP-Overlapped CPU Packing
- Start time: 2026-11-20T05:30:00Z
- End time: 2026-11-20T06:00:00Z
- Motivation:
  - Detailed 2-step Chrome trace (/tmp/r18/profile/detail_tree.r0.json) of Round 16 (33088ee) exposed four distinct CPU/GPU bubbles:
    1. DeepSpeedEngine.backward (engine.py:1935) executed self.losses += loss.mean().item() before self.optimizer.backward(loss), blocking the Python CPU thread for 230–250 ms/step (aten::item = 249.8 ms/step) until 100% of forward GPU kernels drained, exposing a 5.1–6.6 ms fwd -> bwd GPU idle gap while autograd and cuBLAS initialized backward.
    2. Clearing _llava_flat_grad_part (6.76 GiB) and _llava_dw_pair_ring (2.43 GiB) every step triggered 7.0 ms + 3.0 ms expandable_segments:True cuMemCreate/cuMemMap OS stalls during peak-sequence steps (including a 172 ms stall on timed Step 14) plus 2.7 ms/step of redundant _update_model_bit16_weights parameter re-linking.
    3. accelerate.data_loader.DataLoaderShard.__iter__ called send_to_device(current_batch, self.device) (non_blocking=False) *before* LLaVATrainer._prepare_input, blocking CPU on 38.7 MB image transfers, bypassing _llava_cpu attachment (forcing dtoh_stream.synchronize()), and preventing the frozen-CLIP bypass on text-only steps (Steps 11 and 14).
    4. packed_llava_forward ran its per-row CPU sequence/label/position loop *after* encode_images + embed_tokens, leaving a 1.84 ms GPU idle gap before Llama Layer 0.
- Changes implemented (llava/train/opt_patches.py, /submission/switches.json):
  - Persistent Buffers (LLAVA_PERSIST_BUFS=1): Kept _llava_flat_grad_part (6.76 GiB), _llava_part_views, _llava_param_frag_map, and the 3-slot _llava_dw_pair_ring (2.43 GiB) persistent across steps, and cached _llava_linked_flat_ptrs to skip redundant _update_model_bit16_weights calls once linked.
  - Zero-Sync fast_ds_backward: Replaced DeepSpeedEngine.backward on the standard ZeRO-2 bf16 path so self.optimizer.backward(loss) launches immediately at t = 50 ms while forward is executing on the GPU (self-paced to <= 2 buckets ahead by fast_allreduce_and_copy's 2-slot event ring), deferring self.losses += loss.detach().mean().item() until *after* optimizer.backward completes (0.005 ms, zero stream stall).
  - DataLoaderShard Async Pinned HtoD + _llava_cpu Attachment: Patched accelerate.data_loader.send_to_device with a 4-slot pinned-reference ring (_pinned_hold), non_blocking=t.is_pinned(), and out._llava_cpu = t, eliminating blocking HtoD transfers, eliminating dtoh_stream, and activating the frozen-CLIP bypass on text-only steps (-16 ms on Step 11, -172 ms combined on Step 14).
  - CLIP-Overlapped CPU Packing + Single-Buffer Pinned HtoD: Moved all per-row CPU label/position/offset construction and coalesced all_long_gpu (text_ids + pos_ids + valid_idx + valid_labels) async HtoD immediately after launching encode_images(images), hiding CPU packing completely underneath CLIP's 14.5 ms GPU execution.
  - *(Ablated & reverted inside Round 18)*: Tested BLOCK=2048, num_warps=8 + eviction_policy="evict_first" in _zero2_adamw_bf16g_kernel (/tmp/r18/time_1 & /tmp/r18/profile_cand), which saturated SM warp slots and starved concurrent ag_stream ncclKernel_SendRecv P2P overlap (+4.03 ms/step: 35.37 -> 39.40 ms); reverted to BLOCK=1024, num_warps=4 (94% P2P overlap).
- Verification:
  - time (/tmp/r18/time_2/time_tree.json): 933.8 ms/step (2.9594x speedup vs frozen reference 2763.6 ms/step, 34.27 samples/s, windows [9.471s, 9.205s]), window_spread = 0.0061 (down from 0.0281), peak_memory_allocated_gib = 118.81, peak_memory_reserved_gib = 120.50, problems = [].
  - check --quick (/tmp/r18/quick_check/check.json): PASS (tier N1, 0 errors, 0 exact failures; Gate 2 summary 100% identical to Round 16 Full Check #7 since zero math/kernel numerics changed).

---
8.6 hRound 19: Precompiled `llava_cuda_ipc` Extension + Single-Kernel Fused ZeRO-2 `AdamW + Direct NVLink-18 IPC Dual-Store` (`LLAVA_IPC_ADAMW=1`)
- Start time: 2026-11-20T06:01:30Z
- End time: 2026-11-20T06:57:30Z
- Motivation:
  - Round 19 baseline profile (/tmp/r19/profile/profile_tree.md) showed fast_step taking ~35.5 ms/step (_zero2_adamw_bf16g_kernel 33.2 ms + 16-chunk ag_stream ncclKernel_SendRecv 25.3 ms), where ncclKernel_SendRecv re-read 6.76 GiB of updated bf16 weights from local HBM, bounced through NCCL's IPC staging buffer (+13.52 GiB extra HBM write+read), and competed for SM warps (preventing num_warps=8 in _zero2_adamw_bf16g_kernel).
  - Note: PyTorch expandable_segments:True (cuMemCreate) tensors reject cudaIpcGetMemHandle (cudaErrorInvalidValue), which is why naive IPC failed unless backed by cudaMalloc.
- Changes implemented (/opt/candidate-env llava_cuda_ipc, llava/train/triton_ops.py, llava/train/opt_patches.py, /submission/switches.json):
  - Built and installed precompiled C++/CUDA extension llava_cuda_ipc-0.1.0 into /opt/candidate-env (alloc_cuda_malloc_bf16, get_ipc_mem_handle, open_ipc_mem_handle, close_ipc_mem_handle; zero runtime JIT compilation).
  - Hooked DeepSpeedZeroOptimizer.initialize_gradient_partitioning_data_structures (before create_reduce_and_remove_grad_hooks creates param_tmp views) to replace bit16_groups_flat[0] (7.26B bf16 elements = 13.52 GiB) with a cudaMalloc-backed tensor, immediately freeing the original 13.52 GiB CUDACachingAllocator buffer (peak_memory_allocated_gib dropped 118.81 -> 106.22 GiB) and mapping the peer GPU's bit16_groups_flat[0] directly into local virtual address space via cudaIpcOpenMemHandle(..., cudaIpcMemLazyEnablePeerAccess).
  - Added _zero2_adamw_bf16g_ipc_kernel (BLOCK=1024, num_warps=8) in triton_ops.py that computes the fp32 AdamW update once in registers and simultaneously stores p.to(bf16) to local my_part HBM AND directly over NVLink-18 to the peer GPU's peer_part HBM (-27.0 GiB HBM traffic eliminated, zero ag_stream, zero ncclKernel_SendRecv; 35.45 -> 26.13 ms at 700W in /tmp/r19/bench_ipc_full.py, 0.0e+00 bitwise diff).
- Verification:
  - time (/tmp/r19/time_2/time_tree.json): 926.8 ms/step (2.9818x speedup vs frozen reference 2763.6 ms/step, windows [9.403s, 9.133s]), window_spread = 0.0066, peak_memory_allocated_gib = 106.22, problems = [].
  - Full Check #8 (/tmp/r19/full_check/check.json): PASS (tier N1, speedup = 2.9846, 926.0 ms/step vs 2763.6 ms/step).
    - Gate 0: PASS (every optimizer step trains on the exact reference sample multiset)
    - Gate 1: PASS (926.0 ms/step, 2.9846x, windows [9.381s, 9.138s], window_spread = 0.0040, 34.56 samples/s, peak_memory_allocated_gib = 106.22)
    - Gate 2: NOT_BITWISE (0 errors, 0 exact failures)
    - Gate 3: PASS (train_loss_last20_canonical bias +0.002718 = +0.862σ vs 3σ = 0.009458; probe_loss_last20 bias +0.000374 = +0.130σ vs 3σ = 0.008624).

---
9.2 hRound 20: Custom `sm_90` `uint4` CUDA `QkRoPE` + Single-Kernel Multimodal Embed Gather/Scatter + Zero-Padding Asymmetric `Reduce` + Non-Blocking `fast_step` (`LLAVA_FAST_R20=1`)
- Start time: 2026-11-20T07:01:50Z
- End time: 2026-11-20T07:31:30Z
- Motivation:
  - Round 20 baseline profile (/tmp/r20/profile/detail_tree.r0.json) revealed four critical-path inefficiencies:
    1. packed_llava_forward indexed image_features[s_idx] 16 times, creating 16 SelectBackward0 autograd nodes that executed 31 serial [16, 576, 4096] (75.5 MB) FillFunctor + CUDAFunctor_add kernels (2.28 ms/step) at the backward tail right before fast_epilogue.
    2. Asymmetric non-layer buckets (lm_head 262 MB on Rank 1 at backward start; embed_tokens + mm_projector.2 296 MB on Rank 0 vs mm_projector.0 8.4 MB on Rank 1 at backward end) allocated 524–591 MB rs_in buffers, zero-filled 262–287 MB of padding, and ran ReduceScatter on 2x padded buffers.
    3. Triton _qk_rope_kernel (8.78 ms/step) issued strided 2D loads with 128-byte holes across Q and K heads (7.90 ms/step with uint4-vectorized SM90 CUDA C++).
    4. DeepSpeed self.timers(...).start()/stop() inside fast_step called torch.cuda.synchronize() 6 times per step (20.4 ms CPU stall) even when wall_clock_breakdown: false.
- Changes implemented (/opt/candidate-env llava_cuda_ipc-0.2.0, llava/train/triton_ops.py, llava/train/opt_patches.py, /submission/switches.json):
  - Extended llava_cuda_ipc (0.2.0) with sm_90 uint4-vectorized qk_rope_inplace_bf16 (0.0 bitwise diff fwd+bwd), pack_mm_embeds_fwd_bf16, and pack_mm_embeds_bwd_bf16.
  - Added _PackMultimodalEmbedsFn and vectorized CPU dst_src_map/text_bwd_map/img_bwd_map construction inside htod_entry[1] pinned memory (overlapped under CLIP GPU execution), replacing torch.split + 48-way torch.cat in forward and replacing all 31 serial [16, 576, 4096] backward kernels with two 0.04 ms uint4 gather kernels (0.0 bitwise diff).
  - Used zero-padding per-side dist.reduce(op=AVG) in fast_allreduce_and_copy whenever min(total_r0, total_r1) * 4 < half_cap (0.0 bitwise diff), and skipped self.timers cuda.synchronize() calls in fast_step when wall_clock_breakdown is disabled.
- Verification:
  - time (/tmp/r20/time_1/time_tree.json): 922.8 ms/step (2.9949x speedup vs frozen reference 2763.6 ms/step, window_spread = 0.0054), peak_memory_allocated_gib = 106.22, problems = [].
  - check --quick (/tmp/r20/quick_check/check.json): PASS (tier N1, 0 errors, 0 exact failures; all R20 kernels verified 0.0 bitwise diff vs R19).

---
↑ LLaVA