You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fbb7570
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/bridge-guide.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -292,7 +292,7 @@ Or with a helper script:
292
292
293
293
Megatron-LM training checkpoints do not normally contain the Bridge
294
294
`run_config.yaml` required by this export command. See
295
-
[Export Megatron-LM checkpoints without a Bridge run config](megatron-lm-to-megatron-bridge.md#export-megatron-lm-checkpoints-without-a-bridge-run-config)
295
+
[Best-effort export of an existing Megatron-LM checkpoint](megatron-lm-to-megatron-bridge.md#best-effort-export-of-an-existing-megatron-lm-checkpoint)
296
296
for the configuration generation and validation workflow.
Copy file name to clipboardExpand all lines: docs/fern/versions/nightly/pages/bridge-guide.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -260,7 +260,7 @@ Or with a helper script:
260
260
261
261
Megatron-LM training checkpoints do not normally contain the Bridge
262
262
`run_config.yaml` required by this export command. See
263
-
[Export Megatron-LM checkpoints without a Bridge run config](megatron-lm-to-megatron-bridge.md#export-megatron-lm-checkpoints-without-a-bridge-run-config)
263
+
[Best-effort export of an existing Megatron-LM checkpoint](megatron-lm-to-megatron-bridge.md#best-effort-export-of-an-existing-megatron-lm-checkpoint)
264
264
for the configuration generation and validation workflow.
Copy file name to clipboardExpand all lines: docs/fern/versions/nightly/pages/megatron-lm-to-megatron-bridge.mdx
+42-11Lines changed: 42 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ Megatron Bridge is Python-first: configure models, data, and training via typed
6
6
7
7
`scripts/translate_mlm_to_bridge.py` translates bidirectionally between Megatron-LM `pretrain_gpt.py` CLI arguments and Megatron Bridge `run_recipe.py` Hydra overrides. It is useful for running loss-correlation experiments between the two frameworks and for migrating existing MLM configs.
8
8
9
+
This script provides best-effort configuration translation only. It does not establish semantic equivalence, convert checkpoint weights, or emit the serialized `run_config.yaml` stored in a Bridge-native checkpoint. Do not rename its output to `run_config.yaml` or place it in an MLM checkpoint: the generated overrides or Python recipe are starting points for a new Bridge run, not checkpoint metadata. Review every skipped and unknown argument before using the output.
10
+
9
11
### MLM → Bridge (default direction)
10
12
11
13
```bash
@@ -87,9 +89,20 @@ uv run python scripts/translate_mlm_to_bridge.py --reverse \
|`--mtp-hybrid-override-pattern P`|`model.mtp_hybrid_override_pattern=P`| Separate MLM MTP pattern |
99
+
|`--mtp-use-repeated-layer`|`model.mtp_use_repeated_layer=true`| One physical MTP layer reused across prediction depths |
100
+
|`--sft-tokenizer-prompt-format P`|`tokenizer.tokenizer_prompt_format=P`| Bridge exposes the MCore SFT compatibility alias at load time |
90
101
|`--mock-data`|`dataset.mock=true`| Use synthetic data (no files needed) |
91
102
92
-
Flags not present in Bridge (e.g., `--use-mcore-models`, `--use-flash-attn`) are silently skipped with a comment. `--mock-data` translates to `dataset.mock=true`. Unknown flags are listed in a separate section so you can handle them manually.
103
+
Flags not present in Bridge (e.g., `--use-mcore-models`, `--use-flash-attn`) are omitted and listed in a comment. `--mock-data` translates to `dataset.mock=true`. Unknown flags are listed separately so you can handle them manually.
104
+
105
+
Megatron-LM `--spec` values are intentionally not copied into generated configuration as arbitrary import targets. A recognized Mamba or Hybrid spec helps the translator identify the provider family, but a standalone Hybrid recipe still requires an explicit layer pattern. Review and select any Bridge stack specification in trusted Python code.
93
106
94
107
> **Activation function CLI overrides**: `model.activation_func` can now be set via Hydra CLI string override (e.g. `model.activation_func=silu`, `model.activation_func=gelu`). The string is resolved to the callable in `TransformerConfig.finalize()`. This makes `--swiglu` → `model.gated_linear_unit=true model.activation_func=silu` round-trippable from the CLI.
Copy file name to clipboardExpand all lines: docs/megatron-lm-to-megatron-bridge.md
+42-12Lines changed: 42 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ Megatron Bridge is Python-first: configure models, data, and training via typed
6
6
7
7
`scripts/translate_mlm_to_bridge.py` translates bidirectionally between Megatron-LM `pretrain_gpt.py` CLI arguments and Megatron Bridge `run_recipe.py` Hydra overrides. It is useful for running loss-correlation experiments between the two frameworks and for migrating existing MLM configs.
8
8
9
+
This script provides best-effort configuration translation only. It does not establish semantic equivalence, convert checkpoint weights, or emit the serialized `run_config.yaml` stored in a Bridge-native checkpoint. Do not rename its output to `run_config.yaml` or place it in an MLM checkpoint: the generated overrides or Python recipe are starting points for a new Bridge run, not checkpoint metadata. Review every skipped and unknown argument before using the output.
10
+
9
11
### MLM → Bridge (default direction)
10
12
11
13
```bash
@@ -87,9 +89,20 @@ uv run python scripts/translate_mlm_to_bridge.py --reverse \
|`--mtp-hybrid-override-pattern P`|`model.mtp_hybrid_override_pattern=P`| Separate MLM MTP pattern |
99
+
|`--mtp-use-repeated-layer`|`model.mtp_use_repeated_layer=true`| One physical MTP layer reused across prediction depths |
100
+
|`--sft-tokenizer-prompt-format P`|`tokenizer.tokenizer_prompt_format=P`| Bridge exposes the MCore SFT compatibility alias at load time |
90
101
|`--mock-data`|`dataset.mock=true`| Use synthetic data (no files needed) |
91
102
92
-
Flags not present in Bridge (e.g., `--use-mcore-models`, `--use-flash-attn`) are silently skipped with a comment. `--mock-data` translates to `dataset.mock=true`. Unknown flags are listed in a separate section so you can handle them manually.
103
+
Flags not present in Bridge (e.g., `--use-mcore-models`, `--use-flash-attn`) are omitted and listed in a comment. `--mock-data` translates to `dataset.mock=true`. Unknown flags are listed separately so you can handle them manually.
104
+
105
+
Megatron-LM `--spec` values are intentionally not copied into generated configuration as arbitrary import targets. A recognized Mamba or Hybrid spec helps the translator identify the provider family, but a standalone Hybrid recipe still requires an explicit layer pattern. Review and select any Bridge stack specification in trusted Python code.
93
106
94
107
> **Activation function CLI overrides**: `model.activation_func` can now be set via Hydra CLI string override (e.g. `model.activation_func=silu`, `model.activation_func=gelu`). The string is resolved to the callable in `TransformerConfig.finalize()`. This makes `--swiglu` → `model.gated_linear_unit=true model.activation_func=silu` round-trippable from the CLI.
`from_pretrained()` loading, and at least one forward pass. These are structural
322
+
and runtime checks, not numerical-parity evidence. Compare source and exported
323
+
logits when a source-model baseline is available.
293
324
294
325
For MXFP8 parameter checkpoints, use hardware supported by the saved recipe
295
326
(normally Blackwell). The default BF16 export dequantizes Transformer Engine
@@ -300,7 +331,6 @@ native FP8 Hugging Face export currently supports blockwise FP8 parameters.
300
331
301
332
Below is a concise mapping from common `megatron-lm/megatron/training/arguments.py` flags to the new dataclass fields. If a field is not listed here (e.g., highly model-specific knobs), it typically lives under `model.*`, `optimizer.*`, `dataset.*`, or `tokenizer.*` with similar names.
Copy file name to clipboardExpand all lines: scripts/conversion/README.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,13 +13,21 @@ Run `./scripts/conversion/convert.sh import --help`,
13
13
`./scripts/conversion/convert.sh export --help`, or
14
14
`./scripts/conversion/convert.sh roundtrip --help` for the complete CLI.
15
15
16
-
Megatron-LM training checkpoints normally store their arguments in `common.pt`
17
-
instead of the Megatron Bridge `run_config.yaml` required by the export path.
18
-
Before exporting such a checkpoint, follow
19
-
[Export Megatron-LM checkpoints without a Bridge run config](../../docs/megatron-lm-to-megatron-bridge.md#export-megatron-lm-checkpoints-without-a-bridge-run-config)
20
-
to generate and validate the provider configuration. Do not create an empty or
21
-
hand-written YAML file; missing hybrid, MTP, MoE, or FP8 fields can construct a
22
-
different model while appearing to load successfully.
16
+
### Megatron-LM checkpoint compatibility
17
+
18
+
Training with Megatron-LM and later relying on Megatron Bridge for Hugging Face
19
+
export is **not recommended**. Megatron-LM checkpoints normally store their
20
+
arguments in `common.pt` instead of the `run_config.yaml` used by the supported
21
+
Bridge export launcher, so the launcher cannot consume them directly. For an
0 commit comments