Skip to content

Commit c9a5b49

Browse files
committed
Merge branch 'main' into chcui/sage/fix-glm45v-assistant-mask
Signed-off-by: Chen Cui <chcui@nvidia.com>
2 parents e66f5ab + 15e82b5 commit c9a5b49

26 files changed

Lines changed: 1205 additions & 142 deletions

File tree

docs/skills-index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ skills/adding-model-support/llm-patterns
2727
skills/adding-model-support/vlm-patterns
2828
skills/adding-model-support/recipe-patterns
2929
skills/adding-model-support/tests-and-examples
30+
skills/create-model-verification-card/SKILL
3031
skills/verl-e2e-testing/SKILL
3132
skills/nemo-rl-e2e-testing/SKILL
3233
```

examples/conversion/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,36 @@ uv run python examples/conversion/hf_megatron_roundtrip.py \
3232
This utility currently targets decoder-only checkpoints with a top-level
3333
`num_hidden_layers` config field and tensor names containing `layers.<index>`.
3434

35+
### `repair_hf_embedding_rows.py` - Repair Near-Zero Input Embedding Rows
36+
37+
Creates a repaired copy of a local Hugging Face safetensors checkpoint by
38+
rewriting diagnosed near-zero input embedding rows. It is intended for one-off
39+
continued-pretraining cleanup when rare token IDs in the base checkpoint can
40+
produce extreme embedding gradients.
41+
42+
The script scans the input embedding row norms, replaces rows whose L2 norm is
43+
non-finite or at/below `--min-norm` with the matching `lm_head.weight` direction
44+
scaled to the RMS norm of healthy input rows, and writes a manifest with the
45+
affected token IDs. It preserves the HF checkpoint layout and safetensors index.
46+
47+
```bash
48+
uv run python examples/conversion/repair_hf_embedding_rows.py \
49+
--input-hf-path /models/NVIDIA-Nemotron-3-Nano-4B-BF16 \
50+
--output-hf-path /models/NVIDIA-Nemotron-3-Nano-4B-BF16-repaired \
51+
--min-norm 1.0e-4 \
52+
--max-rows 256
53+
54+
# Diagnose only, without writing an output checkpoint
55+
uv run python examples/conversion/repair_hf_embedding_rows.py \
56+
--input-hf-path /models/NVIDIA-Nemotron-3-Nano-4B-BF16 \
57+
--dry-run
58+
```
59+
60+
By default the tool infers common tensor names such as
61+
`backbone.embeddings.weight` and `lm_head.weight`. Use
62+
`--input-embedding-name` and `--output-embedding-name` if a checkpoint uses
63+
different names.
64+
3565
### 1. `hf_megatron_roundtrip.py` - Two-Way Model Conversion
3666

3767
Demonstrates round-trip conversion between HuggingFace and Megatron-LM model formats.

0 commit comments

Comments
 (0)