Skip to content

[recipes] Add GS1-style decision fine-tuning recipe - #6208

Open
jacklanda wants to merge 28 commits into
pytorch:mainfrom
jacklanda:feat/gs1-decision-recipe
Open

jacklanda wants to merge 28 commits into
pytorch:mainfrom
jacklanda:feat/gs1-decision-recipe

Conversation

@jacklanda

@jacklanda jacklanda commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary (human-written)

I wanted the new Qwen3.5 recipe for GS1-format soft targets to fit into the existing Jev workflow, so both recipes now share the same data preparation, training setup, and evaluator. I checked that Jev still produces the same prompts and supervises the same answer letters. I also reviewed the 600-step runs for both training objectives and compared their results on the held-out set.

Why

A GS1-format decision question can carry a soft target such as [0.2, 0.8]. The shared letter-slot pipeline now trains on these probabilities alongside the one-hot targets used for Jev.

What changed

  • Use the prepared probability schema throughout training and evaluation.
  • Reuse the trainer's tokenizer for candidate labels and fit inverse temperature by minimizing calibration NLL.
  • Default to the public BEV data for a reproducible 120-step run with 16,384 tokens per microbatch.

Validation

Both objectives used the same Qwen3.5-0.8B-Base checkpoint, dataset, step count, and A800 GPU type. Seeds 42 and 43 apply to both training and data loading. The public BEV benchmark uses 1,500 test questions and separate calibration states. The README links the dataset and records the revisions and commands.

Objective Seed Accuracy ↑ Brier ↓ ECE ↓ Temperature
Qwen3.5-0.8B-Base — 0.4780 0.6036 0.0542 2.103
Full-vocabulary CE 42 0.7553 0.3214 0.0122 0.987
Full-vocabulary CE 43 0.7520 0.3313 0.0157 0.990
Candidate NLL + Brier 42 0.7733 0.3183 0.0242 1.001
Candidate NLL + Brier 43 0.7420 0.3456 0.0205 1.052

Both objectives improved accuracy, Brier, and ECE over base on public BEV. Each objective had the lower Brier for one seed.

For the local distribution-v4.5 check, the former 3,000-question slice contained only yes/no questions. We reran with 60,000 questions sampled across the full training JSONL and 1,000 questions each for calibration and final testing. The splits used disjoint states.

Objective Seed Expected accuracy ↑ Expected Brier ↓ ECE ↓ Temperature
Qwen3.5-0.8B-Base — 0.4005 0.6553 0.0659 2.837
Full-vocabulary CE 42 0.5667 0.5595 0.1029 2.012
Full-vocabulary CE 43 0.5454 0.5551 0.0650 1.604
Candidate NLL + Brier 42 0.5419 0.5692 0.0911 1.841
Candidate NLL + Brier 43 0.5046 0.5932 0.0683 1.595

Both objectives improved expected accuracy and Brier over base on the soft targets. Full-vocabulary CE had lower Brier in both seeds. ECE varied by seed.

All 22 decision CPU tests passed. The public and local GPU runs completed training, exported their HF-format checkpoints, and reloaded them for evaluation. On the same prepared prompts and logits, the refactor produced bitwise-identical labels, losses, and gradients for both objectives. All pre-commit hooks except Pyrefly passed locally. Pyrefly reported the same six dependency API errors on the previous PR head and this patch.

@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 19, 2026
@meta-cla

meta-cla Bot commented Nov 19, 2026

Copy link
Copy Markdown

Hi @jacklanda!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@pytorch-bot

pytorch-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/fake-pg

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@jacklanda
jacklanda force-pushed the feat/gs1-decision-recipe branch from 52d7bc8 to bfa7f12 Compare November 19, 2026 05:38
Add a reusable candidate-distribution decision recipe and a GS1 specialization. Use TorchTitan Qwen3.5 as the GS1 backbone and include a seeded distribution-v4.5 sampler, tests, and usage notes.
@jacklanda
jacklanda force-pushed the feat/gs1-decision-recipe branch from bfa7f12 to 57abfff Compare November 19, 2026 06:18
@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review. In particular,

  • what's the difference from existing Jev model?
  • is it worth landing as another example?
  • if so, how should we organize this folder? if not, ignore this question

@claude

claude Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 3m 19s —— View job


Request changes: this is the Jev recipe again plus a soft-target loss, with no training results. See my review on this PR, which also answers the three questions.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes -- the only new idea is a soft-target loss, and it comes with no training evidence. torchtitan_recipes/README.md limits public recipes to configurations that have actually been trained, and this PR states "No GPU training, convergence, or performance results are claimed."

What this PR does. It adds a second decision recipe next to the existing Jev recipe (#5569, qwen3.py). It reads GS1 request/targets records that carry a probability distribution over candidates instead of one gold answer, and keeps 3,000 of them. On each pass, the processor samples one answer letter from that distribution. The loss restricts the softmax to the first n letters and minimizes NLL + brier_weight * Brier. The backbone is Qwen3.5-0.8B, with data parallelism only.

Example.

GS1 target: {job_a: 0.2, job_b: 0.3, job_c: 0.5}
Jev (main):  one gold letter, e.g. " C" -> full-vocab CE at "Answer:"
This PR:     options reshuffled each pass; " A"/" B"/" C" sampled with p=(.2,.3,.5)
             labels[-2] = -3 (candidate count), labels[-1] = sampled letter
             loss = -log p_y + w * (sum p^2 + 1 - 2 p_y) over 3 letters, divided by global_count/2

Answers to @tianyu-l

Difference from Jev. These are the only changes to the method:

  1. Soft targets: it samples labels from a distribution instead of using one hard label.
  2. Candidate-restricted softmax plus a Brier term, instead of full-vocab CE.
  3. It reshuffles options on every pass instead of once, at data-prep time.

Everything else re-implements qwen3.py: the processor, the gather-at-answer loss wrapper (DecisionLoss ~ AnswerTokenLoss), and the Trainer.Config block. It also gives up things Jev has:

  • TP/CP support
  • an eval script (the prompt format is now State: plus an extra \n readout token, so evaluate.py can't score it)
  • a calibration/eval split
  • a public dataset (GS1 "distribution-v4.5" is not linked)
  • results

Worth landing as another example? Not in this form. Today it is a parallel copy of the Jev recipe with one loss change and no numbers. The smallest version that carries the new idea is about 30 lines in the existing recipe:

  • DecisionLetterProcessor samples the answer letter from target_probs when they are present (the sampled CE is an unbiased estimate of soft CE, which is the same argument this PR makes).
  • A prep path for GS1-format data.

The Brier term and the restricted softmax (which is what forces the negative-label marker) should only land if a run shows they improve calibration over that baseline. Folder organization is moot until then.

Must fix

  1. The PR description has an empty human-written summary and no motivation. It doesn't say what GS1 is or link the dataset, and the data can't be reproduced without it.
  2. There are no training, convergence, or eval results (see the verdict). The README addition presents this as a working recipe.
  3. base.py:229 -- DecisionModel is an ABC with one subclass that duplicates qwen3.py. Extend the existing recipe instead.
  4. base.py:116 -- the candidate count is stored as a negative label. It is counted as a loss token (hence the / 2 at line 170) and adds a marker search to the loss.
  5. prepare_gs1_data.py:78 -- rows aren't filtered by length, so one over-length state crashes training partway through the run.
  6. test_gs1_decision.py:128 -- this test checks no behavior. Delete it.

Should consider

  • base.py:147 -- the loss builds a host-to-device tensor on every call, which is a CUDA-graph hazard (unverified).
  • base.py:168 -- the logged decision_brier/mean is the one-hot Brier. It is higher than the soft-target Brier by 1 - sum(t^2), so it can't be compared to Jev's Brier column.
  • base.py:255-283 -- tokenizer files are loaded while the config is being built. If ./assets/hf/Qwen3.5-* is missing, gs1_decision() fails before training starts. qwen3.py doesn't do this.
  • prepare_gs1_data.py:97 -- 3,000 samples is a magic number. Say why.

Not verified: GPU runs. I also didn't check whether the GS1 score target IDs really are "0".."n-1".

Comment thread torchtitan_recipes/decision/base.py Resolved
Comment thread torchtitan_recipes/decision/base.py Resolved
Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
@jacklanda

Copy link
Copy Markdown
Author

@tianyu-l @fegin Could you please review the updated GS1 decision recipe at 976aa12 and approve the pending CI workflows, including ciflow/fake-pg? All Claude review threads are addressed and resolved. Thank you!

Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
@jacklanda

Copy link
Copy Markdown
Author

@tianyu-l Implemented the structural fix in a10f76e14: removed the single-user DecisionModel ABC and replaced it with an explicit build_candidate_distribution_config(...) helper. GS1 now supplies its model config/assets directly; the existing Jev recipe remains independent because it has a different hard-label/full-vocabulary objective. This makes the shared code a concrete utility rather than a one-consumer inheritance framework.

@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review

@claude

claude Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 52s —— View job


Request changes: there are still no training results, the old base class is left in base.py as a string literal, and the code doesn't match the README's claim of a native GS1 decision head. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes -- there are still no training results, and the "structural fix" left the old class in the file as a string literal. base.py still has a single consumer, and the recipe's claim of a native GS1 head doesn't match the code.

What this PR does. It adds a second decision recipe next to Jev (qwen3.py). Input is GS1 request/targets records that hold a probability distribution over candidates. The recipe flattens them to one row per question and keeps 3,000. On each pass it samples one answer letter from the distribution. Training is Qwen3.5-0.8B with data parallelism only, on a candidate-restricted NLL + brier_weight * Brier loss. The candidate count travels in the labels as a negative marker.

Example.

GS1 target: {a: 0.75, b: 0.25}  -> options shuffled, e.g. "A) B-text  B) A-text", probs (.25, .75)
input_ids:  ...prompt..."Answer:" "\n"
labels:     ...IGNORE...  -2       " B" (sampled with p=.75)
loss:       softmax over [" A"," B"] only; -log p_B + w * (p_A^2 + p_B^2 + 1 - 2 p_B)
            divided by global_loss_token_counts / 2  (marker + answer counted as 2 tokens)

Must fix

  1. Evidence. The PR still has no training, convergence, or eval results. torchtitan_recipes/README.md limits public recipes to configurations that have actually been trained. The Brier term, the restricted softmax, and the label-marker transport each need a run showing they beat the ~30-line alternative from the last review (sample the letter from target_probs inside the existing DecisionLetterProcessor). I still recommend that alternative.
  2. torchtitan_recipes/decision/base.py:316-426 -- the old DecisionModel was kept as a commented-out string literal plus a no-op stub. Delete it.
  3. torchtitan_recipes/decision/base.py:234 -- @tianyu-l's single-user question is still unresolved. The ABC became a function, but it still has one caller. Fold base.py into gs1.py.
  4. torchtitan_recipes/decision/gs1.py:23 -- the code is a plain Qwen3.5 model with an LM-head letter readout, but the README and description claim a GS1 cross-attention decision head. Either the claim is wrong, or HF loading drops the head (unverified). Show HF numerics parity.
  5. torchtitan_recipes/decision/README.md:75 and the PR description -- both still describe DecisionModel/GS1DecisionModel, which no longer exist. The "Summary" also doesn't link the distribution-v4.5 dataset, so the data can't be reproduced.

Should consider

  • torchtitan_recipes/decision/base.py:261 -- the tokenizer is still loaded while the config is being built (open from the last review), and it duplicates the processor's own letter-ID lookup.
  • torchtitan_recipes/decision/base.py:112 / :174 -- the negative count marker and / 2 are unchanged. The author's reply explains them but doesn't remove the side effects: loss_token_counts is 2x the real count, and labels contain out-of-vocab values. That's acceptable only if a run justifies the restricted softmax (item 1).

Questions

  • Is bigai/GS1-0.8B a stock Qwen3.5-0.8B architecture? If so, what does "GS1 model family" add here beyond the dataset format?

Not verified: GPU runs, and HF checkpoint loading for bigai/GS1-0.8B.

Comment thread torchtitan_recipes/decision/base.py Resolved
Comment thread torchtitan_recipes/decision/base.py Resolved
Comment thread torchtitan_recipes/decision/gs1.py Resolved
Comment thread torchtitan_recipes/decision/README.md Resolved
Comment thread torchtitan_recipes/decision/base.py Resolved
@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review again

Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
@tianyu-l

Copy link
Copy Markdown
Contributor

How's it fundamentally different from existing Jev one? They should sit in the same folder in torchtitan_recipes/, sharing building blocks if they have any.

Place candidate-distribution training alongside Jev and share the answer-token loss wrapper. Document the separate data preparation and evaluation entry points.

Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
@jacklanda

jacklanda commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

@tianyu-l Both recipes score answer letters at one position. Jev uses a gold answer letter and full-vocabulary cross-entropy. The Qwen3.5 recipe samples an answer from the GS1-format soft targets and computes NLL plus weighted Brier over the valid options.

In cdad7cd, both recipes now live under torchtitan_recipes/decision/ and share AnswerTokenLoss, which runs the LM head only at supervised positions. The data preparation scripts handle the two input formats, and evaluate.py serves Jev. All 16 targeted CPU tests passed.

Thank you so much!

Stream reservoir sampling with enumerate, render shuffled options directly, and consolidate overlapping test setup.

Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review again

In particular, check if the folder and file structure makes sense. We should share what could be shared, and make what couldn't be shared in consistent format, via inheritance / composition / etc.

@claude

claude Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 3m 6s —— View job


Request changes: the two recipes still share only AnswerTokenLoss. The prompt, data schema, prep script, labels, Trainer.Config, and evaluation are duplicated or diverge, and the review proposes a shared layout. (Correction: the review's "distribution.py:22-29" should read distribution.py:114-137.)

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes -- both recipes now live in decision/, but they still run two parallel pipelines. Only AnswerTokenLoss is shared. The prompt format, data schema, prep script, processor, label format, and Trainer.Config are all duplicated or diverge for no stated reason, and evaluate.py still only works for Jev.

What changed since the last review. The recipe moved from experiments/ back into torchtitan_recipes/decision/ and uses Qwen3.5-0.8B-Base assets, not GS1. AnswerTokenLoss moved into loss.py, which both recipes import. The negative count marker and the / 2 were replaced by a single class-ID label. The README adds a 10-step run with loss going 1.94 -> 1.50.

Example: what is shared today, per stage.

stage        Jev (qwen3.py)                     distribution.py
prep         prepare_data.py -> {prompt,gold}   prepare_distribution_data.py -> {options,target_probs}
render       at prep, "Context:", "yes/no"      in processor, "State:", "noul"
readout      last token of "Answer:"            extra "\n" after "Answer:"
label        token(" C")                        (n-2)*26 + slot
loss_fn      CrossEntropyLoss                   CandidateDistributionLoss
wrapper      AnswerTokenLoss                    AnswerTokenLoss        <- only shared piece
config       Trainer.Config (50 lines)          same 50 lines, 6 values differ
eval         evaluate.py                        none (no calib/eval split)

Resolved

  • The negative-count marker, the / 2, and the inflated loss_token_counts are gone: there is one label per question now.
  • The tokenizer is no longer read while the config is built.
  • The checkpoint is no longer loaded through the wrong adapter: the recipe now uses Qwen3.5 assets.

Must fix

  1. Structure (@tianyu-l's request). Only the loss pipeline (loss_fn) and the model config need to differ between the recipes, and both can be selected by config type. Everything else should be shared. Target layout:
    decision/
      prepare_data.py   bev and gs1 readers -> one row schema
                        {state, type, instructions, keys, prompt, target_probs}
                        (one-hot for BEV); shared render/filters/write; train/calib/eval for both
      <recipe>.py       one processor: label = token(" X") sampled from target_probs
                        (one-hot -> identical to today's Jev labels)
                        AnswerTokenLoss, _decision_config(...)
                        qwen3_1_7b_decision(), qwen3_5_0_8b_distribution()
      evaluate.py       scores both; Brier against target_probs (identical for one-hot)
    tests/.../test_decision.py
    
    Jev numerics stay bit-identical as long as render and the prep-time shuffle are unchanged. Inline:
    • distribution.py:94 -- second prompt renderer
    • distribution.py:100 -- extra "\n" readout token
    • distribution.py:107 -- class-ID labels
    • distribution.py:215 -- copied Trainer.Config
    • prepare_distribution_data.py:39 -- second prep script with no calib/eval split
    • README.md:78 -- file names that describe different things
  2. Evidence (still open). The new run is 10 steps on one GPU. It shows only that training runs, not that the new objective helps, and the README says the "comparisons with full-vocabulary CE remain to be measured". Until that comparison exists, the restricted softmax and Brier term are the one thing that blocks sharing the label format (see distribution.py:107). Land the shared version with Jev's CE on the sampled letter, and add CandidateDistributionLoss as a different loss_fn config once a held-out run shows it improves calibration.
  3. PR description. "Put distribution preparation ... under torchtitan/experiments/decision_distribution/" and "Use ... the Qwen3.5 state-dict adapter" with "no compatible evaluation entry point" describe an older layout. Update the description to match HEAD, and leave the human-written summary to the author.

Should consider

  • distribution.py:22-29 -- CandidateDistributionLoss.Config has two ways to set the same thing (candidate_token_ids or tokenizer_path), and it loads its own tokenizer even though the trainer already builds one. Keep just one way.
  • distribution.py:103 vs qwen3.py:73 -- an over-length row is silently dropped here but raises in Jev. Pick one behavior for both.

Not verified: GPU runs, and whether Qwen3.5 supports TP/CP with this recipe.

Comment thread torchtitan_recipes/decision/README.md Resolved
Use one letter-slot renderer, processor and trainer config for Jev and GS1-format targets. Compare candidate NLL plus Brier with full-vocabulary CE on separate calibration and test splits.

Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review again

@claude

claude Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 2m 30s —— View job


Request changes: the folder layout is now what you asked for, but the candidate NLL+Brier objective still has two booleans that must agree and no real evidence behind it. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes -- the structure now matches what @tianyu-l asked for. What still blocks is the candidate-restricted NLL+Brier objective: it adds a class-ID label encoding and two coupled booleans, and the only evidence for it is a 30-step run on a non-default config with no measurable effect.

What changed since the last review (525a98d). distribution.py, prepare_distribution_data.py, and loss.py are gone. The two recipes now share:

  • one processor (DecisionLetterProcessor)
  • one prompt renderer (render_options)
  • one _decision_config
  • one prepare_data.py, which writes train/calib/eval for both sources
  • one evaluate.py, which scores soft targets (one-hot for BEV)

The Jev path looks numerically unchanged: same prompt, same label, same warmup, microbatch, and prefetch values, and the Brier/NLL formulas reduce to the old ones for one-hot targets.

Example (GS1 row at HEAD).

prep:    {a: .75, b: .25} -> shuffled once, rendered "Context: ... Question (choice) ... Answer:", target_probs (.25, .75)
CE path (full_vocab_ce=True):   label = token(" B") sampled with p=.75     <- same format as Jev
default (candidate_labels=True): label = (2-2)*26 + 1 = 1                   <- not a token ID
                                 CandidateDistributionLoss decodes count/slot from it

Resolved

  • Folder and file structure: one prep script, one recipe module, one evaluator, one test file.
  • Second prompt renderer and extra "\n" readout token: removed. GS1 now uses Jev's Answer: readout.
  • Copied Trainer.Config: replaced by _decision_config.
  • No calib/eval split, and evaluate.py scoring only Jev: both fixed.
  • Over-length rows: now raise for both recipes.
  • Two ways to set the loss tokenizer: now one.

Must fix

  1. PR description is stale again. It says the Jev files are "unchanged" and that the code lives under torchtitan/experiments/decision_distribution/. Both are false at HEAD. It also has no human-written summary of the motivation, and it doesn't link the distribution-v4.5 data.
  2. README.md:106 -- Evidence. The runs don't use the shipped config, the effect is within noise, there is no base row, and the reported sampling procedure isn't what the code does (inline).
  3. qwen3.py:148 -- Coupled booleans. candidate_labels and full_vocab_ce select the implementation by flag instead of by config type, and a mismatch trains on wrong labels with no error. Unless item 2 shows a real gain, drop the candidate objective and use CE for both recipes (about -90 lines) (inline).

Should consider

  • prepare_data.py:186 -- the sampling and shuffle RNGs share one seed and stream (inline).
  • qwen3.py:140 -- the processor repeats validation that prep already does (inline).
  • qwen3.py:7 -- the module docstring still says "Qwen3-1.7B-Base" only, but the module now hosts qwen3_5_distribution. The prepare_data.py docstring and usage line also describe only BEV.
  • prepare_data.py:34 -- GS1_MAX_STATE_CHARS = 12_000 vs BEV's 4000 has no stated reason. flatten_record's rng: ... | None = None exists only so the test can omit it.
  • qwen3.py:298 -- tokenizer_path=assets duplicates hf_assets_path. If a user overrides one, the loss resolves letter IDs from a different tokenizer. This goes away with item 3.

Not verified: GPU runs, behavior under accelerator graphs, and HF loading of the exported Qwen3.5 checkpoint in evaluate.py's prefix remap.

Comment thread torchtitan_recipes/decision/README.md Resolved
Comment thread torchtitan_recipes/decision/qwen3.py Resolved
Comment thread torchtitan_recipes/decision/qwen3.py Resolved
Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
Signed-off-by: Michael Yang Liu <yonyonlau@gmail.com>
@meta-cla

meta-cla Bot commented Nov 24, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 24, 2026
@jacklanda

Copy link
Copy Markdown
Author

Thanks for the feedback, @tianyu-l. Could you take another look at 54c6ffe79 when you have a chance? The recipes now share the data and training pipeline, and the PR includes the two-seed, 600-step comparison. The CLA check has passed. Could you also approve the Lint, CPU Unit Test, and GPU Unit Tests workflows for this commit? Thanks!

@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review again

@claude

claude Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 2m 59s —— View job


Request changes: the folder layout now works, but the new results show every fine-tuned run scoring worse than the untrained base model, and the temperature fit is clipped at the top of its grid. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes -- the code layout is now fine, but the new results show the shipped Qwen3.5 recipe makes the base model worse on every metric. The temperature fit is also clipped at the top of its grid, so the CE vs candidate comparison isn't a clean measurement yet.

What changed since the last review (f7490a1, 54c6ffe). The two coupled booleans are gone:

  • The processor is now selected by loss config type (CandidateLetterProcessor iff CandidateDistributionLoss.Config).
  • Candidate labels are encoded as -101 - ((n-2)*26 + slot), a range below IGNORE_INDEX and disjoint from vocab IDs, so a mismatch now fails loudly.
  • The RNG streams are seeded per split, sampled states are checked for overlap across splits, GS1 uses Jev's 4,000-char limit, and the README reports 600-step, two-seed runs with a base row.

The Jev path still looks numerically unchanged: same prompt, same label token, same warmup, microbatch size, and prefetch, and the Brier/NLL formulas reduce to the old ones for one-hot targets.

Example (README table at HEAD).

                      exp. acc   Brier    ECE
Qwen3.5-0.8B-Base     0.4315     0.6455   0.0555
CE, seeds 42/43       0.33/0.34  0.692/0.691
Cand NLL+Brier 42/43  0.35/0.38  0.675/0.665
-> every fine-tuned run is worse than not training; fitted T > grid max (~20.1) for all four

Resolved

  • Coupled candidate_labels / full_vocab_ce booleans: replaced by selection on config type, and a mismatch now raises.
  • Evidence not from the shipped config: the runs now use the default 600 steps, 32K-token microbatches, and CUDA graphs, with two seeds and a base row.
  • Shared RNG stream, undocumented 12,000-char limit, and states not checked as disjoint: all fixed.
  • PR description is current and has a human-written summary.

Must fix

  1. torchtitan_recipes/decision/README.md:111-122 -- fine-tuning regresses below the base checkpoint, and the temperature fit saturates at evaluate.py:155's upper edge. The likely cause is many epochs over 3,000 questions (unverified). Widen the grid, retune the data size or steps until fine-tuning beats the base, then re-run the comparison (inline).
  2. Data still not linked. The README and description reference "distribution-v4.5" but don't say where to get it, so the table can't be reproduced. Add the link, or the HF dataset id, in README.md.
  3. torchtitan_recipes/decision/qwen3.py:144-145 -- the answer / gold fallbacks (here and in evaluate.py:57-59) only serve files prepared before this PR. Delete them (inline).

Should consider

  • torchtitan_recipes/decision/qwen3.py:110-114 -- AnswerTokenLoss now does isinstance on one specific loss_fn to run a check that CE's gather and TP CE already enforce (inline).
  • torchtitan_recipes/decision/qwen3.py:385 -- prefetch depth is now tied to batch_contexts, and warmup_steps=0 still has no reason (inline).
  • qwen3.py:876-879 -- still open: CandidateDistributionLoss.Config.tokenizer_path=assets duplicates hf_assets_path and loads a second tokenizer. Overriding one but not the other resolves letter IDs from the wrong tokenizer. The test has to monkeypatch HuggingFaceTokenizer because of it.
  • Still open: the module docstrings (qwen3.py:7, prepare_data.py:7-21) describe only Qwen3-1.7B/BEV, and flatten_record(rng=None) exists only so the test can omit it.

Questions

  • Given that both objectives currently do worse than no training, do the maintainers want the ~150-line candidate objective (processor subclass, label encoding, loss) at all? Or should the recipe land with CE only, adding the candidate objective once it beats both CE and the base at a non-degrading setting?

Not verified: GPU runs, the epoch count per run (depends on average GS1 prompt length), and HF loading of the remapped model.language_model.* export in evaluate.py.

Comment thread torchtitan_recipes/decision/README.md Resolved
Comment thread torchtitan_recipes/decision/qwen3.py Resolved
Comment thread torchtitan_recipes/decision/qwen3.py Resolved
Fit calibration without a fixed temperature grid, use one prepared row schema, and reuse the trainer tokenizer for candidate scoring. Validate the shorter recipe against the base checkpoint and full-vocabulary CE on public BEV data.
@jacklanda
jacklanda requested a review from tianyu-l November 25, 2026 04:23
@jacklanda

Copy link
Copy Markdown
Author

Thanks for the review, @tianyu-l. In 762dd8d68, the default recipe uses the public BEV dataset for 120 steps. Both objectives beat the base checkpoint in both seeds, and the fitted temperatures are 0.987–1.052. Candidate NLL + Brier and full-vocabulary CE each had the lower Brier in one BEV run. CE had the lower Brier in both runs on the local soft-target data. The candidate objective gives users an option-restricted loss with a configurable Brier term. Would you prefer CE as the default?

Could you review the update and approve the Lint, CPU Unit Test, and GPU Unit Tests workflows when you have a chance? Thanks. Results and reproduction steps · CI runs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants