Skip to content

Commit e2c5f23

Browse files
committed
Cleanup for v7x
1 parent 971365c commit e2c5f23

3 files changed

Lines changed: 50 additions & 13 deletions

File tree

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@ ARG INSTALL_PATHWAYS_JAXLIB=false
9898

9999
# Ensure we install the TPU version, even if building locally.
100100
# Jax will fallback to CPU when run on a machine without TPU.
101-
RUN uv pip install --prerelease=allow .[core,tpu] && uv cache clean
101+
RUN uv pip install -qq --prerelease=allow .[core,tpu] && uv cache clean
102102
RUN if [ -n "$EXTRAS" ]; then uv pip install -qq .[$EXTRAS] && uv cache clean; fi
103103
RUN if [ "$INSTALL_PATHWAYS_JAXLIB" = "true" ]; then \
104104
uv pip install --prerelease=allow "jaxlib==0.5.3.dev20250918" \
105105
--find-links https://storage.googleapis.com/axlearn-wheels/wheels.html; \
106106
fi
107-
COPY --from=libtpu-target:latest /wheels /wheels
108-
RUN uv pip install --no-deps /wheels/*.whl && uv cache clean
107+
RUN uv pip install -qq --no-deps libtpu==0.0.26.dev20251022+nightly && uv cache clean
109108
COPY . .
110109

111110
################################################################################

axlearn/common/compiler_options.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,12 @@ def default_xla_options(
136136
if version == "v7x":
137137
options.update(
138138
# Many of the v7x flags are similar to v6e
139-
xla_tpu_dvfs_p_state=7,
140139
xla_tpu_scoped_vmem_limit_kib=65536,
141140
xla_tpu_enable_all_gather_offload_tracing="true",
142141
xla_tpu_enable_async_collective_fusion_fuse_all_gather="false",
143142
xla_enable_async_all_gather="true",
144143
xla_tpu_prefer_async_allgather_to_allreduce="true",
145-
xla_tpu_impure_enable_packed_bf16_math_ops="true",
144+
xla_tpu_bf16_emission_mode="NATIVE_EMISSION",
146145
)
147146

148147
# Ensure pipelining is properly configured
@@ -153,6 +152,7 @@ def default_xla_options(
153152
)
154153

155154
# v7x flags from MaxText, inclusing SparseCore configs
155+
# TODO(samuel-andersen): Move v7x SparseCore config below with v6e
156156
options.update(
157157
xla_tpu_enable_sparse_core_collective_offload_all_reduce="true",
158158
xla_tpu_enable_sparse_core_collective_offload_reduce_scatter="true",
@@ -209,7 +209,9 @@ def default_xla_options(
209209
continue
210210
elif isinstance(v, str):
211211
# Allow numeric strings, time-based strings (e.g., "10m", "30s", "60m"), and bool str.
212-
if v.isdigit() or re.match(r"^\d+[ms]$", v.strip()) or v.strip() in ["true", "false"]:
212+
if v.isdigit() or re.match(r"^\d+[ms]$", v.strip()) or v.strip() in [
213+
"true", "false", "NATIVE_EMISSION"
214+
]:
213215
continue
214216
# Allow paths.
215217
if v.startswith("/"):

axlearn/experiments/text/gpt/fuji.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,52 @@ def get_trainer_kwargs(
727727
),
728728
),
729729
(
730-
"tpu-v7x-.*",
730+
"tpu-v7x-128",
731731
ChainConfigModifier.default_config().set(
732732
config_modifiers=[
733733
MeshShapeModifier.default_config().set(
734-
mesh_shape=mesh_shape_from_axes(data=-1, fsdp=-1)
734+
mesh_shape=mesh_shape_from_axes(data=-1, fsdp=128)
735+
),
736+
# Ensure we set the default tpu_block_size=2048 on v7x
737+
# With the 70B model, MaxText also modifies block_q
738+
# and block_kv_compute to 4096 and 1024 respectively
739+
V7xFlashConfigModifier.default_config(),
740+
SplashAttentionConfigModifier.default_config().set(
741+
splash_block_q=4096,
742+
splash_block_kv_compute=1024,
743+
),
744+
RematSpecModifier.default_config().set(
745+
remat_policies={
746+
"model.decoder.transformer.layer": RematSpec(
747+
prevent_cse=False,
748+
policy=config_for_function(
749+
save_and_offload_only_these_names_regex
750+
).set(
751+
names_which_can_be_saved="|".join(
752+
[
753+
RematRegexSavePatterns.QKV_PROJ.value
754+
]
755+
),
756+
names_which_can_be_offloaded="|".join(
757+
[
758+
RematRegexSavePatterns.INPUT.value,
759+
]
760+
),
761+
offload_src="device",
762+
offload_dst="pinned_host",
763+
),
764+
),
765+
}
766+
),
767+
],
768+
),
769+
),
770+
(
771+
"tpu-v7x-256",
772+
ChainConfigModifier.default_config().set(
773+
config_modifiers=[
774+
MeshShapeModifier.default_config().set(
775+
mesh_shape=mesh_shape_from_axes(data=-1, fsdp=128)
735776
),
736777
# Ensure we set the default tpu_block_size=2048 on v7x
737778
# With the 70B model, MaxText also modifies block_q
@@ -748,11 +789,6 @@ def get_trainer_kwargs(
748789
policy=config_for_function(
749790
save_and_offload_only_these_names_regex
750791
).set(
751-
# names_which_can_be_saved="|".join(
752-
# [
753-
# RematRegexSavePatterns.QKV_PROJ.value
754-
# ]
755-
# ),
756792
names_which_can_be_saved=None,
757793
names_which_can_be_offloaded="|".join(
758794
[

0 commit comments

Comments
 (0)