checkpoint ¶
Pre-quantized MLX checkpoint save/load for the FastWan DiT.
Loading the Diffusers fp32/fp16 checkpoint and quantizing at startup costs both download size and load time on every run. This module persists an already cast (and optionally already quantized) MLXWanDiT so 16 GB users download and load roughly half the bytes and skip requantization entirely:
dit = mlx_dit_from_diffusers_safetensors(ckpt, cfg, quantization="int8")
save_mlx_dit_checkpoint(dit, "FastWan2.1-T2V-1.3B-mlx-int8")
...
dit = load_mlx_dit_checkpoint("FastWan2.1-T2V-1.3B-mlx-int8")
Format (one directory):
mlx_dit.safetensors— every array, saved withmx.save_safetensors. Plain weights keep their key; a quantized weightKis stored as the packedKplusK.scales(andK.biasesfor affine modes).mlx_dit.json— format version, the model config, the quantization spec, and which keys are quantized, so the loader can rebuildQuantizedMatrixobjects without guessing.
Classes¶
Functions:¶
fastvideo.mlx_runtime.checkpoint.load_mlx_dit_checkpoint ¶
Reconstruct an MLXWanDiT model from a versioned checkpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_dir | str | Path | Directory containing the checkpoint manifest and weights. | required |
compile | bool | Whether to configure the reconstructed model for compilation. | False |
Returns:
| Name | Type | Description |
|---|---|---|
MLXWanDiT | MLXWanDiT | The reconstructed model. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If the checkpoint manifest or weights file is missing. |
ValueError | If the checkpoint format is unsupported or block weights are incomplete. |
Source code in fastvideo/mlx_runtime/checkpoint.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
fastvideo.mlx_runtime.checkpoint.save_mlx_dit_checkpoint ¶
Save a plain or quantized MLX Wan DiT checkpoint to a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dit | MLXWanDiT | Model whose weights and configuration will be saved. | required |
checkpoint_dir | str | Path | Destination directory for the checkpoint. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Path | Path | Path to the checkpoint directory. |