You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ExternalDraftConfig accepts tvd_ce weights that produce zero or infinite loss #3524
I’m doing some research for Tessl Code Review and ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:
ExternalDraftConfig(external_loss="tvd_ce", ...) accepts both a zero/zero weight pair and an infinite weight. The current _mix_ce then produces a zero objective or a non-finite loss.
Both fields have ge=0.0, but neither a finiteness constraint nor a combined-positive-weight check.
Validation
I executed the current ExternalDraftConfig class using the actual current ModeloptBaseConfig and ModeloptField, with Pydantic 2.14.4 and PyTorch 2.15.0 on CPU. The two configurations above were accepted; a negative weight was rejected.
I also executed the current _mix_ce method with a small logits/target fixture and a controlled TVD scalar:
Weights 0/0: loss 0, zero logits gradient and zero TVD gradient.
Weights infinity/0.1: infinite loss and infinite TVD gradient.
Weights 0.9/0.1: finite loss and gradients.
No GPU or full training run was involved.
Expected behavior
For tvd_ce, reject non-finite weights and require at least one positive contribution. That would catch a configuration that silently disables the objective before starting training, while still allowing either individual term to be disabled.
Full transparency: I work at Tessl, and we've spotted that using Tessl Code Review - using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced.
We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.
Reproduced on main (3497c11): ExternalDraftConfig(external_loss="tvd_ce") accepts weights 0/0 and inf, and _mix_ce then returns a loss of exactly 0 with zero gradients, or an infinite loss with an infinite TVD gradient. I'd like to take this. The plan is allow_inf_nan=False on both weights, plus a validator that rejects 0/0 only when the objective is tvd_ce, so either term can still be turned off on its own. Tests go in tests/unit/torch/speculative/test_external_draft.py; PR to follow.
Activity
adimalkar commentedon Nov 23, 2026
Reproduced on
main(3497c11):ExternalDraftConfig(external_loss="tvd_ce")accepts weights 0/0 andinf, and_mix_cethen returns a loss of exactly 0 with zero gradients, or an infinite loss with an infinite TVD gradient. I'd like to take this. The plan isallow_inf_nan=Falseon both weights, plus a validator that rejects 0/0 only when the objective istvd_ce, so either term can still be turned off on its own. Tests go intests/unit/torch/speculative/test_external_draft.py; PR to follow.