[Feature] [Clone from PR#10645] Support deterministic inference with triton backend#10674
[Feature] [Clone from PR#10645] Support deterministic inference with triton backend#10674yushengsu-thu wants to merge 32 commits intosgl-project:mainfrom yushengsu-thu:yusheng-thu_triton_det
Conversation
Summary of ChangesHello @yushengsu-thu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the SGLang framework by introducing comprehensive support for deterministic inference, particularly for the Triton attention backend. The core objective is to ensure that given the same input and configuration, the model consistently produces identical outputs, regardless of batching strategies or other non-deterministic factors. This is achieved through careful modifications to attention backends, scheduler logic, and the introduction of new configuration options, all validated by a dedicated test suite. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for deterministic inference with the Triton backend, which is a great feature for reproducibility. The changes are extensive, touching several files to plumb through the deterministic inference configuration and adapt the attention and normalization layers. The addition of a new test file for deterministic inference is also a valuable contribution.
My review focuses on improving code clarity and maintainability. I've identified several areas in triton_backend.py with redundant logic, commented-out code, and development artifacts that should be cleaned up. I also suggest a small refactoring in layernorm.py to avoid direct environment variable access, improving modularity.
… (flashinfer backend)
… (flashinfer backend)
| "SGLANG_FLASHINFER_DECODE_SPLIT_TILE_SIZE", 2048 | ||
| ) | ||
| self.disable_cuda_graph_kv_split = True | ||
| global_config.flashinfer_workspace_size = 2048 * 1024 * 1024 |
There was a problem hiding this comment.
also use env var to optionally change this?
|
@Fridge003 @ispobock @Edenzzzz |
Motivation
Part of #10278
Clone from PR#10645
Reference: Defeating Non-Determinism in LLM Inference
Thanks to the earlier work from @Fridge003, @Edenzzzz, @hebiao064, and @Qiaolin-Yu in the following PRs:
FlashInfer: flashinfer-ai/flashinfer#1675
SGLang FlashInfer: #10645
SGLang DET POC: #10417
SGLang Support deterministic inference with FA3 backend: #10651
Context
Fix
sglang/python/sglang/srt/layers/attention/triton_backend.pyto support triton-backend deterministic inferenceModifications
python/sglang/srt/layers/attention/triton_backend.pypython/sglang/srt/server_args.pyAccuracy Tests
Launch SGLang server:
Benchmarking and Profiling
Checklist