Gemini 4 Neon 1.95×

Harness: Antigravity · switches: SLIME_OPT_SKIP_DEAD_REF=1 SLIME_OPT_REUSE_OPD_LOGPROBS=1 SLIME_OPT_SKIP_DEAD_ENTROPY=1 SLIME_OPT_RECOMPUTE=none SLIME_OPT_GPU_OPTIMIZER=1 SLIME_OPT_KEEP_OPT_ON_GPU=1 SLIME_OPT_FAST_SLEEP=1 SLIME_OPT_SKIP_DEFAULT_PAUSE=1 SLIME_OPT_SHARD_GDN=1 OPD_TEACHER_SERVER_ARGS=--chunked-prefill-size 16384 --mem-fraction-static 0.15 --disable-radix-cache --disable-cuda-graph --enable-layernorm-sp SGLANG_OPT_TP_LOCAL_INPUT_LOGPROBS=1 SGLANG_OPT_QWEN35_LAYERNORM_SP=1 SLIME_OPT_POOLED_TEACHER_HTTP=1 SLIME_OPT_TRIM_TEACHER_LOGPROB_START=1 SGLANG_OPT_NO_SAMPLER_SYNC=1 SGLANG_OPT_FUSED_SAMPLER=1 SGLANG_OPT_CUDA_FUSED_GDN_IN_PROJ=1 SLIME_OPT_STUDENT_DISABLE_RADIX=1 SLIME_OPT_STUDENT_CUDA_GRAPH_MAX_BS=48 SLIME_OPT_STUDENT_DISABLE_PREFILL_CG=1 SLIME_OPT_FUSED_LOGPROB=1 SLIME_OPT_FAST_UPDATE_WEIGHTS=1

Judged
1.95×
Tier
N1
Self-best
2.00×
Rounds
7
Hours
10.0
API cost
$62.2
Input tokens · 96.5% cached
195 M
Output tokens
0.9 M
Requests
671
Candidate, three windows (s)
78.8 / 80.3 / 78.1
Rollout side
1.40×
Teacher side
1.33×
Train side
3.18×
Per-step sampler sync
✓ (round 6; same round swapped in a Triton fused Gumbel-Max sampler and turned off the student radix cache; rollout 1.40×)
Train-side main levers
✓ skip zero-coefficient reference forward and entropy, OPD reuses training-forward logprobs (round 2, 1.35×); no recompute, optimizer moved from CPU offload to fused AdamW on GPU, optimizer state kept in GPU memory during sleep, NCCL comm groups not rebuilt (round 3, 2.11×); GDN split 4-way by head in Ulysses all-to-all layout with forward bitwise identical, default memory segment not swapped out during sleep (sleep+wake 3.1→0.38 s) (round 4, 3.08×); BF16 Triton vocab-parallel logprob, 4 GB weight-sync buckets (round 7, 3.18×)
Round 7 also packed microbatches by descending length, two samples each; train side measured 4.18× and the three-side check passed (projected overall 2.00×); train-only memory already at 105–109 GB, held back pending a full-loop check with the teacher; the log ends there, not in the submission
Teacher-side changes
✓ teacher input logprobs computed locally per GPU (BF16 lm_head + logsumexp + two small all-reduces), logprobs only for the response part, LayerNorm sequence parallel on the teacher, symmetric memory fusing TP comm into the GEMMs, chunk 16384, radix cache and CUDA graph off, static memory fraction 0.15 (teacher memory 39.5→22.6 GiB), pooled HTTP connections; teacher side 1.33× (round 5)
Raw work log8 sections
1.1 hRound 1: Baseline Profiling (Unchanged Reference)
- Start: 2026-11-19 18:03 UTC
- End: 2026-11-19 19:15 UTC
- Hardware: 4x Hopper (Hopper SM90, 132 SMs, 141 GB HBM3e, NV18 NVLink interconnect, 700W TDP), 192 CPU threads (2x Xeon 8558), 2 TiB RAM.
- Frozen Reference Timing (task/timing_ref.json):
  - Full step: 153.815 s (spread 3.76%)
  - Rollout: 75.772 s (49.26% of step; includes teacher_tail_s = 16.391 s, so student generation ~59.38 s)
  - Train: 72.872 s (47.38% of step; spread 6.88%)
  - Teacher standalone: 18.132 s (10.66% of step on critical path)
  - Inter-stage (weight sync + offload/onload): ~5.17 s (3.36% of step)
- Fixture lengths: 1073/1152 samples (93.1%) hit the 8192-token cap; mean prompt ~165 tokens, mean response ~8076 tokens.

### Profile Findings

#### 1. Teacher Profile (/tmp/r1/profile_teacher, wall=258s)
- Window 9202 ms (64 prefill chunks of 4096 tokens), GPU busy 92.5% (8512 ms).
- Top hotspots:
  1. GEMMs (nvjet_sm90_tst_*): 50.9% (4334 ms) — compute/roofline baseline.
  2. Missed FlashInfer AllReduce Fusion -> NCCL RING_LL + separate RMSNorm [Kind 1: missed fast path]:
     - ncclDevKernel_AllReduce_Sum_bf16_RING_LL (21.9%, 1863 ms, 24 blocks = 18% SM cov) + FusedAddRMSNormKernel (4.0%, 339 ms) = 25.9%.
     - Root cause: FUSE_ALLREDUCE_MAX_BATCH_SIZE = 2048 in sglang/srt/layers/layer_boundary/residual/add_norm.py:139, while teacher uses --chunked-prefill-size 4096 -> misses fusion on every full chunk! Also NCCL_CUMEM_ENABLE=0 disables NVLS.
  3. Full-vocab Logits AllGather + Cast + Logsumexp [Kind 3: algorithmic/rewrite]:
     - ncclDevKernel_AllGather_RING_LL (3.6%, 309 ms) + direct_copy permute/cast fp32 (4.1%, 353 ms) + vectorized_gather (1.6%, 137 ms) + _row_logsumexp_kernel (0.7%, 59 ms) = 10.0% (~858 ms).
     - Root cause: gathers full [2048, 248320] logits across TP=4 and casts to fp32 just to extract 1 target token logprob per row. Replaceable with TP-local vocab-parallel logprobs (32 KB allreduce).
  4. GDN Prefill & Attention: FullyFusedDeltaRule (3.1%, 24 blocks under-filled) + CPDeltaRule* (2.0%) + FlashAttnFwdSm90 (2.3%) + repeated small kernel chains (~3.5%).
  5. Host/Client: on_policy_distillation.py creates a fresh aiohttp.ClientSession per sample; max_mamba_cache_size=280 caps max_running_requests=56 < 64.

#### 2. Train Profile (/tmp/r1/profile_train, wall=2710s)
- Unprofiled step 6 breakdown (perf 6: 75.37 s total; peak GPU used only 36.9 GB / 139.8 GB!):
  1. perf/ref_log_probs_time: 11.05 s (14.7%) [Kind 2: dead config work] — --use-kl-loss --kl-loss-coef 0.00 still instantiates ref model, swaps weights, and runs a full 64-microbatch forward pass whose result is multiplied by 0.00.
  2. perf/log_probs_time: 9.99 s (13.3%) [Kind 3: redundant forward pass] — can_reuse_log_probs_in_loss is False when use_opd=True, even though len(num_microbatches)==1 and normalize_advantages=False, so OPD reverse KL & advantages can be computed directly from the training forward pass's log_probs.
  3. perf/actor_train_time: 46.20 s (61.3%) (~40.0 s fwd+recomp+bwd + ~6.2 s CPU-offloaded optimizer):
     - Full activation recomputation (--recompute-granularity full): ~10 s extra forward pass despite ~67 GB free GPU memory even with teacher resident!
     - 4x duplicated GatedDeltaNet compute (hf_attention.py + qwen3_5.py) [Kind 3]: 24/32 layers gather full sequence across TP=2 x CP=2 (AllGather 19.8%, ReduceScatter 6.9% = 26.7% of GPU kernel time!) and run unsharded GDN GEMMs + conv1d + FLA chunk GDN duplicated 4x across all 4 GPUs! Head-sharding GDN across all 4 ranks cuts 75% of GDN compute while keeping identical replicated parameter names/shapes/dtypes.
     - CPU-offloaded HybridDeviceOptimizer: ~6.2 s/step on CPU; HybridDeviceOptimizer natively supports offload_fraction=0.0 (GPU FusedAdam) with identical state schema.
     - Dead entropy & unfused ops: with_entropy=True despite entropy_coef=0.00; unfused Qwen3NextRMSNorm (pow+mean = ~710 ms); _VocabParallelLogProbEntropy chunked eager softmax (~2.5 s).
  4. perf/sleep_time (5.30 s) + perf/wake_up_time (1.53 s) + backup("actor") (~0.8 s) = ~7.6 s (10.1%) [Kind 2: offload/NCCL teardown overhead] — destroys and recreates ALL NCCL process groups every step + gc.collect() + _host_emptyCache() + 10.5 GB CPU<->GPU weight copies.

#### 3. Rollout Profile (/tmp/r1/profile_rollout, wall=466s)
- Unprofiled rollout 0 (perf 0: 79.55 s; e2e_latency/max 62.61 s; median decode 143 tok/s = 6.99 ms/step; pre-contention 5041 tok/s = 6.35 ms/step).
- Profiled 200 decode steps: window 2203.9 ms, GPU busy 44.9% (990.5 ms -> 5.00 ms/step actual GPU kernels).
- Top hotspots:
  1. Host/Scheduler gaps & GPU idle (~1.35–2.25 ms/step unprofiled, ~30% of decode step) [Kind 2/3]: pop_and_process -> stream_output -> ingest_requests/broadcast_pyobj -> prepare_for_decode -> set_mamba_track_indices_from_reqs -> decode_cuda_graph_runner.load_batch run every single token (num_continuous_decode_steps=1, scheduler_recv_interval=1, uses_mamba_radix_cache=True with 0.0% prefix cache hit rate!).
  2. Student-Teacher GPU contention: when early samples finish (~6112 tokens) and hit the colocated TP=4 teacher server, student decode throughput drops 32–50% (4634 -> 3159 -> 1688 tok/s).
  3. Missed fused in_proj_ba GEMM [Kind 1]: nvjet_sm90_tst_64x32... (in_proj_ba, 3 blocks = 2% SM cov, 61.3 ms = 5.7% of GPU decode time) running separately from in_proj_qkvz.
  4. Decode AllReduce Fusion: allreduce_fusion_kernel_oneshot_lamport (14.2%, 154.3 ms, p90 skew 129.9 us).
  5. GDN Decode: fused_recurrent_gated_delta_rule_packed_decode_kernel (8.9%, 96.5 ms) + conv1d (1.3%) + norm (1.0%).
  6. Decode GEMMs: 43.2% of GPU time (gate_up_proj 19.5%, in_proj_qkvz 9.6%, down_proj 9.2%, out_proj 4.9%), running at ~61% of HBM3e peak (96/132 SMs).
  7. Sampling + Logprobs: lm_head (4.5%) + _all_gather_kernel_inner (1.2%, 4 blocks) + cunn_SoftMaxForward (1.4%, 32 blocks) + eager clamp/div/log/copy/argmax (2.6%) = 9.7%.

### Fast-Path Inventory (Initial)
- sglang FlashInfer AllReduce Fusion (sglang/srt/layers/layer_boundary/residual/add_norm.py:142): enabled on SM90 for Qwen3.5, guarded by batch_size <= FUSE_ALLREDUCE_MAX_BATCH_SIZE (2048) — silently falls back to NCCL RING_LL + separate RMSNorm on teacher 4096-token chunks.
- sglang Fused QKVZ+BA Input Projection (sglang/srt/models/qwen3_5.py:632,795): merges in_proj_qkvz + in_proj_ba for seq_len <= 1024, investigate why missed in rollout decode.
- sglang FlashInfer GDN (sglang/srt/layers/attention/linear/kernels/gdn_flashinfer.py): active for prefill on SM90; decode defaults to TritonGDNKernel (packed_decode=True).
- slime can_reuse_log_probs_in_loss (slime/backends/megatron_utils/actor.py:488): guarded by not self.args.use_opd -> silently forces full extra actor forward pass.
- Megatron HybridDeviceOptimizer (Megatron-LM/megatron/core/optimizer/cpu_offloading/hybrid_optimizer.py): supports offload_fraction in [0.0, 1.0], defaults to 1.0 when --optimizer-cpu-offload is passed.

---
1.6 hRound 2: Train Side — Eliminate Dead & Redundant Forward Passes (Ref Forward, Actor LogProbs Forward, Dead Entropy)
- Start: 2026-11-19 19:16 UTC
- End: 2026-11-19 19:43 UTC
- Hotspot targeted: From Round 1 train profile: ref_log_probs (11.05s, 14.7% — dead because --kl-loss-coef 0.00), log_probs (9.99s, 13.3% — redundant single-step OPD forward pass), and entropy calculation in policy_loss_function (dead because --entropy-coef 0.00).
- Changes (slime/slime/backends/megatron_utils/actor.py, loss.py):
  - SLIME_OPT_SKIP_DEAD_REF=1: Skip loading/running ref model when kl_coef == 0 and (not use_kl_loss or kl_loss_coef == 0), and emit kl_loss=0.0 in reported_loss; also guard _switch_model("actor") when already active.
  - SLIME_OPT_REUSE_OPD_LOGPROBS=1: Enable can_reuse_log_probs_in_loss for single-step sglang OPD when not normalize_advantages and compute reverse_kl = old_log_probs - teacher_log_probs and OPD advantages directly inside policy_loss_function using training-forward log_probs.detach().
  - SLIME_OPT_SKIP_DEAD_ENTROPY=1: Pass with_entropy=False to get_log_probs_and_entropy when entropy_coef == 0.0, reporting entropy_loss=0.0.
- Verification (/tmp/r2/check/check.json):
  - Status: PASS (tier N1, train side judged)
  - Train windows: [53.968, 55.029, 52.535] (mean 53.844 s vs frozen ref 72.872 s) -> train speedup 1.3539x, projected step speedup 1.1414x (bar 1.1376x)
  - Numerics: update_direction_cos = 0.99301 (ref noise 0.9913, min 0.9566), loss_mean d = -5.67e-6 (tol 3.75e-5), grad_norm_first d = -1.50e-4 (tol 1.65e-3), mismatch ratio = 1.0000.
- Committed: slime branch opt; promoted switches to /submission/switches.json.

---
2.4 hRound 3 — Train: No Recompute + GPU Fused AdamW + Fast TMS Sleep/Wake (Persistent NCCL)
- Hypothesis: After Round 2 (53.84s), remaining train time was dominated by full activation recomputation (~10s), CPU-offloaded HybridDeviceOptimizer (~6.3s), and sleep()/wake_up() destroying/reloading NCCL process groups + gc.collect()/_host_emptyCache() (~6.4s in train, ~10s+ in full loop). Moving HybridDeviceOptimizer to GPU torch.optim.AdamW(fused=True) (preserving exact 188-entry sub_optimizers schema via lightweight _GpuSubOptimizerView), placing optimizer tensors in TMS "optimizer" tag so sleep() doesn't copy 29.5 GiB via slow pageable TMS backup, keeping NCCL communicators outside TMS tracking (eliminating destroy_process_groups/reload_process_groups), and disabling full recomputation should cut train time nearly in half.
- Changes (behind env switches, default OFF):
  - slime (a03ecdd3):
    - slime/backends/megatron_utils/model_provider.py: SLIME_OPT_RECOMPUTE (none, block:N, selective).
    - slime/backends/megatron_utils/model.py: SLIME_OPT_GPU_OPTIMIZER=1 sets optimizer_offload_fraction=0.0, use_torch_optimizer_for_cpu_offload=True.
    - slime/backends/megatron_utils/actor.py: SLIME_OPT_FAST_SLEEP=1 (keeps NCCL outside TMS via disable() warmup + fast C-level tms_set_interesting_region collective wrappers excluding isend/irecv for P2POp identity, skips destroy_process_groups/reload_process_groups in sleep/wake_up/update_weights, skips gc.collect()/_host_emptyCache()) and SLIME_OPT_KEEP_OPT_ON_GPU=1 (selective TMS pause/resume of param_buffer, grad_buffer, default, leaving optimizer tag on GPU). Added peak GPU memory logging on rank 0.
  - Megatron-LM (9d7cdd3):
    - megatron/core/optimizer/__init__.py: honor use_torch_optimizer_for_cpu_offload under SLIME_OPT_GPU_OPTIMIZER=1 (uses CUDA fused torch.optim.AdamW, matching CPU AdamW to cos=0.9999997 in ~21ms).
    - megatron/core/optimizer/cpu_offloading/hybrid_optimizer.py: _GpuSubOptimizerView preserving exact c0.s0.p0..c0.s187.p0 layout; _optimizer_tms_region tagging fp32 masters & moments under "optimizer"; fixed _d2h_stream race; fused torch._foreach_copy_ writeback.
    - megatron/core/optimizer/distrib_optimizer.py: freed throwaway pre-shard HybridDeviceOptimizer before constructing sharded one (reclaiming 20.8 GiB VRAM).
- Result (/tmp/r3/check2/check.json):
  - Status: PASS, Tier: N1 (exact: ok, update_direction_cos=0.99419 vs min 0.9566 / ref noise 0.9913, update_norm d=-8.15e-5 tol 1.20e-3, exp_avg_sq_norm d=+3.47e-5 tol 4.36e-4, loss_mean d=+1.64e-5 tol 3.75e-5, grad_norm_first d=-1.70e-4 tol 1.65e-3, mismatch ratio=1.0000).
  - Timing: train windows [34.761, 34.743, 34.126] (mean 34.543s vs frozen ref 72.872s) -> train speedup 2.1097x, projected full-step speedup 1.3319x. (actor_train_time dropped 46.3s -> 30.5s; sleep+wake 6.4s -> 3.1s).
  - Full-loop VRAM finding: With SLIME_OPT_RECOMPUTE=none BEFORE Round 4 (unsharded GDN), peak_alloc=93.53GB, peak_res=95.58GB, post_used=102.20GB. Since resident teacher uses ~41.5GB in full loop (102.2 + 41.5 = 143.7 > 139.81GB), we hold SLIME_OPT_RECOMPUTE=none out of /submission/switches.json until Round 4 shrinks GDN activations by 4x (-22GB -> ~80GB peak, safely <98GB).
  - Note on remaining sleep_time (2.2s): TMS backed up ~2.76 GB/rank of "default" segments via pageable malloc+memcpy after step 0 (vs 0.12s at init). Will eliminate or shrink "default" backup alongside Round 4.

---
5.0 hRound 4 — Train: Ulysses AllToAll 4x Head-Sharded GatedDeltaNet + Skip TMS Default Pause
- Hypothesis: In Qwen3.5-9B, 24 of 32 layers are Qwen3_5GatedDeltaNet (HuggingfaceAttention), which gathers the full sequence across TP×CP=4 ranks and runs the entire layer redundantly 4x (holding 4x activation memory and performing 4x redundant compute + 2x AllGather/ReduceScatter per layer). Replacing replicated GDN with Ulysses-style AllToAll 4x head-sharding (local input_layernorm + local in_proj_* on S/4 tokens -> AllToAllHeadToSeq -> 1/4 causal_conv1d + repeat_interleave(2) + 1/4 chunk_gated_delta_rule + 1/4 rms_norm_gated -> AllToAllSeqToHead -> local out_proj on S/4 tokens, with a single coalesced FP32 TP AllReduce of GDN main_grads once at _finalize_model_grads) cuts GDN compute and saved activations by 4x, cuts communication by 25–75%, eliminates 9,216 per-microbatch weight-grad collectives, AND keeps forward + backward dx 100% bitwise identical to baseline (H_max=0.0 across 8 real layers). Also skip TMS pausing "default" tag (SLIME_OPT_SKIP_DEFAULT_PAUSE=1) to eliminate 2.76 GB pageable TMS backup (sleep+wake 3.1s -> 0.38s).
- Diagnostic lesson (what didn't work first):
  - Round 4a/4b (split-K out_proj + ReduceScatter + merged in_proj_qkvzba + native GVA) ran fast (24.2s) but failed grad_norm_first and update_direction_cos (0.9506 vs min 0.9566). Root cause: Qwen3.5-9B layers L00–L08 have extreme backward sensitivity (~2–17x gradient spikes on specific microbatches even from 1e-4 BF16 cuBLAS split-K / N=32 tiling differences in out_proj / in_proj_a / in_proj_b).
  - Switching to Ulysses AllToAll keeps in_proj_qkv/in_proj_z/out_proj unsplit on S/4 tokens (bitwise 0.0 match), uses _ExactSmallLinear for in_proj_a/in_proj_b (N=32 full-M tiling without saving padded activations), and repeat_interleave(2) on 1/4 heads (bitwise 0.0 in FLA GDN) -> 0.00000000000000000 forward diff (mismatch=1.000000000000000) and update_direction_cos=0.99381 (exceeding reference noise 0.99132!).
- Changes (behind env switches, default OFF):
  - slime (75049ccc):
    - slime/slime_plugins/models/qwen3_5.py: SLIME_OPT_SHARD_GDN=1 (_ExactSmallLinear, _AllToAllHeadToSeq, _AllToAllSeqToHead, _forward_head_sharded).
    - slime/slime/backends/megatron_utils/model.py: coalesced once-per-step FP32 TP all_reduce on _slime_gdn_tp_sum_grad parameters inside _finalize_model_grads.
    - slime/slime/backends/megatron_utils/actor.py: SLIME_OPT_SKIP_DEFAULT_PAUSE=1 (skips TMS pause/resume of "default" tag) and warms up all_to_all_single outside TMS in _warmup_nccl_groups.
  - Megatron-LM (f895809):
    - megatron/core/optimizer/distrib_optimizer.py: clear throwaway pre-shard HDO tensor containers before gc.collect(); torch.cuda.empty_cache() (~10 GiB init reserved reclaimed).
- Verification (/tmp/r4/check3/check.json):
  - Status: PASS, Tier: N1 (exact: ok, mismatch ratio = 1.000000, loss_mean d = +3.56e-6 tol 3.75e-5, grad_norm_first = 0.996486 vs ref 0.996736 (d = -2.50e-4 tol 1.65e-3), update_direction_cos = 0.993811 vs min 0.956603 / ref noise 0.991321, update_norm d = -1.07e-4 tol 1.20e-3, exp_avg_sq_norm d = +8.78e-5 tol 4.36e-4).
  - Timing: train windows [23.440, 23.296, 24.333] (mean 23.690 s vs frozen ref 72.872 s) -> train speedup 3.0774x, projected full-step speedup 1.4702x!
  - Peak VRAM: peak_alloc=77.43 GB, peak_res=84.85 GB, post_used=94.84 GB (flat across all 8 steps; fits with resident teacher 94.84 + 41.5 = 136.34 < 139.81 GB, and Round 5 will free an extra ~14 GiB from teacher static pool).
- Committed: slime (75049ccc), Megatron-LM (f895809); promoted all Round 2+3+4 switches (including SLIME_OPT_RECOMPUTE=none, SLIME_OPT_SKIP_DEFAULT_PAUSE=1, SLIME_OPT_SHARD_GDN=1) to /submission/switches.json.

---
7.2 hRound 5 — Teacher: Qwen3.5 LayerNorm SP (`symm_mem` Fused Collectives) + TP-Local Input Logprobs + Trimmed Start Len + Pooled HTTP + Slim VRAM
- Hypothesis: In the baseline teacher profile (18.132 s), TP=4 NCCL AllReduce took 21.9%, FusedAddRMSNorm took 4.0%, full-vocab lm_head AllGather + permute + FP32 cast + copy took 9.3%, and teacher held 39.5 GiB VRAM (--mem-fraction-static 0.25 + CUDA graphs).
  - Enabling Megatron-style LayerNorm Sequence Parallelism (--enable-layernorm-sp, SGLANG_OPT_QWEN35_LAYERNORM_SP=1) on Qwen3_5ForConditionalGeneration with torch.ops.symm_mem.fused_matmul_reduce_scatter + fused_all_gather_matmul (including multi-weight column_parallel_g_matmul_multi for GDN in_proj_qkvz + in_proj_ba) overlaps TP=4 communication directly with the GEMMs (cutting comm overhead by 63% in microbenchmarks) and shrinks GemmaRMSNorm by 4x.
  - Computing TP-local BF16 lm_head + row_logsumexp + 2 tiny AllReduces (SGLANG_OPT_TP_LOCAL_INPUT_LOGPROBS=1) eliminates the 1.02 GB logits AllGather + 2 GB FP32 cast + 2 GB copy.
  - Trimming logprob_start_len to len(tokens) - response_length - 1 (SLIME_OPT_TRIM_TEACHER_LOGPROB_START=1) avoids computing lm_head on prompt tokens; pooling aiohttp.ClientSession per event loop (SLIME_OPT_POOLED_TEACHER_HTTP=1) removes per-request TCP setup.
  - Passing --chunked-prefill-size 16384 --mem-fraction-static 0.15 --disable-radix-cache --disable-cuda-graph --enable-layernorm-sp boosts prefill throughput to ~39k tok/s AND cuts teacher VRAM from 39.5 GiB -> 22.6 GiB (17 GiB freed per GPU for full-loop colocated training!).
- Diagnostic lesson (what didn't work):
  - Raising FlashInfer trtllm AR fusion cap (FUSE_ALLREDUCE_MAX_BATCH_SIZE) to 4096/8192 was slower than plain NCCL+RMSNorm (288/561 us vs 250/470 us); reverted add_norm.py and layernorm.py and replaced with symm_mem fused LayerNorm SP (+185.7 us vs +501.7 us NCCL at M=8192).
- Changes (behind env switches, default OFF):
  - sglang (bb90a13): layernorm_sp.py (SGLANG_OPT_QWEN35_LAYERNORM_SP=1 allowlist + column_parallel_g_matmul_multi), qwen3_5.py (GDN multi-weight SP input proj + seq_len = qkv.shape[0] fix in forward_prepare_cuda_fused), logits_processor.py (SGLANG_OPT_TP_LOCAL_INPUT_LOGPROBS=1).
  - slime (e1670b30): slime/rollout/on_policy_distillation.py (SLIME_OPT_POOLED_TEACHER_HTTP=1, SLIME_OPT_TRIM_TEACHER_LOGPROB_START=1).
- Timing sweep (bench.py time --side teacher):
  - 5a (chunk 4096 + trtllm AR): 16.452 s (1.1021x)
  - 5b (chunk 8192 + trtllm AR): 15.787 s (1.1485x)
  - 5c (chunk 8192 + LayerNorm SP): 14.383 s (1.2606x)
  - 5d (chunk 16384 + LayerNorm SP): 13.643 s (1.3291x), 22.6 GiB VRAM, corr=0.99977 vs ref.

---
7.2 hRound 6 — Rollout: Eliminate 99.4% Decode Host-Sync Bug + Triton Fused Gumbel-Max Sampler + CUDA Fused GDN `in_proj` + Disable Student Radix Cache
- Hypothesis: Baseline rollout (75.772 s) had 55.1% GPU idle time during decode because slime's sglang patch in sampler.py:321 called bool(sampling_info.return_top_p_log_probs.any().item()) on every decode step, causing 99.4% (797 ms / 802 ms) of all main-thread cudaStreamSynchronize stalls and breaking event_loop_overlap (~4.25 ms CPU stall/step). Additionally, sampling ran 9 separate [32, 248320] FP32 kernels (~250 us/step), GDN ran in_proj_ba (N=32, 3 blocks) separately on alt_stream, and student radix cache tracked 112 mamba states per 32 requests.
- Changes (behind env switches, default OFF):
  - sglang (bb90a13):
    - sampling_batch_info.py + sampler.py: SGLANG_OPT_NO_SAMPLER_SYNC=1 (CPU bool need_return_top_p_log_probs mirrors need_return_top_p_token_ids, eliminating the per-step .any().item() sync).
    - sampler.py: SGLANG_OPT_FUSED_SAMPLER=1 (2-stage Triton fused Gumbel-Max + exact FP32 logprob kernel in 1 read pass over [B, V], 250 us -> 46 us, deterministic TP-shared seed from server_args.random_seed + step counter).
    - qwen3_5.py: SGLANG_OPT_CUDA_FUSED_GDN_IN_PROJ=1 (enables CUDA BF16 fused in_proj_qkvz + in_proj_ba inside memory_saver_adapter.region(GPU_MEMORY_TYPE_WEIGHTS) for TMS sleep/wake + in-place update_weights safety; adds prepare_before_cuda_graph_capture forwarding on Qwen3_5ForConditionalGeneration).
  - slime (e1670b30):
    - slime/ray/serving.py + slime/ray/rollout.py: SLIME_OPT_STUDENT_DISABLE_RADIX=1, SLIME_OPT_STUDENT_CUDA_GRAPH_MAX_BS=48, SLIME_OPT_STUDENT_DISABLE_PREFILL_CG=1 (wired in ServingCluster so student engines run mamba num: 32 without radix state tracking and cut startup by ~150 s).
- Negative / break-even directions:
  - SLIME_OPT_DEFER_TEACHER_RM=1 (6b: 54.184 s vs 6a: 54.162 s): sped up generation by 1.21 s (41.73s -> 40.52s) but increased teacher tail by 1.23 s (12.43s -> 13.66s) — net break-even; reverted sglang_rollout.py to keep diff minimal.
  - ReplaySSM (36.23 us) and CuteDSL (136.88 us) GDN decode backends were slower than baseline Triton (31.97 us) at B=32.
- Full 3-Side Verification (/tmp/r6/check_r56/check.json):
  - Status: PASS, Tier: N1, Projected Full-Step Speedup: 1.859x!
  - Train: [23.366, 23.264, 23.296] -> mean 23.309 s (vs 72.872 s = 3.126x), mismatch=1.0000, exact: ok, PASS.
  - Teacher: [13.722, 13.634, 13.581] -> mean 13.646 s (vs 18.132 s = 1.329x), mean_abs_ratio=1.0052, bias t=-0.092, events p=0.646, PASS.
  - Rollout: [54.392, 54.043, 54.366] -> mean 54.267 s (vs 75.772 s = 1.396x; reported_rollout_time 53.20 s), token forcing mean_abs_ratio=0.9814, sampler t=2.20, mismatch ratio=1.0004, rollout teacher mean_abs_ratio=0.9743, PASS.
- Committed: sglang (bb90a13), slime (e1670b30); promoted all Round 2–6 switches to /submission/switches.json.
9.7 hRound 7 — Train: BF16 Triton `FusedVPLogProb` + First-Fit-Decreasing Microbatch Packing (`MAX_TOKENS_PER_GPU=9216`) + Fast 4 GB `update_weights`
- Profile & Hypothesis: Post-R6 train profile (23.309 s) showed:
  1. _ChunkedLogProbEntropy + Float16Module FP32 logits casts took ~1.5 s (12 fwd + 12 bwd TP AllReduces, 4-chunk autograd recompute, 2.03 GB FP32 fwd+bwd casts per microbatch). Using Megatron Float16Module's native fp32_output=False + a 1-pass Triton BF16 _FusedVocabParallelLogProb kernel (FP32 online LSE + target gather, 2 tiny AllReduces, zero-grad fast-zero-store in bwd) cuts logprob to ~59 ms/step and saves ~2.5 GB VRAM.
  2. With default max_tokens_per_gpu=4096 (max_per_bin=8192 for CP=2), nearly all 64 samples (~8.4–8.7K tokens each) landed in 1-sample microbatches (64 microbatches/step), leaving FLA chunk_gated_delta_rule at 48% SM coverage (64 blocks on 132 SMs) and doubling all per-microbatch kernel/NCCL/main_grad launches. Repacking DP-local microbatches in actor.py with First-Fit Decreasing (SLIME_OPT_MAX_TOKENS_PER_GPU=9216 -> max_per_bin=18432) packs 2 samples per microbatch (64 -> 32 microbatches/step), and sorting bins descending by token length puts the peak bin first to cut PyTorch caching allocator fragmentation (peak_res 104.3 GB -> 95.4–99.2 GB).
  3. Colocated update_weights (0.89 s in MODE=full) used 512 MB buckets (~36 sync IPC round-trips + per-chunk empty_cache()). Raising bucket size to 4 GB and skipping per-chunk empty_cache() (SLIME_OPT_FAST_UPDATE_WEIGHTS=1) cuts IPC round-trips ~8x.
- Changes (behind env switches, default OFF, strictly train side):
  - slime (6948da05):
    - slime/backends/megatron_utils/model.py: pass fp32_output=False when SLIME_OPT_FUSED_LOGPROB=1 (bf16/fp16, policy_loss without entropy/top-p/score-centering).
    - slime/backends/megatron_utils/loss.py: add Triton _vp_logprob_fwd_kernel, _vp_logprob_bwd_kernel, _FusedVocabParallelLogProb (fused inv_temp + g==0 fast zero-store in bwd), dispatch inside get_log_probs_and_entropy when SLIME_OPT_FUSED_LOGPROB=1.
    - slime/backends/megatron_utils/actor.py: FFD + descending-size microbatch repacking inside train_actor when SLIME_OPT_MAX_TOKENS_PER_GPU > 0 (DP=1, VPP=1).
    - slime/backends/megatron_utils/update_weight/{hf_weight_iterator_direct.py,update_weight_from_tensor.py}: SLIME_OPT_FAST_UPDATE_WEIGHTS=1 (4 GB buckets + skip per-chunk empty_cache()).
- Timing progression (bench.py time --side train):
  - 7a (FUSED_LOGPROB=1 + FAST_UPDATE_WEIGHTS=1): 22.948 s (3.177x, peak_alloc 74.95 GB, peak_res 82.80 GB, -2.5 GB VRAM vs R6).
  - 7b (+ MAX_TOKENS_PER_GPU=8192, unsorted first_fit_pack, 57/64 mbs): 21.855 s (3.335x, peak_res 104.30 GB).
  - 7c (+ MAX_TOKENS_PER_GPU=9216, FFD + descending bin sort, 32/32 mbs): 17.451 s (4.176x, actor_train_time 16.18 s, 403 TFLOPS/GPU, peak_res 95.4–99.2 GB).
- Full 3-Side Verification (/tmp/r7/check_7c/check.json):
  - Status: PASS, Tier: N1, Projected Full-Step Speedup: 2.0045x!
  - Train: [17.603, 17.415, 17.320] -> mean 17.446 s (vs 72.872 s = 4.177x), update_norm d=-4.3e-5, loss_mean d=5.0e-6, grad_norm_first d=-3.3e-5, cos=0.9622 >= 0.9566, mismatch=0.9959, PASS.
  - Teacher: [13.696, 13.597, 13.564] -> mean 13.619 s (1.331x), PASS.
  - Rollout: [53.682, 54.490, 54.198] -> mean 54.124 s (1.400x), token_forcing mean_abs_ratio=0.9923, sampler t=0.78, PASS.
- Full-Loop VRAM Note & Promotion: Promoted SLIME_OPT_FUSED_LOGPROB=1 and SLIME_OPT_FAST_UPDATE_WEIGHTS=1 immediately to /submission/switches.json (lowers MODE=full peak VRAM by ~2.5 GB). Holding SLIME_OPT_MAX_TOKENS_PER_GPU=9216 (post_used 105–109 GB train-only) until Round 8 adds teacher idle empty_cache() + lower --mem-fraction-static (~18 GB freed) and we verify MODE=full peak VRAM comfortably fits under 139.81 GB.

---
9.7 hCurrent Summary (after Round 7)
- Current switches (/submission/switches.json):
  - Train: SLIME_OPT_SKIP_DEAD_REF=1, SLIME_OPT_REUSE_OPD_LOGPROBS=1, SLIME_OPT_SKIP_DEAD_ENTROPY=1, SLIME_OPT_RECOMPUTE=none, SLIME_OPT_GPU_OPTIMIZER=1, SLIME_OPT_KEEP_OPT_ON_GPU=1, SLIME_OPT_FAST_SLEEP=1, SLIME_OPT_SKIP_DEFAULT_PAUSE=1, SLIME_OPT_SHARD_GDN=1, SLIME_OPT_FUSED_LOGPROB=1, SLIME_OPT_FAST_UPDATE_WEIGHTS=1 (SLIME_OPT_MAX_TOKENS_PER_GPU=9216 verified PASS in check_7c at 2.0045x, pending teacher VRAM slimming in R8 for safe MODE=full promotion).
  - Teacher: OPD_TEACHER_SERVER_ARGS="--chunked-prefill-size 16384 --mem-fraction-static 0.15 --disable-radix-cache --disable-cuda-graph --enable-layernorm-sp", SGLANG_OPT_TP_LOCAL_INPUT_LOGPROBS=1, SGLANG_OPT_QWEN35_LAYERNORM_SP=1, SLIME_OPT_POOLED_TEACHER_HTTP=1, SLIME_OPT_TRIM_TEACHER_LOGPROB_START=1.
  - Rollout: SGLANG_OPT_NO_SAMPLER_SYNC=1, SGLANG_OPT_FUSED_SAMPLER=1, SGLANG_OPT_CUDA_FUSED_GDN_IN_PROJ=1, SLIME_OPT_STUDENT_DISABLE_RADIX=1, SLIME_OPT_STUDENT_CUDA_GRAPH_MAX_BS=48, SLIME_OPT_STUDENT_DISABLE_PREFILL_CG=1.
- Latest check: /tmp/r7/check_7c/check.json -> PASS (N1, all 3 sides) — Train 4.177x (72.872s -> 17.446s), Teacher 1.331x (18.132s -> 13.619s), Rollout 1.400x (75.772s -> 54.124s), Projected Full-Step Speedup: 2.0045x.
- Gains by round:
  - Round 2 (Train dead compute): train 72.87s -> 53.84s (1.354x), step 1.141x
  - Round 3 (Train no-recompute + GPU AdamW + fast sleep): train 53.84s -> 34.54s (2.110x), step 1.332x
  - Round 4 (Train Ulysses AllToAll 4x head-sharded GDN + skip TMS default pause): train 34.54s -> 23.31s (3.126x), step 1.470x
  - Round 5 (Teacher LayerNorm SP + TP-local input logprobs + chunk 16384 + 22.6 GiB): teacher 18.13s -> 13.65s (1.329x)
  - Round 6 (Rollout zero-sync sampler + Triton fused Gumbel-Max + CUDA fused GDN in_proj + disable student radix): rollout 75.77s -> 54.27s (1.396x), combined step 1.859x (1.941x real MODE=full).
  - Round 7 (Train BF16 Triton FusedVPLogProb + FFD MAX_TOKENS_PER_GPU=9216 + 4 GB update_weights): train 23.31s -> 17.45s (4.177x), combined step 2.0045x!
- Negative directions:
  - Train: split-K out_proj + merged in_proj_qkvzba + native GVA failed N1 grad_norm/cos due to L00–L08 sensitivity (replaced with bitwise-exact Ulysses AllToAll).
  - Teacher: FlashInfer trtllm AR fusion at 4096/8192 slower than NCCL+RMSNorm (replaced with symm_mem LayerNorm SP).
  - Rollout: SLIME_OPT_DEFER_TEACHER_RM=1 was net break-even (54.18s vs 54.16s); ReplaySSM and CuteDSL GDN decode backends were slower than Triton at B=32; flashinfer tinygemm/cudnn/cutile and hand-rolled Stream-K mma were slower than cuBLAS in CUDA graphs on Hopper SM90 (28.36 us / 3.55 TB/s for gate_up).
↑ Slime OPD