Fix CUDA autotuning with released KV storage - #21486
Open
JacobSzwejbka wants to merge 3 commits into
Open
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21486
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unclassified FailureAs of commit c86b7c2 with merge base a1d4d35 ( NEW FAILURE - The following job has failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
Gasoonjia
approved these changes
Jul 30, 2026
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.
Summary
The Qwen3.5 MoE low-memory CUDA export frees zero-filled KV-cache storage before AOTInductor compilation. Triton autotuning subsequently calls
clone_preserve_strideson one of those tensors and fails because its logical 4 MiB view has zero bytes of backing storage. This currently breaks both Qwen3.5 CUDA export jobs and leaves the benchmark without an artifact.Rehydrate an emptied KV tensor temporarily on its original device when the clone originates outside
_unlift_graph. The existing CPU rehydration behavior for AOTI buffer lifting and serialization is unchanged._is_emptiedonly matches the all-zero KV buffers deliberately released by the low-memory path.Test plan
Added a CPU regression test that releases an empty-strided tensor storage, exercises the patched Inductor clone within
_compile_time_cpu_clones, and verifies shape, stride, storage size, and zero contents. Also ranblack --check,git diff --check,py_compile, and the helper regression directly against the patched source. Full Qwen3.5 CUDA export is running on release PR #21401.Authored with Claude.