Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use general way to access and update submodules #381

Merged
merged 1 commit into from
Jun 3, 2024
Merged
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
4 changes: 2 additions & 2 deletions torchtitan/parallelisms/parallelize_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def parallelize_llama(model, world_mesh, parallel_dims, job_config: JobConfig):
# apply AC + torch.compile
ac_config = job_config.activation_checkpoint
enable_compile = job_config.training.compile
for layer_id, transformer_block in model.layers.items():
for layer_id, transformer_block in model.layers.named_children():
if ac_config.mode in ("full", "selective"):
transformer_block = checkpoint_wrapper(transformer_block, ac_config)
if enable_compile:
Expand All @@ -379,7 +379,7 @@ def parallelize_llama(model, world_mesh, parallel_dims, job_config: JobConfig):
# compile time.
# torch._dynamo.config.inline_inbuilt_nn_modules = True
transformer_block = torch.compile(transformer_block, dynamic=False)
model.layers[layer_id] = transformer_block
model.layers.register_module(layer_id, transformer_block)

if ac_config.mode in ("full", "selective"):
logger.info(f"Applied {ac_config.mode} activation checkpointing to the model")
Expand Down
Loading