[bugfix] Fix caching of dynamic FlyDSL stage2 tensors - #4998
Open
RolaoDenthu wants to merge 2 commits into
Open
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
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
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.
Co-authored-by: @1am9trash
Motivation
When launching a Kimi-K3 server with SGLang in our TP8 setup, GPU OOM occurred when
--chunked-prefill-sizewas set to 8192 or higher. This happens after AITER #4642 switched the K3 stage2 kernel fromopus_moe2_*toflydsl_moe2_layout_*.The OOM was caused by the FlyDSL stage2 path passing per-layer dynamic MoE tensors through an LRU-cached conversion helper, which kept their GPU storage alive across layers.
The cached scale conversion helper was originally introduced to reuse uint8 views of static weight scales. It was later also used for dynamic, non-weight MoE tensors in FlyDSL stage2. Since the cache retains references to these tensors, their GPU memory cannot be released after each layer and instead accumulates across layers.
Technical Details
Added an uncached
_mxfp4_tensor_u8helper for dynamic and non-scale MoE tensors. The existing_mxfp4_scale_u8helper remains cached and is now used only for static weight scales.Test Plan
Test Result
Submission Checklist