Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/maxdiffusion/configs/base_wan_14b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ revision: ''
weights_dtype: 'bfloat16'
# This sets the layer's dtype in the model. Ex: nn.Dense(dtype=activations_dtype)
activations_dtype: 'bfloat16'
# The dtype for text_encoder model during load/compile
text_encoder_dtype: 'float32'

# Whether to compile the text_encoder with torch.compile
compile_text_encoder: False

# Replicates vae across devices instead of using the model's sharding annotations for sharding.
replicate_vae: False
Expand Down
5 changes: 5 additions & 0 deletions src/maxdiffusion/configs/base_wan_1_3b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ revision: ''
weights_dtype: 'bfloat16'
# This sets the layer's dtype in the model. Ex: nn.Dense(dtype=activations_dtype)
activations_dtype: 'bfloat16'
# The dtype for text_encoder model during load/compile
text_encoder_dtype: 'float32'

# Whether to compile the text_encoder with torch.compile
compile_text_encoder: False

# Replicates vae across devices instead of using the model's sharding annotations for sharding.
replicate_vae: False
Expand Down
5 changes: 5 additions & 0 deletions src/maxdiffusion/configs/base_wan_27b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ revision: ''
weights_dtype: 'bfloat16'
# This sets the layer's dtype in the model. Ex: nn.Dense(dtype=activations_dtype)
activations_dtype: 'bfloat16'
# The dtype for text_encoder model during load/compile
text_encoder_dtype: 'float32'

# Whether to compile the text_encoder with torch.compile
compile_text_encoder: False

# Replicates vae across devices instead of using the model's sharding annotations for sharding.
replicate_vae: False
Expand Down
5 changes: 5 additions & 0 deletions src/maxdiffusion/configs/base_wan_animate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ revision: ''
weights_dtype: 'bfloat16'
# This sets the layer's dtype in the model. Ex: nn.Dense(dtype=activations_dtype)
activations_dtype: 'bfloat16'
# The dtype for text_encoder model during load/compile
text_encoder_dtype: 'float32'

# Whether to compile the text_encoder with torch.compile
compile_text_encoder: False

# Replicates vae across devices instead of using the model's sharding annotations for sharding.
replicate_vae: False
Expand Down
5 changes: 5 additions & 0 deletions src/maxdiffusion/configs/base_wan_i2v_14b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ revision: ''
weights_dtype: 'bfloat16'
# This sets the layer's dtype in the model. Ex: nn.Dense(dtype=activations_dtype)
activations_dtype: 'bfloat16'
# The dtype for text_encoder model during load/compile
text_encoder_dtype: 'float32'

# Whether to compile the text_encoder with torch.compile
compile_text_encoder: False

# Replicates vae across devices instead of using the model's sharding annotations for sharding.
replicate_vae: False
Expand Down
5 changes: 5 additions & 0 deletions src/maxdiffusion/configs/base_wan_i2v_27b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ revision: ''
weights_dtype: 'bfloat16'
# This sets the layer's dtype in the model. Ex: nn.Dense(dtype=activations_dtype)
activations_dtype: 'bfloat16'
# The dtype for text_encoder model during load/compile
text_encoder_dtype: 'float32'

# Whether to compile the text_encoder with torch.compile
compile_text_encoder: False

# Replicates vae across devices instead of using the model's sharding annotations for sharding.
replicate_vae: False
Expand Down
6 changes: 4 additions & 2 deletions src/maxdiffusion/pipelines/wan/wan_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ def __init__(

@classmethod
def load_text_encoder(cls, config: HyperParameters):
torch_dtype = getattr(torch, str(config.weights_dtype), torch.float32)
text_encoder_dtype = getattr(config, "text_encoder_dtype", "float32")
torch_dtype = getattr(torch, str(text_encoder_dtype), torch.float32)
text_encoder = UMT5EncoderModel.from_pretrained(
config.pretrained_model_name_or_path,
subfolder="text_encoder",
torch_dtype=torch_dtype,
)
text_encoder = torch.compile(text_encoder)
if getattr(config, "compile_text_encoder", True):
text_encoder = torch.compile(text_encoder)
return text_encoder

@classmethod
Expand Down
Loading