Skip to content
Open
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
16 changes: 16 additions & 0 deletions src/maxtext/m3/configs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ class TrainerConfig(BaseModel):
remat_policy: str = "NONE"
names_which_can_be_saved: list[str] = Field(default_factory=list)
names_which_can_be_offloaded: list[str] = Field(default_factory=list)
prefetch_fsdp_weights: bool = Field(
default=False,
description=(
"Overlap next scanned layer's FSDP weight all-gather with current layer compute (requires"
" scan_layers=True and non-'none' remat_policy). Known limitation: remat_policy='minimal_offloaded'"
" compiles and matches numerics, but synchronous host-stack DMA stalls PCIe on TPU7x; pair with"
" remat_policy='full' or device-resident savepoints for peak throughput."
),
)
prefetch_fsdp_defer_grad_reduce_scatter: bool = Field(
default=False,
description=(
"With prefetch_fsdp_weights and shard_mode='explicit', defer each layer's weight-gradient"
" reduce-scatter to the next layer's backward step (extra HBM for one layer of unreduced grads)."
),
)
enable_tile_search: bool = False
tile_search_mode: str = "smart"
tile_search_iters: int = 10
Expand Down
3 changes: 2 additions & 1 deletion src/maxtext/m3/infra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Modules:
* `scan.py` — layer stacking via `jax.lax.scan` + `maybe_apply_scan`.
* `remat.py` — path-transparent remat policies, `maybe_apply_remat`, and `check_tags`.
* `fsdp_prefetch.py` — double-buffered FSDP weight prefetch & deferred reduce-scatter for `ScannedLayers`.
* `quantization.py` — `maybe_quantize`: qwix int8 / fp8 by interception, over
the projection layers of the decoder stack.
* `named_scopes.py` — `jax.named_scope` per submodule, so profiles and HLO
Expand All @@ -27,7 +28,7 @@

Composition order is fixed, and `maxtext.m3.train.loop.setup_model` is the
reference for it:
`construct -> scan -> remat -> quantize -> named scopes -> optimizer -> host offload`.
`construct -> scan -> remat -> fsdp_prefetch -> quantize -> named scopes -> optimizer -> host offload`.

None of these wrap the model in another module, and quantization leaves the
variable tree untouched (asserted). Model files contain only zero-cost
Expand Down
Loading
Loading