Skip to content

feat(engine): [image, audio] sglang image vllm asr engines#5121

Open
OliverBryant wants to merge 7 commits into
xorbitsai:mainfrom
OliverBryant:feat/sglang-image-vllm-asr-engines
Open

feat(engine): [image, audio] sglang image vllm asr engines#5121
OliverBryant wants to merge 7 commits into
xorbitsai:mainfrom
OliverBryant:feat/sglang-image-vllm-asr-engines

Conversation

@OliverBryant

Copy link
Copy Markdown
Collaborator

@XprobeBot XprobeBot added this to the v2.x milestone Jul 2, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@XprobeBot XprobeBot modified the milestones: v2.x, v3.x Jul 19, 2026
@OliverBryant OliverBryant changed the title Feat/sglang image vllm asr engines Feat: sglang image vllm asr engines Jul 22, 2026
@qinxuye qinxuye changed the title Feat: sglang image vllm asr engines feat(engine): [image, audio] sglang image vllm asr engines Jul 22, 2026
…-dev

Implement the SGLangImageModel stub with sglang-diffusion offline API
(sglang.multimodal_gen.DiffGenerator) so text-to-image models can run on
the SGLang engine on Linux with NVIDIA GPUs. Supported models: Qwen-Image,
Qwen-Image-2512, Z-Image, Z-Image-Turbo and FLUX.1-dev, matching the
sglang-diffusion compatibility matrix. Virtualenv specs install
sglang[diffusion] when the SGLang engine is selected.

Ref xorbitsai#4896
Add an engine abstraction layer for audio models (mirroring the image
module design): AUDIO_ENGINES registry, engine matching and virtualenv
marker support. Families without registered engines keep the legacy
hardcoded dispatch, so existing behavior is unchanged.

Qwen3-ASR-0.6B/1.7B register two engines: the default transformers
engine and, on Linux with NVIDIA GPUs, a vLLM engine backed by
qwen_asr's Qwen3ASRModel.LLM which shares the same transcribe API.
/v1/engines/audio/<model_name> now returns engine params for audio
models.

Ref xorbitsai#4896
Show the engine select in the launch dialog for audio models that
support engine selection (e.g. Qwen3-ASR on transformers/vLLM), and
include audio in the model types that query /v1/engines. Audio models
without registered engines keep the previous form unchanged.

Ref xorbitsai#4896
@OliverBryant
OliverBryant force-pushed the feat/sglang-image-vllm-asr-engines branch from 7e346ee to 77a64ad Compare July 22, 2026 07:48
self._device = device
self._model = None
self._model_spec = model_spec
self._abilities = model_spec.model_ability or [] # type: ignore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SGLang model copies the full ability list from the diffusers model spec, but this implementation only provides text_to_image. All five registered SGLang models advertise image2image, and three also advertise inpainting, so the running instance is reported as supporting endpoints that will fail with AttributeError (and may even be auto-selected by the image-edit API). Please either implement those methods for SGLang or expose only text2image for this engine.

Implement the vLLM image engine placeholder with a real engine backed by
vllm-omni's Omni text-to-image entrypoint. The engine matches on Linux
with NVIDIA GPUs for the same model set as the SGLang engine: Qwen-Image,
Qwen-Image-2512, Z-Image, Z-Image-Turbo and FLUX.1-dev. Add vllm-omni
virtualenv markers to the builtin specs so engine-scoped installs work.

Ref xorbitsai#4896
vllm-omni does not declare vllm as a dependency but requires a vllm with
the same major.minor version (its patch module imports private vllm APIs),
so an unpinned marker resolved vllm-omni against whatever vllm the parent
environment had and crashed on import. Pin the vllm-omni/vllm pair in the
virtualenv packages, surface the original import error with the pairing
requirement in the failure message, and assert the pins stay in sync in
tests.

Ref xorbitsai#4896
The vLLM image engine serialized all requests: VLLMDiffusionModel had no
allow_batch flag, so ModelActor wrapped every text_to_image call in its
per-model asyncio lock, and each call went through the blocking
Omni.generate. The vllm-omni engine itself schedules requests from a
queue and pipelines stages, so the serialization was purely on the
xinference side.

Omni.generate cannot simply be called concurrently: it drains the shared
engine output queue and drops messages belonging to other requests, and
per-request sampling params (seed, size, steps) cannot be expressed
through one batched generate call since sampling_params_list is
per-stage, not per-prompt.

Set allow_batch = True and submit each request directly via
engine.add_request with its own request_id and sampling params. A single
dispatcher thread drains the engine output queue and routes messages
back to per-request futures; a fatal ErrorMessage fails all in-flight
requests, a per-request error fails only its own future. The dispatcher
exits when idle and restarts on the next submission. When the running
vllm-omni does not expose the needed engine internals, fall back to the
previous serial Omni.generate path, now guarded by a model-level lock
because the actor no longer serializes calls.
sglang pins its own torch stack (sglang 0.5.7 requires torch==2.9.1
exactly), so the unscoped #system_torch#/#system_numpy# placeholders in
the vLLM/SGLang image model specs expand to the host torch (e.g. 2.11.0)
and can never co-resolve with sglang[diffusion] in one virtualenv. Scope
the system placeholders (and the transformers floor, which sglang also
pins itself) to the diffusers and vLLM engines so the SGLang venv
resolves sglang[diffusion] self-contained with its own torch.

Note the SGLang install path additionally requires the xoscar
skip_installed fix for requirements with extras: without it,
sglang[diffusion] is treated as satisfied by a bare host sglang and the
venv is left empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants