-
Notifications
You must be signed in to change notification settings - Fork 6
Wire up CLI for scan and host offloading #156
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
torchprime/torch_xla_models/configs/model/remat/llama-scan-offload.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
defaults: | ||
- llama-scan | ||
- _self_ | ||
|
||
offload_tensors: | ||
- decoder_input |
6 changes: 6 additions & 0 deletions
6
torchprime/torch_xla_models/configs/model/remat/llama-scan.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
defaults: | ||
- llama | ||
- _self_ | ||
|
||
# Compile the sequence of decoder layers at `model.layers` using scan. | ||
scan_layers: 'model.layers' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
activation_checkpoint_layers: | ||
- LlamaDecoderLayer | ||
|
||
# Refer to https://github.com/pytorch/xla/issues/6379 for backward optimization barrier info. | ||
optimization_barrier_layers: | ||
- LlamaDecoderLayer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
activation_checkpoint_layers: | ||
- MixtralDecoderLayer | ||
|
||
# Refer to https://github.com/pytorch/xla/issues/6379 for backward optimization barrier info. | ||
optimization_barrier_layers: | ||
- MixtralDecoderLayer |
37 changes: 0 additions & 37 deletions
37
torchprime/torch_xla_models/configs/model/scaling/llama-fsdp-tp.yaml
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
torchprime/torch_xla_models/configs/model/scaling/llama-fsdp.yaml
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
torchprime/torch_xla_models/configs/model/scaling/mixtral-fsdp.yaml
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
torchprime/torch_xla_models/configs/model/sharding/llama-fsdp-tp.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 2D (FSDP + TP) sharding configuration for Llama models. | ||
|
||
# Weights | ||
|
||
# TODO(https://github.com/AI-Hypercomputer/torchprime/issues/114): This | ||
# cannot be `[tensor, fsdp]`, or the gradients will sometimes become NaN. | ||
model.embed_tokens.weight: [fsdp, tensor] | ||
|
||
model.layers.*.self_attn.q_proj.weight: [tensor, fsdp] | ||
model.layers.*.self_attn.k_proj.weight: [tensor, fsdp] | ||
model.layers.*.self_attn.v_proj.weight: [tensor, fsdp] | ||
model.layers.*.self_attn.o_proj.weight: [fsdp, tensor] | ||
model.layers.*.mlp.gate_proj.weight: [tensor, fsdp] | ||
model.layers.*.mlp.up_proj.weight: [tensor, fsdp] | ||
model.layers.*.mlp.down_proj.weight: [fsdp, tensor] | ||
model.layers.*.input_layernorm.weight: [fsdp] | ||
model.layers.*.post_attention_layernorm.weight: [fsdp] | ||
model.norm.weight: [fsdp] | ||
lm_head.weight: [tensor, fsdp] | ||
|
||
# Activations | ||
model.layers.*.self_attn.q_proj: [fsdp, null, tensor] | ||
model.layers.*.self_attn.k_proj: [fsdp, null, tensor] | ||
model.layers.*.self_attn.v_proj: [fsdp, null, tensor] | ||
model.layers.*.self_attn.o_proj: [fsdp, null, tensor] | ||
model.layers.*.input_layernorm: [fsdp, null, tensor] | ||
model.layers.*.post_attention_layernorm: [fsdp, null, tensor] | ||
model.layers.*.mlp: [fsdp, null, tensor] | ||
model.layers.*: [fsdp, null, tensor] |
17 changes: 17 additions & 0 deletions
17
torchprime/torch_xla_models/configs/model/sharding/llama-fsdp.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Weights | ||
model.embed_tokens.weight: [fsdp, null] | ||
model.layers.*.self_attn.q_proj.weight: [fsdp, null] | ||
model.layers.*.self_attn.k_proj.weight: [null, fsdp] | ||
model.layers.*.self_attn.v_proj.weight: [null, fsdp] | ||
model.layers.*.self_attn.o_proj.weight: [fsdp, null] | ||
model.layers.*.mlp.gate_proj.weight: [fsdp, null] | ||
model.layers.*.mlp.up_proj.weight: [fsdp, null] | ||
model.layers.*.mlp.down_proj.weight: [null, fsdp] | ||
model.layers.*.input_layernorm.weight: [fsdp] | ||
model.layers.*.post_attention_layernorm.weight: [fsdp] | ||
model.norm.weight: [fsdp] | ||
lm_head.weight: [fsdp, null] | ||
|
||
# Activations | ||
model.layers.*: [fsdp, null, null] | ||
lm_head: [fsdp, null, null] |
18 changes: 18 additions & 0 deletions
18
torchprime/torch_xla_models/configs/model/sharding/mixtral-fsdp.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Weights | ||
model.embed_tokens.weight: ['fsdp', null] | ||
model.layers.*.self_attn.q_proj.weight: ['fsdp', null] | ||
model.layers.*.self_attn.k_proj.weight: [null, 'fsdp'] | ||
model.layers.*.self_attn.v_proj.weight: [null, 'fsdp'] | ||
model.layers.*.self_attn.o_proj.weight: ['fsdp', null] | ||
model.layers.*.block_sparse_moe.gate.weight: [null, 'fsdp'] | ||
model.layers.*.block_sparse_moe.experts.w1: [null, null, 'fsdp'] | ||
model.layers.*.block_sparse_moe.experts.w2: [null, 'fsdp', null] | ||
model.layers.*.block_sparse_moe.experts.w3: [null, null, 'fsdp'] | ||
model.layers.*.input_layernorm.weight: ['fsdp'] | ||
model.layers.*.post_attention_layernorm.weight: ['fsdp'] | ||
model.norm.weight: ['fsdp'] | ||
lm_head.weight: ['fsdp', null] | ||
|
||
# Activations | ||
model.layers.*[0]: [fsdp, null, null] # Shard the first output of the decoder layer | ||
lm_head: [fsdp, null, null] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.