Skip to content

Load nvidia/AnyFlow-* checkpoints from the diffusers AnyFlow metadata layout#2

Draft
Enderfga wants to merge 2 commits into
NVlabs:mainfrom
Enderfga:diffusers-compat-wip
Draft

Load nvidia/AnyFlow-* checkpoints from the diffusers AnyFlow metadata layout#2
Enderfga wants to merge 2 commits into
NVlabs:mainfrom
Enderfga:diffusers-compat-wip

Conversation

@Enderfga
Copy link
Copy Markdown

The nvidia/AnyFlow-*-Diffusers checkpoints currently use the metadata
layout written by the pipelines in this repository: model_index.json
references the far.* modules and transformer/config.json carries
init_far_model, init_flowmap_model, chunk_partition, qk_norm,
and added_kv_proj_dim.

huggingface/diffusers#13745
adds an AnyFlowPipeline / AnyFlowFARPipeline to the diffusers
library. Once that PR is merged, we plan to update the metadata on
each nvidia/AnyFlow-*-Diffusers repository so that model_index.json
references the diffusers AnyFlow class names — AnyFlowTransformer3DModel,
AnyFlowFARTransformer3DModel, and FlowMapEulerDiscreteScheduler
without re-uploading the weight tensors.

This PR adds from_pretrained overrides so the code in this repository
loads either metadata layout: the one currently published and the one
aligned with the diffusers AnyFlow pipeline.

What changes

  • FAR_Wan_Transformer3DModel.from_pretrained: when the config omits
    init_*_model, derive the flags from _class_name and fall back to
    chunk_partition=[1, 3, 3, 3, 3, 3, 3, 2] for the FAR variant
    (matches the 81-frame inference schedule).
  • WanAnyFlowPipeline / FARWanAnyFlowPipeline: pre-instantiate the
    transformer and scheduler with the classes defined here and pass
    them as kwargs, so DiffusionPipeline.from_pretrained skips the
    module lookup for those entries.
  • Module-level binding of diffusers.{AnyFlowTransformer3DModel, AnyFlowFARTransformer3DModel, FlowMapEulerDiscreteScheduler} to the
    classes defined here; idempotent (skipped when diffusers provides
    those names).
  • README: "Using with HF diffusers" section.

Compatibility

Additive only — checkpoints with the current config fields are loaded
unchanged; user-supplied kwargs always win. No signature or behavior
change for existing code paths.

Enderfga added 2 commits May 14, 2026 17:51
…layout

The nvidia/AnyFlow-*-Diffusers checkpoints reference the diffusers AnyFlow
class names from `model_index.json` and omit `init_far_model`,
`init_flowmap_model`, `chunk_partition`, `qk_norm`, and `added_kv_proj_dim`
from `transformer/config.json`.

- `FAR_Wan_Transformer3DModel`: when `init_*_model` is absent, derive the
  flags from `_class_name`. For the FAR variant, additionally fall back to
  `chunk_partition=[1, 3, 3, 3, 3, 3, 3, 2]` to match the 81-frame
  inference schedule. Configs that already set these fields are passed
  through unchanged; user kwargs always win.

- `WanAnyFlowPipeline` / `FARWanAnyFlowPipeline`: pre-instantiate the
  transformer and scheduler with the classes defined here and pass them as
  kwargs, so `DiffusionPipeline.from_pretrained` skips the module lookup
  for those two entries. text_encoder / tokenizer / vae still load normally.

- Bind `diffusers.{AnyFlowTransformer3DModel, AnyFlowFARTransformer3DModel,
  FlowMapEulerDiscreteScheduler}` at import time when not already defined;
  idempotent.

- Export `FlowMapEulerDiscreteScheduler` as an alias for
  `FlowMapDiscreteScheduler`.

Additive only — no class signature or behavior change for existing
checkpoints.
Document the standard diffusers usage for the nvidia/AnyFlow-*-Diffusers
checkpoints — AnyFlowPipeline for bidirectional T2V and AnyFlowFARPipeline
for the FAR causal variant (T2V / I2V / V2V via the `context_sequence`
argument).
@Enderfga Enderfga marked this pull request as ready for review May 14, 2026 10:09
@Enderfga Enderfga closed this May 14, 2026
@Enderfga Enderfga reopened this May 14, 2026
@Enderfga Enderfga marked this pull request as draft May 14, 2026 10:11
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.

1 participant