Load nvidia/AnyFlow-* checkpoints from the diffusers AnyFlow metadata layout#2
Draft
Enderfga wants to merge 2 commits into
Draft
Load nvidia/AnyFlow-* checkpoints from the diffusers AnyFlow metadata layout#2Enderfga wants to merge 2 commits into
Enderfga wants to merge 2 commits into
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
nvidia/AnyFlow-*-Diffuserscheckpoints currently use the metadatalayout written by the pipelines in this repository:
model_index.jsonreferences the
far.*modules andtransformer/config.jsoncarriesinit_far_model,init_flowmap_model,chunk_partition,qk_norm,and
added_kv_proj_dim.huggingface/diffusers#13745
adds an
AnyFlowPipeline/AnyFlowFARPipelineto the diffuserslibrary. Once that PR is merged, we plan to update the metadata on
each
nvidia/AnyFlow-*-Diffusersrepository so thatmodel_index.jsonreferences the diffusers AnyFlow class names —
AnyFlowTransformer3DModel,AnyFlowFARTransformer3DModel, andFlowMapEulerDiscreteScheduler—without re-uploading the weight tensors.
This PR adds
from_pretrainedoverrides so the code in this repositoryloads 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 omitsinit_*_model, derive the flags from_class_nameand fall back tochunk_partition=[1, 3, 3, 3, 3, 3, 3, 2]for the FAR variant(matches the 81-frame inference schedule).
WanAnyFlowPipeline/FARWanAnyFlowPipeline: pre-instantiate thetransformer and scheduler with the classes defined here and pass
them as kwargs, so
DiffusionPipeline.from_pretrainedskips themodule lookup for those entries.
diffusers.{AnyFlowTransformer3DModel, AnyFlowFARTransformer3DModel, FlowMapEulerDiscreteScheduler}to theclasses defined here; idempotent (skipped when diffusers provides
those names).
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.