Skip to content

Phonon: keep the Mimi decoder state on the GPU for CUDA (#25021) - #25021

Merged
psiddh merged 1 commit into
pytorch:mainfrom
psiddh:export-D131675810
Nov 14, 2026
Merged

psiddh merged 1 commit into
pytorch:mainfrom
psiddh:export-D131675810

Conversation

@psiddh

@psiddh psiddh commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

mimi_decode takes its streaming state (15 tensors, 2.1 MB, mostly the decoder transformer's keys and values) as inputs and returns it as outputs, so on CUDA every 80 ms frame copied it to the GPU and back, with a synchronization each way. That made mimi_decode take 4 ms in the runtime against 1.3 ms for the compiled graph.

StatefulMimiDecode wraps MimiDecodeStep and keeps the state in mutable buffers of the program (MimiState): forward(latent, reset) -> pcm, where reset = 1 starts an utterance from the zero state. The CUDA export uses it (mimi_state_in_program in export_phonon.py); the other backends keep the state as inputs and outputs. The program records the choice in a new mimi_state_in_program constant and phonon.json, the C++ and Python runners pass (latent, reset) when it is set, and format_version is now 2, so the runners ask to re-export older programs.

This diff was written with the help of Claude Code (Claude Opus 5.5).

Reviewed By: shoumikhin, Gasoonjia

Differential Revision: D131675810

Copilot AI balanced review requested due to automatic review settings November 13, 2026 05:57
@pytorch-bot

pytorch-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25021

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 1 Pending

As of commit 2d35fa1 with merge base fe03d52 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@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 Nov 13, 2026
@meta-codesync

meta-codesync Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D131675810.

@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.

@meta-codesync meta-codesync Bot changed the title Phonon: keep the Mimi decoder state on the GPU for CUDA Phonon: keep the Mimi decoder state on the GPU for CUDA (#25021) Nov 13, 2026
psiddh added a commit to psiddh/executorch that referenced this pull request Nov 13, 2026
Summary:
Pull Request resolved: pytorch#25021

mimi_decode takes its streaming state (15 tensors, 2.1 MB, mostly the decoder transformer's keys and values) as inputs and returns it as outputs, so on CUDA every 80 ms frame copied it to the GPU and back, with a synchronization each way. That made mimi_decode take 4 ms in the runtime against 1.3 ms for the compiled graph.

StatefulMimiDecode wraps MimiDecodeStep and keeps the state in mutable buffers of the program (MimiState): forward(latent, reset) -> pcm, where reset = 1 starts an utterance from the zero state. The CUDA export uses it (mimi_state_in_program in export_phonon.py); the other backends keep the state as inputs and outputs. The program records the choice in a new mimi_state_in_program constant and phonon.json, the C++ and Python runners pass (latent, reset) when it is set, and format_version is now 2, so the runners ask to re-export older programs.

This diff was written with the help of Claude Code (Claude Opus 5.5).

Differential Revision: D131675810
Copilot AI balanced review requested due to automatic review settings November 13, 2026 17:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Gasoonjia Gasoonjia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

psiddh added a commit to psiddh/executorch that referenced this pull request Nov 13, 2026
Summary:
Pull Request resolved: pytorch#25021

mimi_decode takes its streaming state (15 tensors, 2.1 MB, mostly the decoder transformer's keys and values) as inputs and returns it as outputs, so on CUDA every 80 ms frame copied it to the GPU and back, with a synchronization each way. That made mimi_decode take 4 ms in the runtime against 1.3 ms for the compiled graph.

StatefulMimiDecode wraps MimiDecodeStep and keeps the state in mutable buffers of the program (MimiState): forward(latent, reset) -> pcm, where reset = 1 starts an utterance from the zero state. The CUDA export uses it (mimi_state_in_program in export_phonon.py); the other backends keep the state as inputs and outputs. The program records the choice in a new mimi_state_in_program constant and phonon.json, the C++ and Python runners pass (latent, reset) when it is set, and format_version is now 2, so the runners ask to re-export older programs.

This diff was written with the help of Claude Code (Claude Opus 5.5).

Reviewed By: Gasoonjia

Differential Revision: D131675810
Copilot AI balanced review requested due to automatic review settings November 13, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

psiddh added a commit to psiddh/executorch that referenced this pull request Nov 14, 2026
Summary:

mimi_decode takes its streaming state (15 tensors, 2.1 MB, mostly the decoder transformer's keys and values) as inputs and returns it as outputs, so on CUDA every 80 ms frame copied it to the GPU and back, with a synchronization each way. That made mimi_decode take 4 ms in the runtime against 1.3 ms for the compiled graph.

StatefulMimiDecode wraps MimiDecodeStep and keeps the state in mutable buffers of the program (MimiState): forward(latent, reset) -> pcm, where reset = 1 starts an utterance from the zero state. The CUDA export uses it (mimi_state_in_program in export_phonon.py); the other backends keep the state as inputs and outputs. The program records the choice in a new mimi_state_in_program constant and phonon.json, the C++ and Python runners pass (latent, reset) when it is set, and format_version is now 2, so the runners ask to re-export older programs.

This diff was written with the help of Claude Code (Claude Opus 5.5).

Reviewed By: shoumikhin, Gasoonjia

Differential Revision: D131675810
Copilot AI balanced review requested due to automatic review settings November 14, 2026 03:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

psiddh added a commit to psiddh/executorch that referenced this pull request Nov 14, 2026
Summary:

mimi_decode takes its streaming state (15 tensors, 2.1 MB, mostly the decoder transformer's keys and values) as inputs and returns it as outputs, so on CUDA every 80 ms frame copied it to the GPU and back, with a synchronization each way. That made mimi_decode take 4 ms in the runtime against 1.3 ms for the compiled graph.

StatefulMimiDecode wraps MimiDecodeStep and keeps the state in mutable buffers of the program (MimiState): forward(latent, reset) -> pcm, where reset = 1 starts an utterance from the zero state. The CUDA export uses it (mimi_state_in_program in export_phonon.py); the other backends keep the state as inputs and outputs. The program records the choice in a new mimi_state_in_program constant and phonon.json, the C++ and Python runners pass (latent, reset) when it is set, and format_version is now 2, so the runners ask to re-export older programs.

This diff was written with the help of Claude Code (Claude Opus 5.5).

Reviewed By: shoumikhin, Gasoonjia

Differential Revision: D131675810
Copilot AI balanced review requested due to automatic review settings November 14, 2026 07:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

psiddh added a commit to psiddh/executorch that referenced this pull request Nov 14, 2026
Summary:

mimi_decode takes its streaming state (15 tensors, 2.1 MB, mostly the decoder transformer's keys and values) as inputs and returns it as outputs, so on CUDA every 80 ms frame copied it to the GPU and back, with a synchronization each way. That made mimi_decode take 4 ms in the runtime against 1.3 ms for the compiled graph.

StatefulMimiDecode wraps MimiDecodeStep and keeps the state in mutable buffers of the program (MimiState): forward(latent, reset) -> pcm, where reset = 1 starts an utterance from the zero state. The CUDA export uses it (mimi_state_in_program in export_phonon.py); the other backends keep the state as inputs and outputs. The program records the choice in a new mimi_state_in_program constant and phonon.json, the C++ and Python runners pass (latent, reset) when it is set, and format_version is now 2, so the runners ask to re-export older programs.

This diff was written with the help of Claude Code (Claude Opus 5.5).

Reviewed By: shoumikhin, Gasoonjia

Differential Revision: D131675810
Summary:

mimi_decode takes its streaming state (15 tensors, 2.1 MB, mostly the decoder transformer's keys and values) as inputs and returns it as outputs, so on CUDA every 80 ms frame copied it to the GPU and back, with a synchronization each way. That made mimi_decode take 4 ms in the runtime against 1.3 ms for the compiled graph.

StatefulMimiDecode wraps MimiDecodeStep and keeps the state in mutable buffers of the program (MimiState): forward(latent, reset) -> pcm, where reset = 1 starts an utterance from the zero state. The CUDA export uses it (mimi_state_in_program in export_phonon.py); the other backends keep the state as inputs and outputs. The program records the choice in a new mimi_state_in_program constant and phonon.json, the C++ and Python runners pass (latent, reset) when it is set, and format_version is now 2, so the runners ask to re-export older programs.

This diff was written with the help of Claude Code (Claude Opus 5.5).

Reviewed By: shoumikhin, Gasoonjia

Differential Revision: D131675810
@psiddh
psiddh merged commit a532d10 into pytorch:main Nov 14, 2026
262 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants