Skip to content

Commit 1a1f92c

Browse files
authored
[ZeroGPU] Dynamic duration + compilation
1 parent 50e26f5 commit 1a1f92c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/hub/spaces-zerogpu.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ def generate(prompt):
8181

8282
This sets the maximum function runtime to 120 seconds. Specifying shorter durations for quicker functions will improve queue priority for Space visitors.
8383

84+
### Dynamic duration
85+
86+
`@spaces.GPU` also supports dynamic durations.
87+
88+
Instead of directly passing a duration, simply pass a callable that takes the same inputs as your decorated function and returns a duration:
89+
90+
```python
91+
def get_duration(prompt, steps):
92+
step_duration = 3.75
93+
return steps * step_duration
94+
95+
@spaces.GPU(duration=get_duration)
96+
def generate(prompt, steps):
97+
return pipe(prompt, num_inference_steps=steps).images
98+
```
99+
100+
101+
## Compilation
102+
103+
ZeroGPU does not support `torch.compile` but you can use PyTorch **ahead-of-time** compilation.
104+
105+
Checkout this [blogpost](https://huggingface.co/blog/zerogpu-aoti) for a complete compilation guide on ZeroGPU
106+
84107
## Hosting Limitations
85108

86109
- **Personal accounts ([PRO subscribers](https://huggingface.co/subscribe/pro))**: Maximum of 10 ZeroGPU Spaces.

0 commit comments

Comments
 (0)