Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure everything is on gpu and other stuff #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions flux_mod/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ def forward_orig(
device = img.device
dtype = img.dtype
mod_index_length = 344 + 12
distill_timestep = timestep_embedding(torch.tensor(timesteps), 16).to(device=device, dtype=dtype)
distil_guidance = timestep_embedding(torch.tensor(guidance), 16).to(device=device, dtype=dtype)
distill_timestep = timestep_embedding(timesteps, 16).to(device=device, dtype=dtype)
distil_guidance = timestep_embedding(guidance, 16).to(device=device, dtype=dtype)
# get all modulation index
modulation_index = timestep_embedding(torch.tensor(list(range(mod_index_length))), 32).to(device=device, dtype=dtype)
modulation_index = timestep_embedding(torch.arange(0, mod_index_length).to(device=device), 32).to(device=device, dtype=dtype)
# we need to broadcast the modulation index here so each batch has all of the index
modulation_index = modulation_index.unsqueeze(0).repeat(img.shape[0], 1, 1)
modulation_index = modulation_index.unsqueeze(0)
# and we need to broadcast timestep and guidance along too
timestep_guidance = torch.cat([distill_timestep, distil_guidance], dim=1).unsqueeze(1).repeat(1, mod_index_length, 1)
timestep_guidance = torch.cat([distill_timestep, distil_guidance], dim=1).unsqueeze(1).expand(1, mod_index_length, 32)
# then and only then we could concatenate it together
input_vec = torch.cat([timestep_guidance, modulation_index], dim=-1)

Expand Down