Skip to content

Commit 81d7f89

Browse files
committed
update
1 parent 70faef8 commit 81d7f89

6 files changed

Lines changed: 9 additions & 11 deletions

File tree

nunchaku/lora/flux/compose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def compose_lora(
6464
>>> # Compose two LoRA weights with different strengths
6565
>>> lora_paths = [("lora1.safetensors", 0.8), ("lora2.safetensors", 0.6)]
6666
>>> composed = compose_lora(lora_paths, "composed_lora.safetensors")
67-
67+
6868
>>> # Compose from weight dictionaries
6969
>>> lora_dicts = [({"layer.weight": torch.randn(10, 20)}, 1.0)]
7070
>>> composed = compose_lora(lora_dicts)

nunchaku/lora/flux/diffusers_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def handle_kohya_lora(state_dict: dict[str, torch.Tensor]) -> dict[str, torch.Te
6060
- `transformer_blocks_` → `transformer_blocks.`
6161
- `lora_down` → `lora_A`
6262
- `lora_up` → `lora_B`
63-
63+
6464
And many other component-specific transformations.
6565
6666
Examples
@@ -145,7 +145,7 @@ def to_diffusers(input_lora: str | dict[str, torch.Tensor], output_path: str | N
145145
--------
146146
>>> # Convert from file path
147147
>>> diffusers_weights = to_diffusers("path/to/lora.safetensors")
148-
148+
149149
>>> # Convert from weight dictionary
150150
>>> weights = {"transformer.layer.lora_A.weight": torch.randn(10, 20)}
151151
>>> diffusers_weights = to_diffusers(weights, "output.safetensors")

nunchaku/lora/flux/nunchaku_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# convert the diffusers lora to nunchaku format
21
"""
32
Nunchaku LoRA format converter for Flux models.
43
@@ -22,7 +21,7 @@
2221
- `pack_lowrank_weight`/`unpack_lowrank_weight`: Low-rank weight transformations
2322
- `fuse_vectors`: Vector fusion for bias terms
2423
"""
25-
"""Convert LoRA weights to Nunchaku format."""
24+
2625
import logging
2726
import os
2827

nunchaku/lora/flux/packer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class MmaWeightPackerBase:
9090
If tile sizes are not properly divisible.
9191
If pack size is not in the valid range [1, 4].
9292
"""
93+
9394
def __init__(self, bits: int, warp_n: int, comp_n: int = None, comp_k: int = None):
9495
self.bits = bits
9596
assert self.bits in (1, 4, 8, 16, 32), "weight bits should be 1, 4, 8, 16, or 32."
@@ -226,6 +227,7 @@ class NunchakuWeightPacker(MmaWeightPackerBase):
226227
pad_lowrank_weight(weight, down)
227228
Pad low-rank weight tensors to required dimensions.
228229
"""
230+
229231
def __init__(self, bits: int, warp_n: int = 128):
230232
super().__init__(bits=bits, warp_n=warp_n)
231233
self.num_k_unrolls = 2

nunchaku/lora/flux/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def is_nunchaku_format(lora: str | dict[str, torch.Tensor]) -> bool:
1616
"""
1717
Check if LoRA weights are in Nunchaku format.
1818
19-
This function determines whether the provided LoRA weights are already in
19+
This function determines whether the provided LoRA weights are already in
2020
Nunchaku format by checking for specific key patterns that are characteristic
2121
of Nunchaku-formatted LoRA weights.
2222
@@ -36,7 +36,7 @@ def is_nunchaku_format(lora: str | dict[str, torch.Tensor]) -> bool:
3636
>>> # Check format from file path
3737
>>> is_nunchaku_format("path/to/lora.safetensors")
3838
True
39-
39+
4040
>>> # Check format from weight dictionary
4141
>>> weights = {"transformer_blocks.0.mlp_fc.weight": torch.randn(128, 256)}
4242
>>> is_nunchaku_format(weights)

nunchaku/models/text_encoders/t5_encoder.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
3838

3939
# Configure logging
40-
logging.basicConfig(
41-
level=getattr(logging, log_level, logging.INFO),
42-
format="%(asctime)s - %(levelname)s - %(message)s"
43-
)
40+
logging.basicConfig(level=getattr(logging, log_level, logging.INFO), format="%(asctime)s - %(levelname)s - %(message)s")
4441
logger = logging.getLogger(__name__)
4542

4643

0 commit comments

Comments
 (0)