From 1a1f92c93338f02063bcf98b7c3b6a3f6f70e40b Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 4 Sep 2025 14:46:47 +0200 Subject: [PATCH 1/3] [ZeroGPU] Dynamic duration + compilation --- docs/hub/spaces-zerogpu.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/hub/spaces-zerogpu.md b/docs/hub/spaces-zerogpu.md index 5fb31291a..b37209f1d 100644 --- a/docs/hub/spaces-zerogpu.md +++ b/docs/hub/spaces-zerogpu.md @@ -81,6 +81,29 @@ def generate(prompt): This sets the maximum function runtime to 120 seconds. Specifying shorter durations for quicker functions will improve queue priority for Space visitors. +### Dynamic duration + +`@spaces.GPU` also supports dynamic durations. + +Instead of directly passing a duration, simply pass a callable that takes the same inputs as your decorated function and returns a duration: + +```python +def get_duration(prompt, steps): + step_duration = 3.75 + return steps * step_duration + +@spaces.GPU(duration=get_duration) +def generate(prompt, steps): + return pipe(prompt, num_inference_steps=steps).images +``` + + +## Compilation + +ZeroGPU does not support `torch.compile` but you can use PyTorch **ahead-of-time** compilation. + +Checkout this [blogpost](https://huggingface.co/blog/zerogpu-aoti) for a complete compilation guide on ZeroGPU + ## Hosting Limitations - **Personal accounts ([PRO subscribers](https://huggingface.co/subscribe/pro))**: Maximum of 10 ZeroGPU Spaces. From 4d49582a0d6a55982e03debd6f72ae77ff0a61b0 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 4 Sep 2025 15:02:08 +0200 Subject: [PATCH 2/3] Revise supported versions for Gradio and PyTorch --- docs/hub/spaces-zerogpu.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/hub/spaces-zerogpu.md b/docs/hub/spaces-zerogpu.md index b37209f1d..852a4cb2d 100644 --- a/docs/hub/spaces-zerogpu.md +++ b/docs/hub/spaces-zerogpu.md @@ -33,9 +33,24 @@ ZeroGPU Spaces are designed to be compatible with most PyTorch-based GPU Spaces. ### Supported Versions -- Gradio: 4+ -- PyTorch: 2.1.2, 2.2.2, 2.4.0, 2.5.1 (Note: 2.3.x is not supported due to a [PyTorch bug](https://github.com/pytorch/pytorch/issues/122085)) -- Python: 3.10.13 +- **Gradio**: 4+ +- **PyTorch**: Almost all versions from **2.1.0** to **latest** are supported +
+ See full list + + - 2.1.0 + - 2.1.1 + - 2.1.2 + - 2.2.0 + - 2.2.2 + - 2.4.0 + - 2.5.1 + - 2.6.0 + - 2.7.1 + - 2.8.0 + +
+- **Python**: 3.10.13 ## Getting started with ZeroGPU From 4455e227d7bc9bf30885bf277b828b3a1b7eb41e Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 4 Sep 2025 15:03:53 +0200 Subject: [PATCH 3/3] Update ZeroGPU compilation note with version requirement --- docs/hub/spaces-zerogpu.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/hub/spaces-zerogpu.md b/docs/hub/spaces-zerogpu.md index 852a4cb2d..8ad4c9a11 100644 --- a/docs/hub/spaces-zerogpu.md +++ b/docs/hub/spaces-zerogpu.md @@ -115,7 +115,7 @@ def generate(prompt, steps): ## Compilation -ZeroGPU does not support `torch.compile` but you can use PyTorch **ahead-of-time** compilation. +ZeroGPU does not support `torch.compile` but you can use PyTorch **ahead-of-time** compilation (requires torch `2.8+`) Checkout this [blogpost](https://huggingface.co/blog/zerogpu-aoti) for a complete compilation guide on ZeroGPU