Router auxiliary losses computed even when lambda = 0 #31
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?
Severity: low (wasted compute, no wrong results).
giant/training/trainers.py:618-622computesbalance_loss,classify_lossand
entropy_losswhenever a router exists, then adds each only if its lambdais
> 0. Every routed run therefore pays three extrarouter.gate()forwardpasses per batch — including the default
lambda_balance = 0.0case, which isexactly the configuration the failed 2026-07-22 benchmark ran.
Fix: guard the computation on the same
> 0condition that guards theaddition.
Migrated from
issues.md(v0.3.0 branch review, 2026-08-13), Issue 6.Fixed in
f505fe7on v0.3.0-stage2-autoregressive.Guarded the three router auxiliary-loss computations in FlowDDPMStageTrainer._compute (balance_loss, classify_loss, entropy_loss) on the same lambda > 0 condition that already guarded their addition into the total loss, instead of computing all three unconditionally whenever a router exists. Confirmed WGANStageTrainer has no equivalent block, so this was the only call site. Added a test that mocks (wraps) the router's three loss methods and asserts zero calls at the default lambda=0 config and exactly one call each when lambdas are positive, so the guard is verified both ways. All four checks (pytest, ruff format, ruff check, ty check) pass clean.