Skip to content

Build real GOLD trainers in the on-policy generation tests - #7613

Merged
albertvillanova merged 1 commit into
mainfrom
tests-gold-real-trainer-on-policy
Oct 12, 2026
Merged

albertvillanova merged 1 commit into
mainfrom
tests-gold-real-trainer-on-policy

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

This PR runs the GOLD on-policy generation tests on a real trainer, its real tokenizer and model, instead of a trainer built with __new__, hand-written tokenizers and a scripted model.

Part of #7565.

Motivation

These tests skipped __init__, set the attributes the method under test read by hand, and decoded with fake tokenizers that mapped a few token ids to letters, so they could not notice a change in how the trainer is set up or in how a real tokenizer decodes special and pad tokens. One of them replaced the trainer's own _process_completions_to_buffer to capture its arguments. Only vLLM cannot run in the test environment.

Changes

  • GOLD: the on-policy generation tests (completion buffering, vLLM prompt handling and budgeting, and the non-vLLM fallback) build a real trainer from a tiny model and take their token ids and expected texts from its tokenizer.
  • The non-vLLM tests generate with the real model and check the budgeted prompt and the completion length, without patching unwrap_model_for_generation.
  • vLLM is replaced by a stand-in that records the prompts it receives and completes each one with a fixed token.
  • The test that captured _process_completions_to_buffer's arguments now checks the buffered inputs it produces.

Note

Low Risk
Test-only refactor with no production code changes; slightly heavier tests due to real model init and generation.

Overview
Refactors GOLD on-policy generation tests to exercise a fully constructed GOLDTrainer (tiny Qwen2 student/teacher + zen dataset) instead of __new__ shells with hand-rolled tokenizers and dummy models.

Adds shared helpers _gold_trainer, _gold_vllm_trainer, and RecordingVLLMGeneration so vLLM is stubbed while everything else stays real. Tests now derive token ids and expected prompt/completion text from the trainer’s tokenizer, call instance methods (_process_completions_to_buffer, _generate_on_policy_for_slices, _generate_non_vllm_for_slices), and assert buffered tensors/text logs end-to-end. The non-vLLM path no longer patches unwrap_model_for_generation or fakes model.generate; the completion-buffer test asserts outputs instead of intercepting _process_completions_to_buffer arguments.

Reviewed by Cursor Bugbot for commit 19d108e. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added the πŸ”§ maintenance CI, tooling, tests, or repo upkeep label Oct 9, 2026
@bot-ci-comment

bot-ci-comment Bot commented Oct 9, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec
qgallouedec requested a review from cmpatino October 12, 2026 05:12
@albertvillanova
albertvillanova merged commit e70581a into main Oct 12, 2026
7 checks passed
@albertvillanova
albertvillanova deleted the tests-gold-real-trainer-on-policy branch October 12, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

πŸ”§ maintenance CI, tooling, tests, or repo upkeep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants