Skip to content

feat(diffusion): encoder_hub — family-dispatched frozen-encoder logic - #96

Open
zhihengy wants to merge 3 commits into
mainfrom
feat/encoder-hub
Open

feat(diffusion): encoder_hub — family-dispatched frozen-encoder logic#96
zhihengy wants to merge 3 commits into
mainfrom
feat/encoder-hub

Conversation

@zhihengy

@zhihengy zhihengy commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

What

New miles/rollout/encoder_hub/ package holding frozen-encoder logic per model family, dispatched by the resolved args.diffusion_model_family (same decentralization mechanism as the TPC registry). Motivated by review on #90: TrainPipelineConfig should only drive the training backend; encoders are an independent, rollout-side concern.

Each family module provides three functions: load_encoder(args, device) (frozen tokenizer/text-encoder/VAE from the explicit --sft-encoder-checkpoint HF name/path), encode_sample(encoder, pixels, prompt, generator) (one media/prompt pair → clean latent + cond kwargs), and validate_args(args) (family-specific encode constraints — for Wan2.2, the (num_frames-1) % 4 == 0 VAE temporal-stride rule, which is an encoder property, not a global SFT rule).

Wan2.2 is the only entry; unsupported families are rejected at dispatch with a clear error.

Stack

This PR is the base of a two-PR stack:

Merge this first, then #90.

…ogic

Review feedback on PR #90: TrainPipelineConfig should only drive the
training backend, so frozen-encoder loading/encoding lives in its own
rollout-side hub, dispatched by the resolved diffusion model family.
Wan2.2 provides UMT5+VAE loading (from the explicit
--sft-encoder-checkpoint introduced by the consumer PR), sample encoding,
and its 4k+1 frame-count constraint.

No callers in this PR; the SFT PR (#90) is stacked on top and wires
argument validation and the encode actor pool to this hub.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
zhihengy added a commit that referenced this pull request Aug 6, 2026
…training-only

Review feedback (PR #90): TrainPipelineConfig drives the training backend
only. Encoder loading/encoding now lives in miles/rollout/encoder_hub
(stacked base PR #96), dispatched by args.diffusion_model_family; the
Wan-specific 4k+1 frame constraint validates there too. Encoders load
from the explicit --sft-encoder-checkpoint, which also replaces
hf_checkpoint in the per-sample cache key since it is what determines
cache content.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread miles/rollout/encoder_hub/wan2_2.py Outdated
embeds[:, int(inputs.attention_mask[0].sum()) :] = 0

return {
"latent": latent[0].to(torch.float16).cpu(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The dtypes here need to be double-checked.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done (173abc6) — aligned with sglang-d's Wan pipeline config (vae_precision fp32, text_encoder_precisions fp32, DiT bf16): UMT5 now computes in fp32 like the rollout engine, VAE stays fp32, and both cached tensors store bf16 — the precision the DiT boundary sees on the rollout path. Note for anyone with an existing .sft_cache: the cache key does not encode dtypes, so clear it manually to re-encode.

zhihengy and others added 2 commits August 6, 2026 06:03
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Match the rollout engine's Wan pipeline config (vae_precision fp32,
text_encoder_precisions fp32, DiT bf16): UMT5 now computes in fp32, and
both cached tensors store bf16 — the precision the DiT boundary sees on
the rollout path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants