-
Notifications
You must be signed in to change notification settings - Fork 7k
[docs][serve][llm] Add comprehensive architecture documentation for Ray Serve LLM #57830
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
[docs][serve][llm] Add comprehensive architecture documentation for Ray Serve LLM #57830
Conversation
Convert the Ray Serve LLM quickstart documentation from RST to MyST Markdown format. Changes: - Convert quick-start.rst to quick-start.md using MyST syntax - Apply Ray docs style guide (contractions, active voice, sentence case) - Convert all RST directives to MyST equivalents (tab-sets, code blocks, cross-refs) - No content changes, pure format conversion - Verified: builds successfully with no errors or warnings This is Phase 0 of the LLM docs reorganization plan. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create the directory structure for Ray Serve LLM documentation reorganization. Changes: - Add user-guides/ directory for user guide content - Add architecture/ directory for architecture docs - Add api/ directory for API reference This is Phase 1 of the LLM docs reorganization plan. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create a simple examples landing page that lists all available LLM tutorials. Changes: - Add examples.md with flat list of tutorial links - Include all 7 existing deployment tutorials - Follow style guide (sentence case, active voice) This is part of Phase 2 of the LLM docs reorganization plan. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Extract FAQ section from quick-start and create dedicated troubleshooting page. Changes: - Create troubleshooting.md with 3 FAQs: - How to use gated Huggingface models - Why is downloading the model so slow - How to configure tokenizer pool size - Add 'Get help' section with community links - Follow style guide (sentence case, contractions, active voice) This is part of Phase 2 of the LLM docs reorganization plan. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Extract Multi-LoRA documentation from quick-start into dedicated user guide. Changes: - Create user-guides/multi-lora.md with: - Overview of multi-LoRA deployment and when to use it - How request routing works with adapter caching - Configuration sections (LoRA config and engine arguments) - Complete server and client examples - Example queries for base model and adapters - Follow Ray docs style guide (sentence case, contractions, active voice) This is part of Phase 3 of the LLM docs reorganization plan. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Remove Multi-LoRA deployment section from quick-start as it's now a dedicated user guide. Changes: - Remove Multi-LoRA deployment section (server + client examples) - Content moved to user-guides/multi-lora.md This reduces quick-start.md from 917 to ~850 lines. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create user guide and architecture docs for request routing policies. Changes: - Add user-guides/prefix-aware-routing.md: - Overview and when to use prefix-aware routing - How it works (load balance, prefix matching, fallback) - Deployment example with corrected import path - Configuration parameters and best practices - Add architecture/routing-policies.md: - Routing vs ingress distinction - Request routing architecture - Available policies (Power of Two, Prefix-aware) - Design patterns (centralized store, broadcast metrics) - Custom routing policies with proper links to Ray Serve docs - Utility mixins documentation - Implementation details (async operations, state management) - Add routing policy diagrams (request_router_1.png, request_router_2.png) - Follow Ray docs style guide (sentence case, contractions, active voice) This is part of Phase 3 of the LLM docs reorganization plan. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Add index files and update main index to include new documentation sections. Changes: - Update serve/llm/index.md toctree to include: - Examples - User Guides (with index) - Architecture (with index) - Troubleshooting - Create user-guides/index.md with links to: - Multi-LoRA deployment - Prefix-aware routing - Create architecture/index.md with link to: - Request routing This resolves the 'document isn't included in any toctree' warnings. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Apply Ray docs style guide and improve clarity in routing-policies.md. Style improvements: - Use active voice and direct address (you/your) - Add code backticks for technical terms (model_id, OpenAiIngress, etc.) - Improve conversational tone - Change 'Choosing' to 'Choose' for imperative mood Image improvements: - Rename request_router_1.png → routing_centralized_store.png - Rename request_router_2.png → routing_broadcast_metrics.png - Update all image references in documentation These changes improve readability and align with Ray documentation standards. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Replace implementation-focused prefix-aware-request-router.md with the user-focused prefix-aware-routing.md in user guides. Changes: - Delete prefix-aware-request-router.md (implementation details) - Remove toctree entry from index.md - User guide (user-guides/prefix-aware-routing.md) is now the primary documentation for prefix-aware routing The new user guide focuses on practical usage (when to use, how to deploy, configuration) rather than implementation details, which aligns better with user needs. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create user-guides/prefill-decode.md to replace pd-dissagregation.md. Changes: - Create user-guides/prefill-decode.md with improved structure - Apply Ray docs style guide (active voice, contractions, you/your) - Remove VLLM_USE_V1 mention (v1 is now default) - Improve section organization and headings (sentence case, imperative) - Reorganize structure: Deploy with NIXLConnector → Deploy with LMCacheConnectorV1 - Add 'When to use' and 'Best practices' sections - Enhance troubleshooting section with specific guidance - Update user-guides/index.md to include new guide - Remove pd-dissagregation.md from main index.md toctree - Delete old pd-dissagregation.md file The new guide focuses on practical deployment steps while maintaining all technical content from the original. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create user-guides/vllm-compatibility.md to document vLLM feature support. Changes: - Create user-guides/vllm-compatibility.md with comprehensive coverage - Document embeddings, structured output, vision models, and reasoning models - Highlight Ray Serve LLM alignment with vLLM OpenAI-compatible server - Apply Ray docs style guide (active voice, you/your, sentence case) - Include practical examples for each feature with server/client code - Update user-guides/index.md to include new guide The guide emphasizes that users can switch between vllm serve and Ray Serve LLM with no code changes while gaining Ray Serve's production features (autoscaling, multi-model serving, advanced routing). Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create user-guides/model-loading.md for configuring model sources. Changes: - Create user-guides/model-loading.md with comprehensive coverage - Document loading from Hugging Face Hub with fast download - Document gated model authentication with HF_TOKEN - Document loading from S3/GCS remote storage - Include AWS credentials configuration (env vars and IAM roles) - Add cluster-wide environment variable configuration with ray.init - Include best practices for security, performance, and source selection - Add troubleshooting for slow downloads and access errors - Apply Ray docs style guide (active voice, contractions, 'such as') - Update user-guides/index.md to include new guide The guide consolidates model loading patterns extracted from quick-start FAQs and remote storage sections into a focused, practical resource. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Remove sections moved to dedicated user guides, reducing file by 53%. Removed sections: - Embeddings → moved to vllm-compatibility.md - Structured output → moved to vllm-compatibility.md - Vision language models → moved to vllm-compatibility.md - Fractional GPU serving → moved to fractional-gpu.md - Remote storage → moved to model-loading.md - Gated models FAQ → moved to model-loading.md - Fast download FAQ → moved to model-loading.md Changes: - Reduced from 845 to 398 lines (447 lines removed, 53% reduction) - Kept tokenizer pool size FAQ (not moved to user guides) - Maintained clean flow from multi-model section to FAQs - No linter errors The quick-start now focuses on core deployment patterns with links to dedicated user guides for advanced topics. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Remove placeholder files in preparation for PR. Changes: - Remove .gitkeep from user-guides/ - Remove .gitkeep from architecture/ - Remove api/.gitkeep and empty api/ directory The api/ directory will be added in a future PR focused on API reference documentation. This PR focuses on user guides. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create comprehensive architecture documentation for Ray Serve LLM. Changes: - Create architecture/overview.md - High-level architecture overview - What Ray Serve LLM provides (horizontal scaling, distributed strategies) - Ray Serve primitives (deployment, replica, handle) - Core components (LLMServer, OpenAiIngress) - Physical placement and engine management - Network topology and scaling considerations - Architecture patterns overview (data parallel, prefill-decode, routing) - Design principles - Create architecture/core.md - Technical implementation details - Core abstractions (LLMEngine protocol, LLMConfig, protocols) - Builder pattern for flexible deployment configuration - Async constructor pattern for engine initialization - Component relationships diagram - Extension points (custom engines, servers, ingress, builders) - Update architecture/index.md to include new docs in toctree Content extracted from kh/arch-docs branch design/core.md and adapted to Ray docs style guide. Split into two focused documents for better discoverability and different audiences (overview for understanding, core for extending). Full Ray docs style guide compliance: - Active voice throughout - Contractions used appropriately - Complete sentences for code lead-ins - Proper list punctuation - Consistent capitalization Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Create serving patterns documentation and copy images from arch-docs branch. Changes: - Copy architecture images from kh/arch-docs branch: - llmserver.png - LLMServer component diagram - placement.png - Physical placement strategy - llmserver-ingress-rpc.png - Network topology - pd.png - Prefill-decode architecture - dp.png - Data parallel architecture - dp_flow.png - Data parallel request flow - Create architecture/serving-patterns/ directory structure - index.md - Overview of serving patterns - prefill-decode.md - PD disaggregation architecture - Update architecture/index.md to include serving patterns Architecture doc for prefill-decode includes: - Resource characteristics comparison table - PDProxyServer component details - KV cache transfer backends (NIXLConnector, LMCacheConnectorV1) - Request flow with diagrams - Combining with data parallelism - Performance characteristics and design considerations - Full Ray docs style guide compliance Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Apply Ray documentation style guide improvements to prefill-decode.md. Changes: - Use active voice: 'The correct ratio...improves' instead of 'could improve' - Use contractions: 'it's' instead of 'it is', 'isn't' instead of 'are not' - Replace informal abbreviations: 'prefill instance' instead of 'P' - Improve clarity: 'when decode-limited' instead of long fragment - User-focused language: 'You should inspect' instead of 'this needs' - Better word choice: 'versus' instead of 'vs.' All changes maintain technical accuracy while improving readability and following Ray docs voice and grammar guidelines. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Refine data-parallel architecture documentation to focus on its primary use case: serving large sparse MoE models with expert parallelism. Changes: - Clarify that DP is most useful when combined with expert parallelism - Emphasize that replicas work together, not in isolation - Focus on MLA (Multi-head Latent Attention) benefits - Explain when DP helps: saturating experts with larger batch sizes - Remove unnecessary details about fault tolerance (to be designed) - Simplify scaling section to reflect static support only - Remove comparison table and custom routing details - Update pseudocode to show rank passing to engine Key insight: DP allows reaching larger batch sizes by utilizing sparsity of experts more efficiently in MoE + MLA architectures. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Apply Ray documentation style guide improvements to both files. data-parallel.md fixes: - Use contractions: 'aren't', 'don't', 'can't', 'isn't' - Fix typos: 'or' -> 'of', 'benefitional' -> 'beneficial', 'effecitve' -> 'effective', 'Psudocode' -> 'Pseudocode' - Improve clarity: 'qkv' -> 'attention (QKV) layers' - Define MLA (Multi-head Latent Attention) on first use deepseek-v3.md fixes: - Fix typo: 'builde_pd_openai_app' -> 'build_pd_openai_app' - Clarify eager mode comment - Update imports to use build_pd_openai_app helper - Update diagram to show 32 ingress replicas and 32 PDProxyServer replicas - Add note about ~2 PDProxyServer replicas per node - Update all examples to use P:32, D:96 scaling - Add request routing config to deployment_config - Simplify code by removing manual PDProxyServer construction All changes maintain technical accuracy while improving readability and following Ray docs voice and grammar guidelines. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Complete final missing pieces of documentation reorganization. Changes: - Create user-guides/observability.md: - Extract observability content from quick-start.md - Service-level metrics and engine metrics - Grafana dashboard documentation - Configuration examples for log_engine_metrics - Usage data collection information - Best practices for monitoring - Update quick-start.md: - Remove observability section (moved to user guide) - Remove gen_config CLI section (deprecated feature) - Add link to observability user guide - Streamline quick-start content - Update index.md with improved overview: - Better positioning: 'high-performance, scalable framework' - Add 'Why Ray Serve LLM?' section highlighting distributed workloads - Emphasize key differentiators (parallelism, PD disaggregation, routing) - Update features list to include new capabilities - Remove outdated 'Key Components' and 'Configuration' sections - Update user-guides/index.md to include observability guide Full Ray docs style guide compliance maintained throughout. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Co-authored-by: angelinalg <[email protected]> Signed-off-by: kourosh hakhamaneshi <[email protected]>
Co-authored-by: angelinalg <[email protected]> Signed-off-by: kourosh hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
…e the corresponding file. Update architecture overview to generalize serving patterns without specific mention of DeepSeek-V3. Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
|
/gemini review |
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.
Code Review
This pull request introduces extensive and well-structured architecture documentation for Ray Serve LLM, covering core components, abstractions, and serving patterns like data parallelism and prefill-decode disaggregation. My review focuses on improving the clarity and correctness of this new documentation. I've identified several areas for improvement, including fixing typos in documentation directives, correcting code examples to ensure they are valid, and highlighting placeholder content that needs to be completed. These suggestions aim to make the documentation more accurate and user-friendly for developers.
doc/source/serve/llm/architecture/serving-patterns/data-parallel.md
Outdated
Show resolved
Hide resolved
doc/source/serve/llm/architecture/serving-patterns/prefill-decode.md
Outdated
Show resolved
Hide resolved
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
|
/gemini review |
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.
Code Review
This pull request adds extensive and valuable architecture documentation for Ray Serve LLM. The new documents are well-structured and provide a great overview of the core components, serving patterns, and design principles. My review focuses on improving the correctness and clarity of the code examples provided in the documentation. I've identified a few instances of undefined variables, missing imports, and inconsistent method signatures in the code snippets, which could confuse users. Addressing these points will make the documentation more accurate and easier to follow.
doc/source/serve/llm/architecture/serving-patterns/data-parallel.md
Outdated
Show resolved
Hide resolved
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
|
/gemini review |
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.
Code Review
This pull request adds extensive and valuable architecture documentation for Ray Serve LLM. The new documents are well-structured, detailed, and cover core components, serving patterns, and design principles, which will be a great resource for developers. My review focuses on minor improvements to enhance clarity, consistency, and correctness in the documentation and code examples. Overall, this is an excellent contribution.
doc/source/serve/llm/architecture/serving-patterns/data-parallel.md
Outdated
Show resolved
Hide resolved
doc/source/serve/llm/architecture/serving-patterns/data-parallel.md
Outdated
Show resolved
Hide resolved
doc/source/serve/llm/architecture/serving-patterns/data-parallel.md
Outdated
Show resolved
Hide resolved
doc/source/serve/llm/architecture/serving-patterns/prefill-decode.md
Outdated
Show resolved
Hide resolved
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
ruisearch42
left a comment
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.
Nice docs, overall looks good
| @@ -0,0 +1,205 @@ | |||
| (serve-llm-architecture-data-parallel)= | |||
| # Data parallelism | |||
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.
Call this "Data parallel attention" to be more precise? Or clarify in the texts.
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.
done
|
|
||
| ## Architecture overview | ||
|
|
||
| ```{figure} ../../images/dp.png |
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.
The MP executor instead of Ray executor is currently used?
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.
Ray executor is still used. The MPClient is used not RayActorClient.
|
|
||
| - **Large sparse MoE with MLA**: Allows reaching larger batch sizes by utilizing the sparsity of the experts more efficiently. MLA (Multi-head Latent Attention) reduces KV cache memory requirements. | ||
| - **High throughput required**: You need to serve many concurrent requests. | ||
| - **KV-cache limited**: Adding more KV cache capacity increases throughput, so that parallelization of experts could effectively increase the capacity of KV-cache for handling concurrent requests. |
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.
so that parallelization of experts
This is benefit of EP?
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.
it's not meant to frame that we do EP because it increases kv-cache size (TP does that too). It's just a note that if we do EP kv-cache size increases.
The reader should get an idea of what the general thinking behind DP + EP is
|
|
||
| Data parallel serving works best when: | ||
|
|
||
| - **Large sparse MoE with MLA**: Allows reaching larger batch sizes by utilizing the sparsity of the experts more efficiently. MLA (Multi-head Latent Attention) reduces KV cache memory requirements. |
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.
The main motivation is attention weights and KV-cache cannot be partitioned along head dimension for MLA, and DP allows partition at request dimension?
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.
yeah.
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.
so you could do TP up to the degree that you can keep sharding your kv, after that to avoid duplication you can do DP.
So somehting like DP2TP4EP8 for Qwen-235b makes sense, instead of DP8EP8
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.
Added some clarification around this.
| Consider alternatives when: | ||
|
|
||
| - **Low to medium throughput**: If you can't saturate the MoE layers, don't use DP. | ||
| - **Non-MLA Attention**: DP is beneficial with MLA. Without DP (using TP instead), you need to replicate the KV cache, which isn't beneficial because you want to maximize batch size. As long as the KV cache can be sharded, using TP might be sufficient. |
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.
DP can benefit GQA as well? When TP_size > num_kv_heads
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.
yeah. do you think these are not coming across? Maybe I should be more explicit :D ?
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.
Added some clarification around this.
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.
replica is 1..N
but rank is 0..N
Should unify both to 0..N-1 ?
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.
yeah, it's minor. we'll do it when we create mermaid format of these figures.
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
…ay Serve LLM (ray-project#57830) Signed-off-by: Kourosh Hakhamaneshi <[email protected]> Signed-off-by: xgui <[email protected]>
…ay Serve LLM (#57830) Signed-off-by: Kourosh Hakhamaneshi <[email protected]> Signed-off-by: elliot-barn <[email protected]>
…ay Serve LLM (ray-project#57830) Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
…ay Serve LLM (ray-project#57830) Signed-off-by: Kourosh Hakhamaneshi <[email protected]> Signed-off-by: Aydin Abiar <[email protected]>
Summary
This PR adds complete architecture documentation for Ray Serve LLM, providing technical implementation details, serving patterns, and design documentation for developers building on and extending the framework.
Builds on: #57787 (Phase 1: User guides and structure)
Motivation
Ray Serve LLM is a sophisticated distributed serving framework, but lacked comprehensive architecture documentation explaining:
This documentation is essential for:
Changes
New Architecture Documentation
Core Architecture (2 documents)
architecture/overview.mdarchitecture/core.mdServing Patterns (4 documents)
architecture/serving-patterns/index.mdarchitecture/serving-patterns/prefill-decode.mdarchitecture/serving-patterns/data-parallel.mdarchitecture/serving-patterns/deepseek-v3.mdRequest Routing Architecture
architecture/routing-policies.mdFollowups to this PR: