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
Copy file name to clipboardExpand all lines: docs/guides/checkpointing_solutions/convert_checkpoint.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ You can find your converted checkpoint files under `${BASE_OUTPUT_DIRECTORY}/0/i
78
78
### Key Parameters
79
79
80
80
-`model_name`: The specific model identifier. It must match a supported entry in the MaxText [globals.py](https://github.com/AI-Hypercomputer/maxtext/blob/16b684840db9b96b19e24e84ac49f06af7204ae3/src/maxtext/utils/globals.py#L46C1-L46C7).
81
-
-`scan_layers`: Controls whether the output uses a scanned (`scan_layers=true`) or unscanned (`scan_layers=false`) checkpoint format. Refer [to the Checkpoints guide](checkpoints) for more information. **IMPORTANT:**This setting *must* match the `scan_layers` value used during model training or loading. A mismatch will cause PyTree loading errors (though MaxText will intercept these and raise a descriptive `ValueError`explaining the mismatch).
81
+
-`scan_layers`: Controls whether the output uses a scanned (`scan_layers=true`) or unscanned (`scan_layers=false`) checkpoint format. Refer [to the Checkpoints guide](checkpoints) for more information. **Note:**When resuming or loading a checkpoint in MaxText, this setting will automatically be loaded from the checkpoint metadata, meaning you do not have to manually specify it during model execution. If you do explicitly specify a value for `scan_layers`, it must match the checkpoint's saved configuration, or a `ValueError`mismatch error will be raised.
82
82
-`use_multimodal`: Indicates if multimodality is used, important for Gemma3.
83
83
-`base_output_directory`: The path where the converted Orbax checkpoint will be stored; it can be Google Cloud Storage (GCS) or local.
84
84
-`hardware=cpu`: The conversion script runs on a CPU machine.
@@ -298,9 +298,9 @@ Here is an example [PR to add support for gemma3 multi-modal model](https://gith
298
298
299
299
-**Error:**`Type ShapeDtypeStruct is not a valid JAX type` or generic **PyTree structure/shape mismatches** (e.g., Orbax reporting `"X/Y paths matched"`, such as `143/145 paths`).
300
300
301
-
-**Cause: Configuration mismatch** (e.g., `scan_layers`) between the checkpoint conversion script (e.g., `to_maxtext.py` or `to_huggingface.py`) and the trainer/inference runner (e.g., `train.py`).
301
+
-**Cause: Configuration mismatch** (e.g., `scan_layers`) between the checkpoint conversion script (e.g., `to_maxtext.py` or `to_huggingface.py`) and the trainer/inference runner (e.g., `train.py`). (Note: Since MaxText automatically loads `scan_layers` from the checkpoint's saved metadata, you should only encounter this error if you explicitly set a mismatching value on the command line, which raises a `ValueError` mismatch error).
302
302
303
-
-**Solution:**Ensure the `scan_layers`flag is set to the exact same value (`True`or `False`) in both the conversion command and your training/execution command.
303
+
-**Solution:**Omit the `scan_layers`parameter from your training or execution command to allow MaxText to automatically resolve it from the checkpoint metadata, or ensure any explicitly specified `scan_layers` parameter matches the format of the loaded checkpoint.
304
304
305
305
-**Error:** The converted checkpoint loads without errors but produces nonsensical output.
Copy file name to clipboardExpand all lines: docs/reference/core_concepts/checkpoints.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
@@ -74,7 +74,7 @@ In MaxText, the **`scan_layers`** configuration parameter is used to control thi
74
74
-`scan_layers=false` tells MaxText to keep layer parameters unstacked (often required for inference and certain model architectures).
75
75
76
76
> [!IMPORTANT]
77
-
> **PyTree Structure Compatibility:**Because JAX expects the loaded PyTree structure to exactly match the model's instantiated structure, the value of the `scan_layers` flag during execution (training, SFT, RL, DPO, or decoding) **must** match the format of the checkpoint being loaded. A mismatch will cause PyTree loading or shape/path mismatch errors (which MaxText will intercept to raise a descriptive `ValueError`pointing to the scan_layers setting).
77
+
> **Automatic scan_layers Resolution:**MaxText automatically loads `scan_layers` from the checkpoint's saved metadata when resuming (via `load_parameters_path`) if you do not explicitly specify `scan_layers` on the command-line. If you explicitly specify a value for `scan_layers` that conflicts with the checkpoint format, MaxText will raise a descriptive `ValueError`mismatch error to prevent JAX PyTree structure or shape mismatch errors during loading.
**Note:** Because the model hasn't been properly trained, the output text will be random. To generate meaningful output, you need to load a trained checkpoint using the `load_parameters_path` argument. For instructions on how to convert pre-trained Hugging Face model checkpoints (like Llama or Gemma) to MaxText's Orbax format, please refer to the [Checkpoint Conversion Guide](../guides/checkpointing_solutions/convert_checkpoint.md).
71
71
72
72
> [!NOTE]
73
-
> **Checkpoints & `scan_layers`compatibility:** When loading an external or converted checkpoint via `load_parameters_path`, the `scan_layers`setting in your command **must** match the setting used to save the checkpoint. If the checkpoint was saved/converted with `scan_layers=False` (common for Hugging Face conversions and inference runs), you must specify `scan_layers=False` in your command. Otherwise, JAX/Orbax will raise PyTree structure mismatch errors.
73
+
> **Checkpoints & `scan_layers`Auto-Resolution:** When resuming or loading an external or converted checkpoint via `load_parameters_path`, MaxText automatically loads `scan_layers`with the checkpoint's saved format (stacked vs unstacked). You do not need to explicitly specify `scan_layers` on your command line when resuming. If you do explicitly specify a `scan_layers` value, it must match the checkpoint's saved configuration, or a `ValueError`mismatch error will be raised.
> The `scan_layers`setting during your fine-tuning run **must match** the setting used when creating the checkpoint at `MAXTEXT_CKPT_PATH`.
107
+
> **Automatic `scan_layers`Resolution:**
108
+
> MaxText automatically loads `scan_layers`from the checkpoint's saved metadata when resuming (via `load_parameters_path`) if you do not explicitly specify it on the command-line.
109
109
>
110
-
> -If the checkpoint was converted or saved with `scan_layers=False` (which is common for Hugging Face conversions and inference-ready models), you **must also provide `scan_layers=False` in the MaxText command.**
111
-
> - If `scan_layers`does not match, MaxText will raise a `ValueError`.
110
+
> -You do not need to manually supply `scan_layers=False` (or `scan_layers=True`) when loading checkpoints; MaxText will configure this automatically.
111
+
> - If you do explicitly provide a `scan_layers`argument, it must match the checkpoint's saved setting or a `ValueError` mismatch error will be raised.
112
112
> See the [Checkpoints concept guide](../../reference/core_concepts/checkpoints.md) for more details.
> The `scan_layers`setting during your fine-tuning run **must match** the setting used when creating the checkpoint at `MAXTEXT_CKPT_PATH`.
104
+
> **Automatic `scan_layers`Resolution:**
105
+
> MaxText automatically loads `scan_layers`from the checkpoint's saved metadata when resuming (via `load_parameters_path`) if you do not explicitly specify it on the command-line.
106
106
>
107
-
> - If the checkpoint was converted or saved with `scan_layers=False` (which is common for Hugging Face conversions and inference-ready models), you **must also provide `scan_layers=False` in the MaxText command.**
107
+
> - You do not need to manually supply `scan_layers=False` (or `scan_layers=True`) when loading checkpoints; MaxText will configure this automatically.
108
+
> - If you do explicitly provide a `scan_layers` argument, it must match the checkpoint's saved setting or a `ValueError` mismatch error will be raised.
> The `scan_layers`setting during your RL training run **must match** the setting used when creating the checkpoint at `MAXTEXT_CKPT_PATH`.
152
+
> **Automatic `scan_layers`Resolution:**
153
+
> MaxText automatically loads `scan_layers`from the checkpoint's saved metadata when resuming (via `load_parameters_path`) if you do not explicitly specify it on the command-line.
154
154
>
155
-
> -If the checkpoint was converted or saved with `scan_layers=False` (which is common for Hugging Face conversions and inference-ready models), you **must also provide `scan_layers=False` in the MaxText command.**
156
-
> - If `scan_layers`does not match, MaxText will raise a `ValueError`.
155
+
> -You do not need to manually supply `scan_layers=False` (or `scan_layers=True`) when loading checkpoints; MaxText will configure this automatically.
156
+
> - If you do explicitly provide a `scan_layers`argument, it must match the checkpoint's saved setting or a `ValueError` mismatch error will be raised.
157
157
> See the [Checkpoints concept guide](../../reference/core_concepts/checkpoints.md) for more details.
> The `scan_layers`setting during your fine-tuning run **must match** the setting used when creating the checkpoint at `MAXTEXT_CKPT_PATH`.
92
+
> **Automatic `scan_layers`Resolution:**
93
+
> MaxText automatically loads `scan_layers`from the checkpoint's saved metadata when resuming (via `load_parameters_path`) if you do not explicitly specify it on the command-line.
94
94
>
95
-
> -If the checkpoint was converted or saved with `scan_layers=False` (which is common for Hugging Face conversions and inference-ready models), you **must also provide `scan_layers=False` in the MaxText command.**
96
-
> - If `scan_layers`does not match, MaxText will raise a `ValueError`.
95
+
> -You do not need to manually supply `scan_layers=False` (or `scan_layers=True`) when loading checkpoints; MaxText will configure this automatically.
96
+
> - If you do explicitly provide a `scan_layers`argument, it must match the checkpoint's saved setting or a `ValueError` mismatch error will be raised.
97
97
> See the [Checkpoints concept guide](../../reference/core_concepts/checkpoints.md) for more details.
> The `scan_layers`setting during your fine-tuning run **must match** the setting used when creating the checkpoint at `MAXTEXT_CKPT_PATH`.
143
+
> **Automatic `scan_layers`Resolution:**
144
+
> MaxText automatically loads `scan_layers`from the checkpoint's saved metadata when resuming (via `load_parameters_path`) if you do not explicitly specify it on the command-line.
145
145
>
146
-
> -If the checkpoint was converted or saved with `scan_layers=False` (which is common for Hugging Face conversions and inference-ready models), you **must also provide `scan_layers=False` in the MaxText command.**
147
-
> - If `scan_layers`does not match, MaxText will raise a `ValueError`.
146
+
> -You do not need to manually supply `scan_layers=False` (or `scan_layers=True`) when loading checkpoints; MaxText will configure this automatically.
147
+
> - If you do explicitly provide a `scan_layers`argument, it must match the checkpoint's saved setting or a `ValueError` mismatch error will be raised.
148
148
> See the [Checkpoints concept guide](../../reference/core_concepts/checkpoints.md) for more details.
0 commit comments