Change single blocks to use num_blocks value

This commit is contained in:
rockerBOO
2025-03-23 21:30:45 -04:00
parent af5adb2b61
commit dd9a330860

View File

@@ -969,7 +969,7 @@ class Flux(nn.Module):
def enable_block_swap(self, num_blocks: int, device: torch.device):
self.blocks_to_swap = num_blocks
double_blocks_to_swap = min(self.num_double_blocks - 2, num_blocks // 2)
single_blocks_to_swap = (num_blocks - double_blocks_to_swap) * 2
single_blocks_to_swap = (num_blocks - (num_blocks // 2)) * 2
assert double_blocks_to_swap <= self.num_double_blocks - 2 and single_blocks_to_swap <= self.num_single_blocks - 2, (
f"Cannot swap more than {self.num_double_blocks - 2} double blocks and {self.num_single_blocks - 2} single blocks. "