Skip to content

Move _get_kl_completion_ids into _get_kl_dataset#6181

Merged
qgallouedec merged 4 commits into
mainfrom
move-get-kl-dataset
Jun 29, 2026
Merged

Move _get_kl_completion_ids into _get_kl_dataset#6181
qgallouedec merged 4 commits into
mainfrom
move-get-kl-dataset

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Jun 25, 2026

Copy link
Copy Markdown
Member

_get_kl_completion_ids was a module-level helper used in exactly one place. Move it into its only caller, KTOTrainer._get_kl_dataset, as a nested function, alongside the existing rename_kl_fn.

The direct unit test that imported the helper is removed; its behavior stays covered through the trainer's KL-dataset preparation.


Note

Low Risk
Refactor-only with no API or algorithm change; only test coverage for the helper moved from a unit test to trainer integration paths.

Overview
Inlines the KL mismatching logic that used to live in module-level _get_kl_completion_ids into KTOTrainer._get_kl_dataset as a nested get_kl_completion_ids, next to rename_kl_fn. The batched dataset.map call now uses that nested function; behavior (cycling completion_ids by +1 within each batch for the KL term) is unchanged.

Test cleanup drops the direct import and the synthetic Dataset block in test_tokenize_and_process_tokens that exercised the old public helper. A comment in the vision collator is updated to reference get_kl_completion_ids instead of the removed name.

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

@bot-ci-comment

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 merged commit 7de024a into main Jun 29, 2026
4 of 5 checks passed
@qgallouedec qgallouedec deleted the move-get-kl-dataset branch June 29, 2026 12:40
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.

2 participants