Skip to content

Policy metrics in the compiled monolithic loss (#507)#565

Open
jlamypoirier wants to merge 1 commit into
jlp_monolithic_head_lossfrom
jlp_monolithic_metrics
Open

Policy metrics in the compiled monolithic loss (#507)#565
jlamypoirier wants to merge 1 commit into
jlp_monolithic_head_lossfrom
jlp_monolithic_metrics

Conversation

@jlamypoirier

Copy link
Copy Markdown
Collaborator

Claude Opus 4.8 note: authored with Claude Code.

Intermediate PR in the monolithic-loss stack: jlp_monolithic_triton (#558) → thisjlp_monolithic_head_loss (#549, dev). Contains the path-agnostic + compiled-path policy-metrics work; the triton kernel and triton-metric wiring stay in #558 on top of this.

What this adds

  • Compiled GSPO metrics: finish reduces the policy-metric family (importance ratio, KL, clip fraction, advantage stats, entropy) from the shared softmax and the segment seam via gspo_metrics_core, matching how GRPO already reuses the softmax — no second softmax pass.
  • PolicyMetricsLevel reworked to {none, basic, auto}, default auto:
    • basic folds entropy in (now near-free) — no separate with_entropy.
    • auto resolves to basic when pipeline_parallel == 1 and none otherwise (the metrics need the full-logits pass, which pipeline parallelism splits). An explicit basic still asserts pipeline_parallel == 1.
    • none stays zero-cost.
  • Metric cores take a precomputed entropy_per_token, unifying the compiled/standalone (from the softmax) and — in Triton monolithic head-loss kernel (#507) #558 — the triton (from the kernel) entropy sources.
  • De-flake: raise the GSPO loss-comparison floor (loss_min_threshold); its per-segment geometric-mean reduction is noisier in float32 than a per-token sum, so the fused-vs-reference scalar diff sat at the 1e-6 floor ~1/300 draws.

Validated on CPU (test_lm_head + test_lm_losses, 577 passed). The equivalent code was GPU-validated as part of the combined branch before the stack split.

🤖 Generated with Claude Code

Extend the monolithic loss to emit the policy-gradient metric family (GRPO and
GSPO) from the shared softmax on the compiled path:

- Compiled GSPO metrics: `finish` reduces the family from the shared softmax and
  the segment seam via `gspo_metrics_core`, matching how GRPO already reuses it.
- Collapse `PolicyMetricsLevel` to `{none, basic}` (entropy folded into `basic`,
  now near-free) plus an `auto` default that resolves to `basic` when
  `pipeline_parallel == 1` and `none` otherwise (an explicit `basic` still
  requires it). `none` stays zero-cost.
- The metric cores take a precomputed `entropy_per_token`, unifying the softmax
  and (later) kernel entropy sources.
- Raise the GSPO loss-comparison floor to de-flake its float32 tolerance.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jlamypoirier jlamypoirier force-pushed the jlp_monolithic_metrics branch from 32c3943 to 2368650 Compare July 11, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant