Skip to content

Fix CUDA autotuning with released KV storage - #21486

Open
JacobSzwejbka wants to merge 3 commits into
mainfrom
fix/cuda-autotune-emptied-kv
Open

Fix CUDA autotuning with released KV storage#21486
JacobSzwejbka wants to merge 3 commits into
mainfrom
fix/cuda-autotune-emptied-kv

Conversation

@JacobSzwejbka

Copy link
Copy Markdown
Contributor

Summary

The Qwen3.5 MoE low-memory CUDA export frees zero-filled KV-cache storage before AOTInductor compilation. Triton autotuning subsequently calls clone_preserve_strides on 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_emptied only 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 ran black --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.

@pytorch-bot

pytorch-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🔗 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 Failure

As of commit c86b7c2 with merge base a1d4d35 (image):

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.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 30, 2026
@JacobSzwejbka
JacobSzwejbka requested a review from Gasoonjia July 30, 2026 04:04
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/cuda CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants