Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Changelog
- Fix Megatron unified HF export of MoE models with grouped-GEMM experts when only the experts are quantized (e.g. ``nvfp4_experts_only-*`` recipes): ``hf_quant_config.json`` and the ``quantization_config`` in ``config.json`` were not written, so the quantized experts were served as unquantized weights. Re-export such checkpoints.
- Fix DFlash conversion on NoPE targets whose config leaves ``rope_theta`` unset.
- Fix offline DFlash training failing to reconstruct the target logits when the captured hidden states are stored in a different dtype than the target's weights.
- Fix ``hf_ptq`` overwriting a model's existing ``pad_token`` with ``eos_token`` when the model already has a valid padding token. The exported tokenizer now preserves the source model's padding configuration.
- Fix Megatron-Core checkpoint saving for quantized grouped MoE experts when tensor and expert parallelism are both enabled.
- Fix unified HuggingFace export of RADIO-based VLMs retaining post-conversion vision and
projector names instead of restoring the hub layout; deployment loaders could skip those weights.
Expand Down
3 changes: 1 addition & 2 deletions examples/hf_ptq/example_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ def get_tokenizer(ckpt_path, trust_remote_code=False, **kwargs) -> PreTrainedTok
ckpt_path, trust_remote_code=trust_remote_code, **kwargs
)

# can't set attribute 'pad_token' for "<unk>"
if tokenizer.pad_token != "<unk>" or tokenizer.pad_token is None:
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token

assert tokenizer.pad_token is not None, f"Pad token for {ckpt_path} cannot be set!"
Expand Down
29 changes: 29 additions & 0 deletions tests/examples/hf_ptq/test_example_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,35 @@ def from_pretrained(*args, output_loading_info=False, **kwargs):
assert used["path"] == ("bundled" if expect_bundled_code else "builtin")


# ---------- get_tokenizer ----------------------------------------------------


class _StubTokenizer:
"""Minimal stand-in for a PreTrainedTokenizer."""

def __init__(self, pad_token, eos_token="<|eos|>"):
self.pad_token = pad_token
self.eos_token = eos_token


@pytest.mark.parametrize(
("pad_token", "eos_token", "expected_pad"),
[
# Valid existing pad token must be preserved unchanged.
("<|endoftext|>", "<|im_end|>", "<|endoftext|>"),
# <unk> as pad must also be preserved (only None triggers the fallback).
("<unk>", "<|im_end|>", "<unk>"),
# Missing pad token falls back to eos_token.
(None, "<|im_end|>", "<|im_end|>"),
],
)
def test_get_tokenizer_pad_token(monkeypatch, pad_token, eos_token, expected_pad):
stub = _StubTokenizer(pad_token=pad_token, eos_token=eos_token)
monkeypatch.setattr(example_utils.AutoTokenizer, "from_pretrained", lambda *a, **k: stub)
tok = example_utils.get_tokenizer("/fake/path")
assert tok.pad_token == expected_pad


def _layerwise(**kwargs):
return {"enable": True, **kwargs}

Expand Down
Loading