n_sec mode='head': allow sampled instead of argmax secondary counts #86
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
For
stage2_model.n_sec.mode = "head", the secondary count is resolved deterministically as an argmax over the classifier logits (giant/sample.py:510-511):The head (
Stage2Autoregressive.predict_n_sec,giant/model/models.py:652) is a linear head over the base conditioning embedding emitting(B, K_MAX+1)logits, trained with plainF.cross_entropy(giant/training/trainers.py:539).Taking the argmax collapses the multiplicity distribution onto its conditional mode: at fixed pre-step conditioning the count is fully deterministic, so all spread in
n_secacross a rollout comes from variation in the conditioning, never from the head. Real secondary multiplicity is genuinely stochastic at fixed pre-step state, so this should systematically under-dispersen_sec— and being a mode rather than a mean, it biases low wherever the true conditional distribution is right-skewed, which for multiplicity it typically is.mode = "stop_token"already has the corresponding knob:n_sec.stop_sampling("greedy"|"sample",giant/sample.py:348) chooses between thresholding and a Bernoulli draw.mode = "head"has no equivalent.Proposal
Add a categorical sampling branch to
resolve_n_sec, i.e.Preferred config shape: generalize the existing key into one
n_sec.sampling = "greedy" | "sample"covering both modes (greedy = argmax forhead, threshold at 0 forstop_token; sample = categorical draw forhead, Bernoulli forstop_token), rather than adding a second parallel key.stop_samplingwould need to be kept as a deprecated alias, or migrated, since it appears in existing checkpoints'model_config— seegiant/config.py:431,440,448,1515andgiant/_migration.py.This is weight-neutral and shape-neutral: it changes only sampling-time behavior, so it also belongs on the inference-safe override allowlist (see the companion issue on inference-time config overrides).
Acceptance
n_sec.sampling(or equivalent) selects greedy vs sampledn_secundermode = "head"stop_tokenbehavior unchanged by default; existingstop_samplingvalues in old checkpoints still honoredstop_samplingchecktests/test_sample.py:270-292greedyso existing runs are unaffectedFollow-up
Worth checking against a rollout: if a
head-mode rollout shows a too-narrow secondary-count distribution vs Geant4 in the analysis pipeline, this is a prime suspect.