Repository navigation
Conversation
This was referenced Aug 5, 2024
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/132820
Note: Links to docs will display an error until the docs builds have been completed. ❌ 5 New Failures, 1 Unrelated FailureAs of commit 86b9bf9 with merge base 4abe38b ( NEW FAILURES - The following jobs have failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
fegin
marked this pull request as draft
August 6, 2024 23:26
fegin
marked this pull request as ready for review
August 12, 2024 18:11
wanchaol
reviewed
Aug 12, 2024
wconstab
reviewed
Aug 21, 2024
wconstab
reviewed
Aug 21, 2024
wconstab
reviewed
Aug 21, 2024
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 21, 2024
**Summary** (WIP) This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. TODO: 1. Add seq_len scalability, loss convergence, and WPS performance benchmark. 2. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 21, 2024
**Summary** (WIP) This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. TODO: 1. Add seq_len scalability, loss convergence, and WPS performance benchmark. 2. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. [ghstack-poisoned]
Contributor
Author
|
@pytorchbot merge -f "The failing tests are not related." |
Collaborator
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 22, 2024
**Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence. [ghstack-poisoned]
XilunWu
added a commit
to pytorch/torchtitan
that referenced
this pull request
Oct 23, 2024
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * __->__ #592 **Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence.
SamGinzburg
pushed a commit
that referenced
this pull request
Oct 28, 2024
Summary: This implementation does not utilize the benefit that after allgather we can directly perform the SDPA without doing the ring-based SDPA, but we can overlap the communication with the first sharded kv computation. This implementation shows some performance benefit and memory saving compared to the original alltoall implementation in certain cases. Pull Request resolved: #132820 Approved by: https://github.com/XilunWu
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 13, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * __->__ pytorch#592 **Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence.
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 25, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * __->__ pytorch#592 **Summary** This PR adds DTensor Context Parallel (pytorch/pytorch#131351) option to torchtitan. **Instructions** Find the `context_parallel_degree` option in the `experimental` section in `.toml` file, assign the desired Context Parallel degree (i.e. the # of GPUs along the Context Parallel dimension). **Benchmark Settings** The benchmark uses `train_configs/llama3_8b.toml` with extra changes as below: - norm_type = "fused_rmsnorm" - mode = 'full' (using full activation checkpoint allows us to find the longest possible input sequence length on a device) **Benchmark Results** 1. *max seq_len scalability* The first set of benchmark shows that with CP, adding more GPUs on the CP dimension allows longer input seq_len and this growth is linearly scalable. We use FSDP to shard the model and fix `data_parallel_shard_degree` to be 8, and we use 8, 16, 32, 64 H100 GPUs (i.e. CP degree=1,2,4,8) to measure the longest possible input seq_len w/o GPU OOM. We adjust the CP degree by modifying the `context_parallel_degree` in the `experimental` section in `.toml` file. <img width="600" alt="image" src="https://github.com/user-attachments/assets/03f68062-3368-4ea5-a324-9d2346806af3"> *As Context Parallel degrees goes up (1, 2, 4, 8), the max seq_len also increases (32k, 80k, 144k, 300k)* <img width="597" alt="image" src="https://github.com/user-attachments/assets/b48078d3-ab4d-40dc-97cf-2d477b713e00"> *While increasing Context Parallel degree increases the max seq_len, it also decreases the WPS on each device. This is the price paid for longer input* <img width="593" alt="image" src="https://github.com/user-attachments/assets/edef69ef-f0f0-41ec-9114-f7c420929064"> *However, increasing CP degree doesn't significantly affect MFU.* 2. *loss curve convergence* The second set of benchmark proves that our implementation is correct by showing the loss curve converges just as FSDP + TP. This experiment uses 64 H100 GPUs and fix TP degree and local batch size to 8 (`tensor_parallel_degree=8`, `batch_size=8`). As we increase CP degree, we decrease DP degree to make sure that `CP * DP = 8`. Besides, we also make sure `seq_len` increases such that `seq_len = 8192 * CP`. <img width="1061" alt="image" src="https://github.com/user-attachments/assets/8a25e0b1-cbd4-46d5-a444-8dd6f5277227"> *The training loss curve matches among the 4 combination of parallelisms: DP=8; DP=4, CP=2; DP=2, CP=4; CP=8 (TP is fixed to 8).* <img width="2292" alt="Screenshot 2024-10-07 at 12 42 37 PM" src="https://github.com/user-attachments/assets/74a62cc8-562b-4441-babf-d601ec9bf375"> *The only observed difference is among the warm-up steps. This is due to our pick of the number of steps and picking an appropriate number of warm-up steps should smooth out this.* 3. *max seq_len vs. local WPS on a fixed number of GPUs* The third set of benchmark gives users a guide on what CP degree to choose and what WPS to expect on a specific set of devices (e.g. number of devices, device types, etc). Here we use H100 as an example but it is expected to observer similar trade-off curves on other hardware. <img width="830" alt="image" src="https://github.com/user-attachments/assets/b1ea2320-e0ae-439f-9434-4194bd4932a0"> *Increasing CP degree allows longer input sequence length at the cost of reducing WPS on each device. The exception is pure CP -- the seq_len increase is very limited compared to DP=2, CP=4 on 8 GPUs. This is due to our implementation, and we're working on enabling performant CP to support ultra-long input sequence.* TODO: 1. An option for CP tensor rotate implementation between all-to-all and all-gather will be added once pytorch/pytorch#132820 is landed. 2. Investigate the limitation in pure CP, to enable ultra-long input sequence.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stack from ghstack (oldest at bottom):
Summary:
This implementation does not utilize the benefit that after allgather we can directly perform the SDPA without doing the ring-based SDPA, but we can overlap the communication with the first sharded kv computation. This implementation shows some performance benefit and memory saving compared to the original alltoall implementation in certain cases.
cc @XilunWu @H-Huang @awgu @kwen2501 @wanchaol @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o