Skip to content

[BUG] #6386 overwrites a checkpoint generation_config.pad_token_id with the tokenizer pad id (ovis + qwen3-marin red) #6402

Done

Description

@Qubitium

Fresh sweep of main = 1615accf9 (2026-11-29). Regression introduced by #6386 (e8e73276a): green at 390a03229 (its parent), red at HEAD.

Root cause

BaseQModel.__init__ now unconditionally copies the tokenizer's pad id onto the loaded model's generation config (gptqmodel/models/base.py, block added by #6386):

if self.tokenizer is not None:
    generation_config = getattr(self.model, "generation_config", None)
    pad_token_id = getattr(self.tokenizer, "pad_token_id", None)
    if generation_config is not None and pad_token_id is not None:
        generation_config.pad_token_id = pad_token_id

This clobbers an explicit checkpoint generation_config.json. Two observed shapes:

  1. Checkpoint pins a pad id. tests/test_ovis_local_port.py writes pad_token_id: 151643 for the clip-qwen2 policy; after GPTQModel.load() the loaded config reports 0 (assert 0 == 151643).
  2. Checkpoint leaves it None. The marin fixture in tests/test_qwen3_local_port.py has generation_config.pad_token_id = None; after load it becomes 0, and greedy/beam generate() diverges from the source model (first differing token at index 10).

Repro

cd tests
CUDA_VISIBLE_DEVICES="" PYTHONPATH=<clone>:<clone>/tests /root/venv/bin/python -m pytest \
  "test_ovis_local_port.py::test_released_generation_policy_public_load_and_two_safetensors_cycles[clip-qwen2-policy0]" \
  "test_qwen3_local_port.py::test_public_native_selection_tokenizer_generation_and_reload[False-None-marin]" \
  "test_qwen3_local_port.py::test_public_native_selection_tokenizer_generation_and_reload[True-1-marin]" \
  -q --tb=line -p no:cacheprovider
# 3 failed

Minimal pad-id probe:

source = source_fixture(tmp_path / "source", "marin")
loaded = GPTQModel.load(str(tmp_path / "source"), device="cpu", backend=BACKEND.TORCH, dtype=torch.float32)
print(source.generation_config.pad_token_id, loaded.model.generation_config.pad_token_id)
# None 0

Expected

Only fill generation_config.pad_token_id when it is unset (None), or only for the tokenizer-less-checkpoint repair path (#6361). A checkpoint's explicit generation policy must survive a load.

Evidence

  • test_ovis_local_port.py::... — red at 1615accf9, passes at 390a03229.
  • test_qwen3_local_port.py::...[False-None-marin] / [True-1-marin] — red at 1615accf9, pass at 390a03229.
  • 3 nodes total; deterministic (chunked xdist run + standalone rerun).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions