Repository navigation
Add diffusers serve to CLI #15017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DN6
wants to merge
29
commits into
main
Choose a base branch
from
diffusers-serve
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,391
−21
Open
Add diffusers serve to CLI #15017
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
260ae4a
add diffusers serve and generate commands
DN6 3e4aa57
add remote serve
DN6 5bc3948
update
DN6 fc92295
update
DN6 c964faf
Merge remote-tracking branch 'origin/main' into diffusers-serve
DN6 c8967b0
Address serve review feedback and run serve --remote on HF Jobs
DN6 a5781d1
Add context-parallel serving and allow --compile with --context-parallel
DN6 a60093d
Restore --compile with --context-parallel guard
DN6 3df7581
clean up
DN6 b81768c
Remove the SGLang and vLLM-Omni serve backends and clean up the serve…
DN6 a7e8ea0
Reorganize serve modules and validate manifests at startup
DN6 ccdcc36
Flatten serve response formatting into _format_job_response and _form…
DN6 2fd5dcb
Derive serve fps and sample rate from the model and merge parallel.py…
DN6 8e8f6c3
Seed request seeds from the global RNG and build job responses inside…
DN6 c746c03
Resolve outputs, fps and adapter weights in the manifest so the backe…
DN6 7179858
Address review: validate adapter repo ids, add --generation-timeout
DN6 8830305
Wait on the event loop, time out by deadline, and drop low-value serv…
DN6 29ad358
Simplify serve: inline single-use helpers, drop 501 stubs, shorten docs
DN6 57c1686
Merge branch 'main' into diffusers-serve
DN6 e66798c
Remove ParallelBackend
DN6 196fb0f
Harden serve media inputs, support modular step callbacks, and simpli…
DN6 aa2a41c
Drop fraction from progress events
DN6 52f2be3
Clean up
DN6 7ef87c6
Add Generative Media Spec docs (#15323)
apolinario c592639
Address review comments
DN6 89bc8a2
Accept model positionally in run and serve
DN6 7ab2cdf
Address review comments
DN6 8b14b0b
Merge branch 'main' into diffusers-serve
sayakpaul 3ee9fd4
Use `insert_step_callback` for modular step progress
DN6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| <!--Copyright 2026 The HuggingFace Team. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations under the License. | ||
| --> | ||
|
|
||
| # Generative Media Spec | ||
|
|
||
| The [Generative Media Spec](https://github.com/huggingface/gms-alpha) (GMS) is an open HTTP API for serving image, | ||
| video, and audio generation models. Any GMS client works with any GMS server, and a model exposes the same interface | ||
| everywhere it is hosted. [`diffusers serve`](./serve) is a GMS server. | ||
|
|
||
| > [!TIP] | ||
| > GMS is in alpha. The full specification, the [OpenAPI definition](https://github.com/huggingface/gms-alpha/blob/main/openapi.yaml) | ||
| > and the [manifest JSON Schema](https://github.com/huggingface/gms-alpha/blob/main/schemas/manifest.schema.json) | ||
| > live in the [GMS repository](https://github.com/huggingface/gms-alpha). Feedback is welcome there. | ||
|
|
||
| Every request follows one loop: | ||
|
|
||
| 1. **Discover.** `GET /v1/models/{id}` returns the model's manifest: its tasks, inputs, outputs, parameters and | ||
| presets, plus what the server supports. | ||
| 2. **Generate.** `POST /v1/generations` creates a generation from a model, its `inputs` and its `parameters`. | ||
| 3. **Follow along.** A generation goes from `queued` to `generating` to `complete`. Poll it, or subscribe to | ||
| `GET /v1/generations/{id}/events` for progress and previews. | ||
| 4. **Read the results.** The completed generation lists its named outputs, the seed that was used, and the model | ||
| revision that ran. | ||
|
|
||
| ## Manifests | ||
|
|
||
| A manifest is the machine-readable description of one model. Clients render interfaces and validate requests from it, | ||
| so a new model works in an existing client without client changes. | ||
|
|
||
| Each task declares its inputs and parameters in flat, typed maps, and the names are model-specific. `serve` uses the | ||
| pipeline's own argument names, except for a few common ones: | ||
|
|
||
| | Manifest name | Pipeline argument | | ||
| |---|---| | ||
| | `steps` | `num_inference_steps` | | ||
| | `seed` | `generator` | | ||
| | `num_outputs` | `num_images_per_prompt`, `num_videos_per_prompt`, `num_waveforms_per_prompt` | | ||
| | `fps` | `frame_rate` | | ||
| | `mask` (input) | `mask_image` | | ||
|
|
||
| The manifest travels with the model: canonically, a `gms.json` file in the model repository. A server SHOULD serve a | ||
| published manifest as is, so the same model reads the same on every host. `serve` loads it automatically, and falls | ||
| back to a manifest derived from the pipeline's `__call__` signature when the repository has none. | ||
|
|
||
| ## Publishing a manifest | ||
|
|
||
| A derived manifest has types and defaults, but no ranges or presets. Write a `gms.json` to add them, and test it | ||
| locally before uploading: | ||
|
|
||
| ```bash | ||
| diffusers serve black-forest-labs/FLUX.2-klein-4B --manifest gms.json | ||
| ``` | ||
|
|
||
| `serve` checks the manifest against the pipeline at startup and refuses to start if it declares something the | ||
| pipeline can't do. Once it loads, upload it to the root of the model repository: | ||
|
|
||
| ```bash | ||
| hf upload black-forest-labs/FLUX.2-klein-4B gms.json gms.json | ||
| ``` | ||
|
|
||
| See the [example manifests](https://github.com/huggingface/gms-alpha/tree/main/manifests) for FLUX.2, LTX 2.5 and | ||
| ACE-Step 1.5. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remote worker doesn’t inherit the local PR revision. Running the PR’s CLI locally with
--remotelaunched a stock worker whose installed Diffusers release lackedserve. Maybe we should clarify this?