From 1a1f92c93338f02063bcf98b7c3b6a3f6f70e40b Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 4 Sep 2025 14:46:47 +0200 Subject: [PATCH 1/6] [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 5fb31291a2..b37209f1d0 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/6] 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 b37209f1d0..852a4cb2d9 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/6] 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 852a4cb2d9..8ad4c9a114 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 From 46c944d66b9d1a0451b14715009fd61d0ad63302 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 8 Sep 2025 12:59:11 +0200 Subject: [PATCH 4/6] Update docs/hub/spaces-zerogpu.md Co-authored-by: Pedro Cuenca --- 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 8ad4c9a114..7ef87c4cc4 100644 --- a/docs/hub/spaces-zerogpu.md +++ b/docs/hub/spaces-zerogpu.md @@ -100,7 +100,7 @@ This sets the maximum function runtime to 120 seconds. Specifying shorter durati `@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: +Instead of directly passing a duration, simply pass a callable that takes the same inputs as your decorated function and returns a duration value: ```python def get_duration(prompt, steps): From a48f8b481e2dd15e0f82dff2e7731296b87b5143 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 8 Sep 2025 12:59:20 +0200 Subject: [PATCH 5/6] Update docs/hub/spaces-zerogpu.md Co-authored-by: Pedro Cuenca --- 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 7ef87c4cc4..3b77780394 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 (requires torch `2.8+`) +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 From c2e2fef7687166c220580f430c48f33bb008859d Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 8 Sep 2025 12:59:38 +0200 Subject: [PATCH 6/6] Update docs/hub/spaces-zerogpu.md Co-authored-by: Pedro Cuenca --- 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 3b77780394..8b9595e4bf 100644 --- a/docs/hub/spaces-zerogpu.md +++ b/docs/hub/spaces-zerogpu.md @@ -117,7 +117,7 @@ def generate(prompt, steps): 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 +Check out this [blogpost](https://huggingface.co/blog/zerogpu-aoti) for a complete guide on ahead-of-time compilation on ZeroGPU. ## Hosting Limitations