Skip to content

Support separate placement for encoding and decoding with tensor parallelism #15336

Open

Description

@dacorvo

The tensor-parallel inference example from #13718 loads and runs the text encoders and VAE on every rank. Each rank encodes the same prompt and decodes the same final latents. For FLUX.1-schnell, those components account for about 9.3 GiB of bf16 weights per rank.

Could Diffusers support running encoding and decoding once per request, with configurable placement for those stages?

  • Encode the prompt and any input images once, then send the conditioning tensors to the TP group.
  • Run denoising across the TP group.
  • Decode and postprocess the final latents once.

Keeping the encoders and VAE on a single TP rank would reduce total memory use and redundant computation. If those weights stay resident during denoising, that rank still has less room for its denoiser shard. With equal-sized shards, the rank with the least free memory determines what fits across the group. To free memory on every TP rank during denoising, the pipeline could place encoding and decoding on a separate device or offload their weights between stages.

This came up while testing on Trainium, but the placement is hardware-independent. FLUX already accepts precomputed prompt embeddings and can return latents. Pipeline-level support would let callers use those stage boundaries without wiring them up separately for each pipeline.

Activity

  1. DN6 commented on Nov 18, 2026

    @DN6
    Collaborator

    @dacorvo Looking into it for diffusers-cli serve #15017. Might not land in that PR, but should be included shortly after.

  2. self-assigned this
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions