Skip to content

Playground: ask before loading models too big for phones and tablets - #24030

Merged
psiddh merged 1 commit into
pytorch:mainfrom
psiddh:export-D126470374
Oct 20, 2026
Merged

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

Conversation

@psiddh

@psiddh psiddh commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary:
On iPhones, loading a chat model in the ExecuTorch WebGPU Playground closes the Safari tab during download or GPU setup. iOS kills the tab for memory, so the page gets no error it could show. The chat models need far more memory than a phone gives one tab: the downloaded bytes, the runtime's copy of the program, the GPU weights, and the fp32 KV cache each program allocates for its full 8,960-token context (Qwen 3 0.6B: 2.06 GB; Gemma 3 1B: 0.48 GB).

Before a demo starts loading, memory-guard.js estimates the peak: twice the download, plus the KV cache for chat models. On a phone or tablet (iPadOS included, which reports a Mac user agent), or on a device reporting 4 GB of memory or less, it shows a dialog when the estimate is over 400 MB. The dialog states the estimate, says phones often close the tab, and offers Cancel (focused) or Load anyway, once per model per page load. Today that covers the chat models (Qwen ~2.9 GB, Gemma ~1.8 GB) and Whisper (~0.5 GB); the vision demos stay under the limit and load as before. Desktops are unchanged.

This is a guardrail, not a fix. Re-exporting the chat models with a shorter context would cut the KV cache itself.

Differential Revision: D126470374

Summary:
On iPhones, loading a chat model in the ExecuTorch WebGPU Playground closes the Safari tab during download or GPU setup. iOS kills the tab for memory, so the page gets no error it could show. The chat models need far more memory than a phone gives one tab: the downloaded bytes, the runtime's copy of the program, the GPU weights, and the fp32 KV cache each program allocates for its full 8,960-token context (Qwen 3 0.6B: 2.06 GB; Gemma 3 1B: 0.48 GB).

Before a demo starts loading, `memory-guard.js` estimates the peak: twice the download, plus the KV cache for chat models. On a phone or tablet (iPadOS included, which reports a Mac user agent), or on a device reporting 4 GB of memory or less, it shows a dialog when the estimate is over 400 MB. The dialog states the estimate, says phones often close the tab, and offers Cancel (focused) or Load anyway, once per model per page load. Today that covers the chat models (Qwen ~2.9 GB, Gemma ~1.8 GB) and Whisper (~0.5 GB); the vision demos stay under the limit and load as before. Desktops are unchanged.

This is a guardrail, not a fix. Re-exporting the chat models with a shorter context would cut the KV cache itself.

Differential Revision: D126470374
Copilot AI balanced review requested due to automatic review settings October 20, 2026 20:00
@pytorch-bot

pytorch-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 07b439a with merge base d46a886 (image):
💚 Looks good so far! There are no failures yet. 💚

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 Oct 20, 2026

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 reached their quota limit.

@meta-codesync

meta-codesync Bot commented Oct 20, 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 D126470374.

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

@psiddh
psiddh merged commit b032012 into pytorch:main Oct 20, 2026
217 of 220 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