Skip to content

fix: add truncation warning to TRL generate paths#242

Merged
abrichr merged 1 commit into
mainfrom
fix/trl-truncation-warning
Mar 29, 2026
Merged

fix: add truncation warning to TRL generate paths#242
abrichr merged 1 commit into
mainfrom
fix/trl-truncation-warning

Conversation

@abrichr
Copy link
Copy Markdown
Member

@abrichr abrichr commented Mar 29, 2026

Summary

  • Add truncation warning after both generation paths (Outlines constrained and HF unconstrained) in generate_fn inside make_waa_rollout_func. When output length reaches max_new_tokens - 1, a warning is logged suggesting to increase max_new_tokens or enable constrained_decoding.
  • Replace tautological truncation tests in test_trl_robustness.py (which reimplemented the check logic inline in the mock) with tests that exercise the actual generate_fn code path by calling it through the rollout function with mocked torch and model.generate.

Test plan

  • test_truncation_warning_logged_hf_path — verifies warning fires when completion hits max_new_tokens
  • test_no_truncation_warning_when_short — verifies no warning for short completions
  • All 34 tests in test_trl_robustness.py and test_trl_rollout.py pass
  • Full test suite (1493 passed, 54 skipped)

🤖 Generated with Claude Code

Add a truncation check after both generation paths (Outlines constrained
and HF unconstrained) in generate_fn. When the output length reaches
max_new_tokens - 1, a warning is logged suggesting to increase
max_new_tokens or enable constrained_decoding. This helps diagnose
cases where the model generates excessively long reasoning that gets
cut off before producing a parseable action.

Also replaced the tautological truncation tests in test_trl_robustness.py
(which reimplemented the check logic inline) with tests that exercise the
actual generate_fn code path by calling it through the rollout function
with mocked torch and model.generate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@abrichr abrichr merged commit e71ed9f into main Mar 29, 2026
1 check passed
abrichr added a commit that referenced this pull request Mar 29, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant