Skip to content

Commit 3e3ec73

Browse files
committed
fix: add missing all-gather for nnx vocab tiling
1 parent cf9b093 commit 3e3ec73

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/maxtext/utils/vocabulary_tiling.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ def _reshape(inputs, out_shape, out_sharding):
349349
# custom_vjp + lax.scan boundary, which fails for tied embeddings.
350350
graphdef, head_params, other_params, rest = nnx.split(model, _is_output_head_param_path, nnx.Param, ...)
351351

352+
# all gather only the embedding table
353+
head_params = all_gather_over_fsdp(
354+
head_params,
355+
nnx.get_partition_spec(head_params),
356+
model.mesh,
357+
config.logical_axis_rules,
358+
config.shard_mode,
359+
)
360+
352361
def _logits_for_chunk(chunk_head_params, chunk_other_params, chunk_rest, hidden_chunk):
353362
local_model = nnx.merge(graphdef, chunk_head_params, chunk_other_params, chunk_rest, copy=True)
354363
chunk_logits = local_model.logits_from_hidden_states_for_vocab_tiling(hidden_chunk, deterministic, model_mode)

0 commit comments

Comments
 (0)