Skip to content

[feat] TP Sharding logic split to pattern detection and executor (fixes #5916) - #86

Merged
greg-kwasniewski1 merged 7 commits into
feat/ad-2025-07-07from
gk/sharding_config
Jul 16, 2025
Merged

[feat] TP Sharding logic split to pattern detection and executor (fixes #5916)#86
greg-kwasniewski1 merged 7 commits into
feat/ad-2025-07-07from
gk/sharding_config

Conversation

@greg-kwasniewski1

@greg-kwasniewski1 greg-kwasniewski1 commented Jul 14, 2025

Copy link
Copy Markdown

[https://github.com/NVIDIA/issues/5916][feat] TP Sharding logic split to pattern detection and executor

Description

column_row_shard, which directly modifying GraphModule, is replaced by two-step solution:

  • detect_column_row_shard(gm) -> List[TPSharingTransformation] is read-only w.r.t. gm and returns a list of detected _insert_sharded_matmul patterns,
  • transformation_executor() that consumes the sharding config and applies transformations on GraphModule

This first PR is just the first step, covering only tensor-parallel sharding. However, the transformation_executor is meant to be a container class for any graph transformations, especially other sharding strategies (MoE, BMM).

The expected benefit is that by detaching the pattern detection and graph transformations, the transformation config can be intercepted and either provided directly by a user, or inferred from model's config (e.g., Llama4 base_model_tp_plan ) .

Test Coverage

tests/unittest/_torch/auto_deploy/unit/multigpu/transformations/library/test_graph_sharding.py has been updated to test new sharding logic.

…sharding

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
@greg-kwasniewski1 greg-kwasniewski1 added the enhancement New feature or request label Jul 14, 2025
@lucaslie lucaslie changed the title [https://github.com/NVIDIA/TensorRT-LLM/issues/5916][feat] TP Sharding logic split to pattern detection and executor [feat] TP Sharding logic split to pattern detection and executor (fixes #5916) Jul 14, 2025
@lucaslie
lucaslie requested a review from suyoggupta July 14, 2025 22:27
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/library/sharding.py
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/library/sharding.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/library/sharding.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/library/sharding.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/library/sharding.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/transform.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/transform.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/transform.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/library/sharding.py Outdated
… functionality, applied to test_graph_sharding

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
…applies any generic transformations

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/library/base_transformations.py Outdated
…rk on node.name

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

@lucaslie lucaslie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@greg-kwasniewski1
greg-kwasniewski1 merged commit dc2f4fc into feat/ad-2025-07-07 Jul 16, 2025
1 check passed
lucaslie pushed a commit that referenced this pull request Jul 18, 2025
NVIDIA#5916) (#86)

* introduced basic sharding config logic

* transformation_executor works for TP parallelism. Updated test_graph_sharding

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Switched from dataclass to pydantic. Added run_pattern_detection_test functionality, applied to test_graph_sharding

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Restructured transformation execution logic. transformation_executor applies any generic transformations

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Detection + execution logic moved only to sharding. Transformation work on node.name

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Removed redundant params

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

---------

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
lucaslie pushed a commit that referenced this pull request Jul 21, 2025
NVIDIA#5916) (#86)

* introduced basic sharding config logic

* transformation_executor works for TP parallelism. Updated test_graph_sharding

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Switched from dataclass to pydantic. Added run_pattern_detection_test functionality, applied to test_graph_sharding

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Restructured transformation execution logic. transformation_executor applies any generic transformations

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Detection + execution logic moved only to sharding. Transformation work on node.name

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

* Removed redundant params

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>

---------

Signed-off-by: greg-kwasniewski1 <213329731+greg-kwasniewski1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants