ZeroGPU native support - #13316
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/7dfee1b9bed972badc5abd3b6466849d9b9e1f1e/gradio-6.18.0-py3-none-any.whlInstall Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@7dfee1b9bed972badc5abd3b6466849d9b9e1f1e#subdirectory=client/python"Import Gradio JS Client from this PR via CDN import { Client } from "https://huggingface.co/buckets/gradio/npm-previews/resolve/7dfee1b9bed972badc5abd3b6466849d9b9e1f1e/browser.js"; |
🦄 change detectedThis Pull Request includes changes to the following packages.
|
|
This approach looks good to me @cbensimon |
For context I am working on sibling PR: I'll add the ZeroGPUMiddleware registration part once ready on PS: Keeping you updated! |
freddyaboulton
left a comment
There was a problem hiding this comment.
Code looks good @cbensimon ! Tried to test myself with spaces 0.50.0 dev version but the spaces image is hardcoding version 0.48
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 43dde93. Configure here.

Note
Medium Risk
Touches core request execution/queueing paths (context propagation, multiprocessing-safe progress/log emission) and adds a new middleware integration path, which could affect event handling and streaming behavior on Spaces.
Overview
Adds native Hugging Face Spaces ZeroGPU support via a new
gradio/zerogpu.pythat conditionally installsspaces.zero.ZeroGPUMiddleware, including custom exception mapping, log emission, disconnect detection, and worker contextualization.Refactors queued execution to capture and propagate
contextvarsfrom/queue/jointhroughroute_utils.call_process_apiandBlocks.process_api/call_function, covering sync/async and generator functions (includingSyncToAsyncIterator), and adds queue-side RPC plumbing for progress/log messages when events run in child processes.Removes the previous
spaces.gradio_auto_wrapbehavior, tweaks ZeroGPU detection (SPACES_ZERO_GPUaccepts"1"), makes server start timeout configurable viaGRADIO_START_TIMEOUT, updates test deps to includespaces, and adds tests ensuring request context propagation and cancellation behavior.Reviewed by Cursor Bugbot for commit 76cc566. Bugbot is set up for automated code reviews on this repo. Configure here.