Skip to content

poc: vllm-omni-neuron for serving FLUX.2 Klein - #15249

Open
JingyaHuang wants to merge 9 commits into
huggingface:mainfrom
JingyaHuang:support-neuron-vllm-omni
Open

JingyaHuang wants to merge 9 commits into
huggingface:mainfrom
JingyaHuang:support-neuron-vllm-omni

Conversation

@JingyaHuang

@JingyaHuang JingyaHuang commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

This PR makes small changes so that vllm-omni-neuron can serve Diffusers pipelines on AWS Neuron through vLLM-Omni, starting with FLUX.2 Klein. The plugin runs the Diffusers pipeline as-is and compiles some regions of it with static shapes.

Changes

Klein hits the same lite eager gaps in two more places: the prompt-embedding stack → permute → reshape and the latent unpack before VAE decode. The plugin handles both, so they need no changes here.

Validation

On Trainium2, FLUX.2-klein-4B served through vllm-omni-neuron produces images pixel-identical to bare Diffusers (256², 4 steps, same seed). 8- and 50-step requests also run without recompiling.

Before submitting

  • Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
    • Did you read the Coding with AI agents guide?
    • Did you run the self-review skill on the diff?
    • Did you share the final self-review notes in the PR description or a comment?
  • Did you read the contributor guideline?
  • Did you read our philosophy doc? (important for complex PRs)
  • Was this discussed/approved via a GitHub issue or GitHub Discussions? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?
  • Are you the author (or part of the team we work with) of the model/pipeline this PR relates to?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Pages changed in this PR:

@JingyaHuang
JingyaHuang marked this pull request as ready for review November 25, 2026 17:47
JingyaHuang and others added 4 commits November 25, 2026 18:02
Revert the prompt-embeds and VAE-latents workarounds (now handled in
vllm-omni-neuron) and keep only a tensor-only timestep helper, shared by
Klein, Klein inpaint and Klein KV via # Copied from.
@github-actions github-actions Bot removed the tests label Nov 27, 2026
@JingyaHuang

Copy link
Copy Markdown
Collaborator Author

Despite the current runtime bugs in TorchNeuron led to the modeling code change, I would love to have your inputs on serving diffusers pipelines with vllm-omni on Trainium with a diffusers adapter in vllm-omni-neuron aws-neuron/vllm-omni-neuron#5 @sayakpaul.

cc. @pagezyhf

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some comments. Very supportive of the idea of course! Cc: @stevhliu for the docs.

self._current_timestep = t
# broadcast to batch dimension in a way that's compatible with ONNX/Core ML
timestep = t.expand(latents.shape[0]).to(latents.dtype)
timestep = self._prepare_timestep(t, latents)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We usually don't do one-liner methods like this and prefer inlining them as much as possible for better readability.

Kept as a tensor-only method so backends can compile it as its own region (e.g. libtorch-neuronx-lite, where
running this cast eagerly breaks the denoising loop).
"""
return timestep.expand(latents.shape[0]).to(latents.dtype)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as above.

Comment on lines -29 to -30
if is_flashinfer_available():
import flashinfer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like an unrelated change to me.

@stevhliu stevhliu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice work, cool to see more support!


```bash
export VLLM_OMNI_NEURON_DIFFUSERS_RESOLUTIONS=256x256,512x512
vllm serve <model-id> --omni --diffusion-load-format diffusers --dtype bfloat16

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would be nice to use a real value here :)

Suggested change
vllm serve <model-id> --omni --diffusion-load-format diffusers --dtype bfloat16
vllm serve black-forest-labs/FLUX.2-klein-4B --omni --diffusion-load-format diffusers --dtype bfloat16

vllm serve <model-id> --omni --diffusion-load-format diffusers --dtype bfloat16
```

See the vllm-omni-neuron repository for installation and supported pipelines.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

may also be nice to add what a sample request looks like so users know its good

Suggested change
See the vllm-omni-neuron repository for installation and supported pipelines.
The server is ready once lal declared resolutions have compiled. For installation steps and supported pipelines, see the [vllm-omni-neuron](https://github.com/aws-neuron/vllm-omni-neuron) repository.

[vllm-omni-neuron](https://github.com/aws-neuron/vllm-omni-neuron) serves Diffusers pipelines on Neuron through
vLLM-Omni. Diffusers runs the pipeline, and the plugin handles device placement and compilation.

Neuron compiles static shapes, so declare the resolutions to serve up front. The server compiles them at startup and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Neuron compiles static shapes, so declare the resolutions to serve up front. The server compiles them at startup and
Neuron [compiles static shapes](#compiled-mode), so declare the resolutions to serve up front. The server compiles them at startup and

vLLM-Omni. Diffusers runs the pipeline, and the plugin handles device placement and compilation.

Neuron compiles static shapes, so declare the resolutions to serve up front. The server compiles them at startup and
rejects any other resolution. The number of inference steps isn't restricted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
rejects any other resolution. The number of inference steps isn't restricted.
rejects any other resolution. If you don't set it, the server compiles only 256x256. The number of inference steps isn't restricted.

Comment on lines +118 to +120


## Serving with vLLM-Omni

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
## Serving with vLLM-Omni
## Serve pipelines with vLLM-Omni

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation pipelines quantization size/M PR with diff < 200 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants