fix : correct prefill sampling and record alignment

- sample the first token from prefill logits without duplicating the prompt tail
- reject incomplete multi-output records before preprocessing alignment
- cover cached generation and partial DPO records with regression tests
This commit is contained in:
2026-08-05 22:20:29 +08:00
parent a317a4756b
commit 654e6eb0d1
7 changed files with 143 additions and 80 deletions
+13
View File
@@ -369,6 +369,19 @@ def test_dpo_missing_field_is_none(chat_tokenizer, builder):
assert builder.build({"chosen": [], "rejected": []}, config, chat_tokenizer) is None
@pytest.mark.parametrize("missing", ["chosen", "rejected"])
def test_dpo_partial_record_is_none(chat_tokenizer, builder, missing):
config = make_dpo_chat_config()
item = {
"chosen": [{"role": "assistant", "content": "Good"}],
"rejected": [{"role": "assistant", "content": "Bad"}],
}
item.pop(missing)
assert builder.build(item, config, chat_tokenizer) is None
assert builder.build_batch([item], config, chat_tokenizer) == [None]
def test_grpo_basic(chat_tokenizer, builder):
config = make_grpo_config()
item = {