Skip to content
Merged
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
13 changes: 13 additions & 0 deletions src/f5_tts/model/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from __future__ import annotations

import math
import warnings
from typing import Optional

import torch
Expand Down Expand Up @@ -452,6 +453,12 @@ def __init__(
):
if attn_backend == "flash_attn":
assert is_package_available("flash_attn"), "Please install flash-attn first."
if attn_backend == "torch" and attn_mask_enabled:
warnings.warn(
"attn_mask_enabled=True with attn_backend='torch' can consume large GPU memory. "
"Please switch attn_backend to 'flash_attn'.",
UserWarning,
)

self.pe_attn_head = pe_attn_head
self.attn_backend = attn_backend
Expand Down Expand Up @@ -557,6 +564,12 @@ def __init__(
):
if attn_backend == "flash_attn":
assert is_package_available("flash_attn"), "Please install flash-attn first."
if attn_backend == "torch" and attn_mask_enabled:
warnings.warn(
"attn_mask_enabled=True with attn_backend='torch' can consume large GPU memory. "
"Please switch attn_backend to 'flash_attn'.",
UserWarning,
)

self.attn_backend = attn_backend
self.attn_mask_enabled = attn_mask_enabled
Expand Down
3 changes: 2 additions & 1 deletion src/f5_tts/model/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __init__(
"grad_accumulation_steps": grad_accumulation_steps,
"max_grad_norm": max_grad_norm,
"noise_scheduler": noise_scheduler,
"bnb_optimizer": bnb_optimizer,
}
model_cfg_dict["gpus"] = self.accelerator.num_processes
self.accelerator.init_trackers(
Expand Down Expand Up @@ -139,7 +140,7 @@ def __init__(

self.optimizer = bnb.optim.AdamW8bit(model.parameters(), lr=learning_rate)
else:
self.optimizer = AdamW(model.parameters(), lr=learning_rate)
self.optimizer = AdamW(model.parameters(), lr=learning_rate, fused=True)
self.model, self.optimizer = self.accelerator.prepare(self.model, self.optimizer)

@property
Expand Down