Raw predicted log_mass in decode_secondaries can crash log_transform during rollout #54
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?
decode_secondaries(giant/data/transforms.py:684-690) appliesinv_log_transform()directly to the model's raw predictedlog_mass:log_massisn't itself the output oflog_transform, so it isn't guaranteed to land in a range that round-trips cleanly:exp(log_mass)undershoots_EPS, makinginv_log_transform(log_mass) = exp(log_mass) - _EPSgo slightly negative.exp(log_mass)overflows float32 toinf.Either one crashes the next rollout step: once that secondary spawns a track, its mass is fed back in as conditioning (
giant/rollout.py→build_cond_features→_physical_cond_columns), andlog_transform(mass)computeslog(mass + eps)— non-finite formass <= -epsormass = inf.Proposal: clip
log_massto[log(_EPS), _LOG_MASS_MAX]before inverting, guaranteeing a finite, non-negative mass — matching the invariant the surrounding comment already assumed but didn't enforce._LOG_MASS_MAXshould sit comfortably below float32's overflow point (~88.7) while being far beyond any physical particle mass a converged model would predict (80.0 was used previously).A fix for this (clip + regression tests for both tails) was already implemented on
fix/rollout-negative-secondary-mass, but that branch forked from a stale master and predates several since-merged changes totransforms.py/network.py(e.g. gitea #35, #36), so it can't be merged as-is. Reimplement the same fix against current master.Fixed in
bacc876on fix/issue-54.decode_secondaries now clips the raw predicted log_mass to [log(_EPS), _LOG_MASS_MAX=80.0] before inv_log_transform, guaranteeing a finite, non-negative mass — matching the invariant the surrounding comment already assumed but didn't enforce. Added regression tests for both the extreme-negative and extreme-positive tails (asserting the decoded mass round-trips through log_transform without raising, which is the actual downstream crash path). Reimplemented fresh against current master rather than merging the stale fix/rollout-negative-secondary-mass branch, since that branch forked before #35/#36; the stale branch was left untouched per the user's call. No follow-up filed.