[BugFix][Graph Optimization] Fix deterministic mode + CUDAGraph garbled output by making reset_share_inputs CUDAGraph-safe`#6746
Open
gongweibao wants to merge 2 commits intoPaddlePaddle:developfrom
Open
Conversation
|
gongweibao seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
Thanks for your contribution! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6746 +/- ##
==========================================
Coverage ? 71.95%
==========================================
Files ? 392
Lines ? 53848
Branches ? 8463
==========================================
Hits ? 38748
Misses ? 12328
Partials ? 2772
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Motivation
When
FD_DETERMINISTIC_MODE=1anduse_cudagraph=Trueare both enabled, model output is garbled. Either feature works correctly in isolation, but the combination fails.Root cause:
reset_share_inputs()is called after CUDAGraph capture in the deterministic mode post-warmup path (gpu_worker.py). Several lines insidereset_share_inputs()create new tensor objects (paddle.to_tensor(...)/paddle.full(...)), which allocate new GPU addresses. CUDAGraph has already baked the old addresses during capture, so replay reads/writes stale memory — producing garbage output.Modifications
fastdeploy/worker/input_batch.py:reasoning_allowed_tokens,free_list,free_list_len,rope_emb) that previously created new tensor objects inreset_share_inputs(), addFD_DETERMINISTIC_MODEguard to use in-place operations (fill_,copy_, slice assignment) instead, preserving GPU addresses for CUDAGraph safety.fastdeploy/worker/gpu_worker.py:if not self.model_runner.use_cudagraphskip aroundreset_share_inputs(). Sincereset_share_inputs()is now CUDAGraph-safe under deterministic mode, it can be called unconditionally.Accuracy Tests