-
Notifications
You must be signed in to change notification settings - Fork 357
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
Tensor parallel documentation #3359
Draft
apbose
wants to merge
1
commit into
main
Choose a base branch
from
nccl_ops_documentation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
github-actions
bot
added
the
documentation
Improvements or additions to documentation
label
Jan 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/examples/distributed_inference/tensor_parallel_llama3.py 2025-01-17 00:49:54.427641+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/distributed_inference/tensor_parallel_llama3.py 2025-01-17 00:50:14.910448+00:00
@@ -64,11 +64,11 @@
device="cuda",
)
with torch.no_grad():
# The plan is
- #plan = {
+ # plan = {
# "attention": PrepareModuleInput(
# input_layouts=(Shard(1), None),
# desired_input_layouts=(Replicate(), None),
# ),
# "attention.wq": ColwiseParallel(),
@@ -82,22 +82,22 @@
# ),
# "feed_forward.w1": ColwiseParallel(),
# "feed_forward.w2": RowwiseParallel(output_layouts=Shard(1)),
# "feed_forward.w3": ColwiseParallel(),
# "ffn_norm": SequenceParallel(),
- #}
+ # }
model = ParallelTransformer(model_args, device_mesh)
-# %%
-# Model inference with Torch-TensorRT backend
-# -------------------------------------------
-# When we compile the distributed model using Torch-TensorRT backend, pytorch distributed libraries create the sharded model
-# on multiple GPUs and the communicator operations are used for proper communication. In the above,
-# `ColwiseParallel` and `RowwiseParallel` shard the attention layers in the column or row fashion.
-# `SequenceParallel` performs sharded computations of the normalization layer
-# `PrepareModuleInput` configures the model input with proper communication operations
+ # %%
+ # Model inference with Torch-TensorRT backend
+ # -------------------------------------------
+ # When we compile the distributed model using Torch-TensorRT backend, pytorch distributed libraries create the sharded model
+ # on multiple GPUs and the communicator operations are used for proper communication. In the above,
+ # `ColwiseParallel` and `RowwiseParallel` shard the attention layers in the column or row fashion.
+ # `SequenceParallel` performs sharded computations of the normalization layer
+ # `PrepareModuleInput` configures the model input with proper communication operations
torch.manual_seed(0)
inp = torch.randint(32000, (8, 256), device="cuda")
python_result = model(inp)
torch_tensorrt.runtime.set_multi_device_safe_mode(True)
apbose
changed the title
Tensor parallel Llama3 tutorial illustrating use of torch.distributed…
Tensor parallel documentation
Jan 17, 2025
apbose
force-pushed
the
nccl_ops_documentation
branch
from
January 17, 2025 00:57
0313372
to
d511d80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/examples/distributed_inference/tensor_parallel_llama3.py 2025-01-17 00:57:39.378946+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/distributed_inference/tensor_parallel_llama3.py 2025-01-17 00:57:59.494626+00:00
@@ -64,11 +64,11 @@
device="cuda",
)
with torch.no_grad():
# The plan is
- #plan = {
+ # plan = {
# "attention": PrepareModuleInput(
# input_layouts=(Shard(1), None),
# desired_input_layouts=(Replicate(), None),
# ),
# "attention.wq": ColwiseParallel(),
@@ -82,23 +82,23 @@
# ),
# "feed_forward.w1": ColwiseParallel(),
# "feed_forward.w2": RowwiseParallel(output_layouts=Shard(1)),
# "feed_forward.w3": ColwiseParallel(),
# "ffn_norm": SequenceParallel(),
- #}
+ # }
model = ParallelTransformer(model_args, device_mesh)
-# %%
-# Model inference with Torch-TensorRT backend
-# -------------------------------------------
-# When we compile the distributed model using Torch-TensorRT backend, pytorch distributed libraries create the sharded model
-# on multiple GPUs and the communicator operations are used for proper communication. In the above,
-# `ColwiseParallel` and `RowwiseParallel` shard the attention layers in the column or row fashion.
-# `SequenceParallel` performs sharded computations of the normalization layer
-# `PrepareModuleInput` configures the model input with proper communication operations
-# The NCCL operations used in the distributed backend is handled by the TensorRT-LLM NCCL plugins, which causes no graph breaks now
+ # %%
+ # Model inference with Torch-TensorRT backend
+ # -------------------------------------------
+ # When we compile the distributed model using Torch-TensorRT backend, pytorch distributed libraries create the sharded model
+ # on multiple GPUs and the communicator operations are used for proper communication. In the above,
+ # `ColwiseParallel` and `RowwiseParallel` shard the attention layers in the column or row fashion.
+ # `SequenceParallel` performs sharded computations of the normalization layer
+ # `PrepareModuleInput` configures the model input with proper communication operations
+ # The NCCL operations used in the distributed backend is handled by the TensorRT-LLM NCCL plugins, which causes no graph breaks now
torch.manual_seed(0)
inp = torch.randint(32000, (8, 256), device="cuda")
python_result = model(inp)
torch_tensorrt.runtime.set_multi_device_safe_mode(True)
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.
Tensor parallel Llama3 tutorial illustrating use of torch.distributed and nccl ops
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: