-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Doc]Add the user_guide doc file regarding fine-grained TP. #5084
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
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e004e4c
Add the user_guide doc file regarding fine-grained TP.
zzhx1 f18c3fc
Improve doc
zzhx1 d700184
fix
zzhx1 32eca34
docs fix
Kurumi5210 7c9a4b6
Merge branch 'main' into finegrained-TP
Kurumi5210 fbb5554
fix name from comment
zzhx1 ba90d7b
Merge branch 'main' into finegrained-TP
zzhx1 3abadf3
Merge branch 'main' into finegrained-TP
jianzs 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
103 changes: 103 additions & 0 deletions
103
docs/source/user_guide/feature_guide/Fine_grained_TP.md
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,103 @@ | ||
| # Fine-Grained Tensor Parallelism (Finegrained TP) | ||
|
|
||
| ## Overview | ||
|
|
||
| Fine-Grained Tensor Parallelism (Finegrained TP) extends standard tensor parallelism by enabling **independent tensor parallel sizes for different model components**. Instead of applying a single global `tensor_parallel_size` to all layers, Finegrained TP allows users to configure separate TP size for key modules—such as embedding, language model head (lm_head), attention output projection (oproj), and MLP blocks—via the `finegrained_tp_config` parameter. | ||
|
|
||
| This capability supports heterogeneous parallelism strategies within a single model, providing finer control over weight distribution, memory layout, and communication patterns across devices. The feature is compatible with standard dense transformer architectures and integrates seamlessly into vLLM’s serving pipeline. | ||
|
|
||
| --- | ||
|
|
||
| ## Benefits of Finegrained TP | ||
|
|
||
| Fine-Grained Tensor Parallelism delivers two primary performance advantages through targeted weight sharding: | ||
|
|
||
| - **Reduced Per-Device Memory Footprint**: | ||
| Finegrained TP shards large weight matrices(如 LM Head、o_proj)across devices, lowering peak memory usage and enabling larger batches or deployment on memory-limited hardware—without quantization. | ||
|
|
||
| - **Faster Memory Access in GEMMs**: | ||
| In decode-heavy workloads, GEMM performance is often memory-bound. Weight sharding reduces per-device weight fetch volume, cutting DRAM traffic and improving bandwidth efficiency—especially for latency-sensitive layers like LM Head and o_proj. | ||
|
|
||
| Together, these effects allow practitioners to better balance memory, communication, and compute—particularly in high-concurrency serving scenarios—while maintaining compatibility with standard dense transformer models. | ||
|
|
||
| --- | ||
|
|
||
| ## Supported Scenarios | ||
|
|
||
| ### Models | ||
| Finegrained TP is **model-agnostic** and supports all standard dense transformer architectures, including Llama, Qwen, DeepSeek (base/dense variants), and others. | ||
|
|
||
| ### Component & Execution Mode Support | ||
|
|
||
| | TP config | Eager | Graph | Hybrid | Prefill | Decode | | ||
| | ------------- | ----- | ----- | ------ | ------- | ------ | | ||
| | **embedding** | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
| | **o_proj** | ❌ | ✅ | ❌ | ❌ | ✅ | | ||
| | **mlp** | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
| | **LMhead** | ✅ | ✅ | ✅ | ✅ | ✅ | | ||
|
|
||
| > ⚠️ Note: | ||
| > - `o_proj` TP is only supported in Graph mode during Decode, because dummy_run in eager mode will not trigger o_proj. | ||
| > - `mlp` TP supports dense models, or dense layers in MoE models. For example, the first three dense layers of DeepSeek-R1. | ||
|
|
||
| ### Configuration Limit: | ||
| The Fine-Grained TP size for any component must: | ||
| - Be **≤ the data-parallel (DP) size**, and | ||
| - **Evenly divide the DP size** (i.e., `dp_size % tp_size == 0`) to ensure valid device assignment and communication grouping. | ||
| > ⚠️ Violating these constraints will result in runtime errors or undefined behavior. | ||
|
|
||
| --- | ||
|
|
||
| ## How to Use Finegrained TP | ||
|
|
||
| ### Configuration Format: | ||
|
|
||
| Finegrained TP is controlled via the `finegrained_tp_config` field inside `--additional-config`. | ||
|
|
||
| ```bash | ||
| --additional-config '{ | ||
| "finegrained_tp_config": { | ||
| "embedding_tensor_parallel_size": 8, | ||
| "lmhead_tensor_parallel_size": 8, | ||
| "oproj_tensor_parallel_size": 8, | ||
| "mlp_tensor_parallel_size": 8 | ||
| } | ||
| }' | ||
| ``` | ||
|
zzhx1 marked this conversation as resolved.
|
||
|
|
||
| ### Example Usage: | ||
|
|
||
| ```bash | ||
| vllm serve deepseek-ai/DeepSeek-R1 \ | ||
| --data-parallel-size 16 \ | ||
| --tensor-parallel-size 1 \ | ||
| --enable-expert-parallel \ | ||
| --additional-config '{ | ||
| "finegrained_tp_config": { | ||
| "embedding_tensor_parallel_size": 8, | ||
| "lmhead_tensor_parallel_size": 8, | ||
| "mlp_tensor_parallel_size": 8 | ||
| } | ||
| }' | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Experimental Results | ||
|
|
||
| To evaluate the effectiveness of fine-grained TP in large-scale service scenarios, we use the model **DeepSeek-R1-W8A8**, deploy PD-separated decode instances in the environment of 32 cards Ascend 910B*64G (A2), with parallel configuration as DP32+EP32, and fine-grained TP size of 8, the performance data is as follows. | ||
|
|
||
| | Module | Memory Savings | TPOT Impact (batch=24) | | ||
| | ---------------- | -------------- | ------------------------- | | ||
| | o_proj TP = 8 | 5.8 GB | **+1.5 ms** (degradation) | | ||
| | LM head TP = 8 | 1.51 GB | **−1.2 ms** (improvement) | | ||
| | FFN TP = 8 | 0.9 GB | **−1.0 ms** (improvement) | | ||
| | Embedding TP = 8 | 1.51 GB | **−1.0 ms** (improvement) | | ||
| | **Total** | **9.72 GB** | — | | ||
|
|
||
| - We achieved significant gains in terms of high memory capacity on a single card, as well as the benefits of TPOT. | ||
| --- | ||
|
|
||
| ## ✅ Deployment Recommendations | ||
|
|
||
| Fine-grained TP is the **most effective** in the **decode instance** of PD separation, where models are typically deployed in all-DP mode. In this setup, sharding weight-heavy layers reduces redundant storage and memory pressure. | ||
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 |
|---|---|---|
|
|
@@ -18,5 +18,6 @@ kv_pool | |
| external_dp | ||
| large_scale_ep | ||
| ucm_deployment | ||
| Fine_grained_TP | ||
| speculative_decoding | ||
| ::: | ||
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.