Repository navigation
poc: vllm-omni-neuron for serving FLUX.2 Klein - #15249
JingyaHuang wants to merge 9 commits into
Conversation
|
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: |
…fusers into support-neuron-vllm-omni
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.
|
Despite the current runtime bugs in cc. @pagezyhf |
| 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) |
There was a problem hiding this comment.
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) |
| if is_flashinfer_available(): | ||
| import flashinfer |
There was a problem hiding this comment.
This seems like an unrelated change to me.
stevhliu
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
would be nice to use a real value here :)
| 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. |
There was a problem hiding this comment.
may also be nice to add what a sample request looks like so users know its good
| 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 |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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. |
|
|
||
|
|
||
| ## Serving with vLLM-Omni |
There was a problem hiding this comment.
| ## Serving with vLLM-Omni | |
| ## Serve pipelines with vLLM-Omni |
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
Flux2KleinPipeline: moves the per-step timestep cast into a_prepare_timestephelper so it can be compiled as its own region. The logic is unchanged. On the libtorch-neuronx-lite runtime that vLLM-Neuron uses, the cast can't run eagerly ([libtorch-neuronx-lite] Eager copy fails when it changes dtype or the source is non-contiguous aws-neuron/torch-neuronx#1055). The only plugin-side alternative is to keep bf16 timesteps on the device, and that triggers an "Execution Queue Full" failure ([libtorch-neuronx-lite] "Execution Queue Full" in a denoising loop with bf16 timesteps; every later execution fails aws-neuron/torch-neuronx#1056). Once those are fixed, the helper can go.quantizers/bfl/utils.py: importsflashinferonly inside the CUDA path ofBFLNVFP4Linear.forward. The module-level import brokeimport diffuserson non-CUDA torch builds when flashinfer was installed.Klein hits the same lite eager gaps in two more places: the prompt-embedding
stack → permute → reshapeand 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
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
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.