Skip to content

Loss function comparison (CE vs P2 variants) under parameter-golf constraints - #1180

Open
estesryan wants to merge 2 commits into
openai:mainfrom
estesryan:sr-cm-p2loss
Open

estesryan wants to merge 2 commits into
openai:mainfrom
estesryan:sr-cm-p2loss

Conversation

@estesryan

@estesryan estesryan commented Mar 31, 2026 •

Copy link
Copy Markdown

Submission: SR-CM-P2Loss (non-record / ablation study)

Note:
The original record-style submission associated with this run was not valid under competition rules. This artifact has been repurposed as a compliant non-record submission and should be interpreted as a controlled ablation study, not a leaderboard result.

Scope:

  • Controlled comparison of CE vs P2 loss (γ ∈ {0.5, 1.0, 2.0})
  • Identical architecture, optimizer, data, and schedule
  • Evaluation remains standard cross-entropy

Included:

  • train_gpt.py
  • train.log (CE baseline)
  • train_p2_0_5.log
  • train_p2_1_0.log
  • train_p2_2_0.log
  • README.md
  • submission.json

@dexhunter

Copy link
Copy Markdown
Contributor

I tested the P2 loss (1-p)^2 training approach on our stack (11L, 512d, Full Hessian GPTQ, XSA-all, BigramHash) and wanted to flag a potential metric issue.

The concern: The P2 loss reweights the cross-entropy during training, focusing gradients on hard tokens. This is a legitimate training technique. However, if the same P2-weighted loss is also used during evaluation (via model.forward() returning the P2-weighted loss), the reported val_bpb is not standard cross-entropy — it's a reweighted metric that will be lower than the true BPB.

Per the README and Issue #1017:

"val_bpb is the prequential code length of a causal predictor"

This requires standard cross-entropy evaluation (Condition 2: full normalized distribution scored with log p(x_t)), not a reweighted variant.

My test results:

Metric Standard CE training P2 loss training
Post-EMA (model.forward) 1.131 0.985 ← P2-weighted, not CE
Sliding window (F.cross_entropy) 1.111 1.157 ← true BPP, worse

When evaluated with standard F.cross_entropy (the correct metric), the P2-trained model scores 1.157 BPP — significantly worse than standard CE training (1.111). The P2 loss sacrifices easy-token accuracy to focus on hard tokens, which nets worse overall BPP.

The reported 1.0577 BPP may be using the P2-weighted loss path for evaluation rather than standard cross-entropy. Could you confirm whether eval_val() uses model.forward() (P2-weighted) or F.cross_entropy(model.forward_logits()) (standard CE)?

cc @0hq @valerio-oai

@estesryan

Copy link
Copy Markdown
Author

Thanks for the careful review. You are correct. Validation is currently using the P2-weighted loss via model.forward().

I will update the evaluation to use standard cross-entropy (unweighted), rerun, and resubmit with corrected metrics.

Appreciate you flagging this.

@estesryan estesryan changed the title SR-CM-P2Loss: 1.0577 bpb (~15.06MB) Loss function comparison (CE vs P2 variants) under parameter-golf constraints Apr 1, 2026
@estesryan estesryan closed this Apr 4, 2026
@MatoTeziTanka

Copy link
Copy Markdown

Community Review — Loss function comparison (CE vs P2 variants) under parameter-golf constraints

Compliance: LOOKS CLEAN — pure-neural submission, no TTT/SLOT/n-gram-cache

Analysis Head SHA: 827b057 File audited: records/track_10min_16mb/2026-03-31_SR_CM_P2Loss/train_gpt.py (1221 lines) --- ### Check 1: ILLEGAL n-gram family bug (target XOR'd into hash key / BigramHash) NOT PRESENT. No n-gram, bigram, BigramHash, or XOR-based hash key construction found anywhere in the file. The model uses standard transformer architecture with CausalSelfAttention, MLP, RMSNorm, Rotary embeddings, and a token_mixer Conv1d layer. No n-gram lookup table or hash-based shortcut. ### Check 2: ILLEGAL Pre-Quant TTT (multi-epoch on val_tokens without score-first) NOT PRESENT. No test-time training of any kind detected. The val_tokens tensor (loaded at line 899, used at lines 1061 and 1198–1209) is consumed exclusively by eval_val() in torch.inference_mode() (line 290). No gradient computation, no optimizer step, no parameter update ever touches val_tokens. The eval function is called twice: once mid-training for logging (line 1061) and once post-quantization for roundtrip validation (line 1198). Both are pure inference. ### Check 3: LEGAL score-first TTT (PR #1413 pattern, is_last_chunk guard) NOT APPLICABLE. No TTT of any form is present, so this pattern is neither present nor needed. ### Check 4: HOLD scored-region SLOT NOT PRESENT. No scored-region slot reservation, special region markers, or held-back inference regions detected. ### Check 5: CLEAN pure neural CONFIRMED. The submission is a standard transformer (GPT) with: - Encoder-decoder skip connections (lines 792–798) - GQA attention (lines 635–683) - Focal-loss-like weighting (1-p)^2 on CE loss (lines 806–808) - Late QAT with fake int6 quantization during warmdown (lines 1114–1119, controlled by LATE_QAT flag) - Int6/Int8 post-training quantization + zstd/zlib compression for submission...

Verdict: LOOKS CLEAN.

Recommendation to @cocohearts @valerio-oai @0hq @yuzhougu-oai @notapplica: MERGE pending the usual record-track checks (3-seed validation, under-16MB artifact cap, ≤600s train + ≤600s eval on 8×H100 SXM). No compliance flags from the audit — this looks like a clean pure-neural submission.


Reviewed by @MatoTeziTanka — The Agora. Compliance audit via LLM agent (Sonnet) reviewing full train_gpt.py source, cross-checked against deterministic AST classifier. If this review misread your code, please call it out so I can re-audit manually.

@estesryan estesryan reopened this Apr 12, 2026
@estesryan

Copy link
Copy Markdown
Author

Reopening with a non-record ablation study:

  • Added controlled comparison of CE vs P2 (γ = 0.5, 1.0, 2.0)
  • Evaluation uses standard CE for comparability
  • Results show CE outperforms P2 across all settings

All logs included for reproducibility.

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.

4 participants