Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
f99fe28
Add LoRA+ support
rockerBOO Apr 1, 2024
c769160
Add LoRA-FA for LoRA+
rockerBOO Apr 1, 2024
1933ab4
Fix default_lr being applied
rockerBOO Apr 3, 2024
75833e8
Fix default LR, Add overall LoRA+ ratio, Add log
rockerBOO Apr 8, 2024
68467bd
Fix unset or invalid LR from making a param_group
rockerBOO Apr 11, 2024
4f203ce
Fused backward pass
2kpr Apr 14, 2024
64916a3
add disable_mmap to args
Zovjsra Apr 16, 2024
feefcf2
Display name of error latent file
Cauldrath Apr 19, 2024
fc37437
Allow negative learning rate
Cauldrath Apr 19, 2024
2c9db5d
passing filtered hyperparameters to accelerate
ccharest93 Apr 20, 2024
4477116
fix train controlnet
sdbds Apr 20, 2024
b886d0a
Cleaned typing to be in line with accelerate hyperparameters type res…
ccharest93 Apr 20, 2024
5cb145d
Update train_util.py
sdbds Apr 20, 2024
52652cb
disable main process check for deepspeed #1247
kohya-ss Apr 21, 2024
0540c33
pop weights if available #1247
kohya-ss Apr 21, 2024
040e26f
Regenerate failed file
Cauldrath Apr 21, 2024
fdbb03c
removed unnecessary `torch` import on line 115
frodo821 Apr 23, 2024
834445a
Merge pull request #1233 from rockerBOO/lora-plus
kohya-ss Apr 29, 2024
969f82a
move loraplus args from args to network_args, simplify log lr desc
kohya-ss Apr 29, 2024
dbb7bb2
Fix caption_separator missing in subset schema
rockerBOO May 2, 2024
8db0cad
Add caption_separator to output for subset
rockerBOO May 2, 2024
58c2d85
support block dim/lr for sdxl
kohya-ss May 3, 2024
52e64c6
add debug log
kohya-ss May 4, 2024
7fe8150
update loraplus on dylora/lofa_fa
kohya-ss May 6, 2024
3fd8cdc
fix dylora loraplus
kohya-ss May 6, 2024
2a359e0
Merge pull request #1259 from 2kpr/fused_backward_pass
kohya-ss May 6, 2024
017b82e
update help message for fused_backward_pass
kohya-ss May 6, 2024
b56d5f7
add experimental option to fuse params to optimizer groups
kohya-ss May 6, 2024
793aeb9
fix get_trainable_params in controlnet-llite training
aria1th May 7, 2024
607e041
chore: Refactor optimizer group
kohya-ss May 12, 2024
c1ba0b4
update readme
kohya-ss May 12, 2024
6dbc23c
Merge branch 'dev' into fused-backward-pass
kohya-ss May 12, 2024
f3d2cf2
update README for fused optimizer
kohya-ss May 12, 2024
bee8cee
update README for fused optimizer
kohya-ss May 12, 2024
7983d3d
Merge pull request #1319 from kohya-ss/fused-backward-pass
kohya-ss May 12, 2024
e9f3a62
Merge branch 'dev' into lora-plus
kohya-ss May 12, 2024
e01e148
Merge branch 'dev' into lora-plus
kohya-ss May 12, 2024
1ffc0b3
fix typo
kohya-ss May 12, 2024
c6a4370
Merge branch 'dev' into lora-plus
kohya-ss May 12, 2024
3c8193f
revert lora+ for lora_fa
kohya-ss May 12, 2024
4419041
update docs etc.
kohya-ss May 12, 2024
02298e3
Merge pull request #1331 from kohya-ss/lora-plus
kohya-ss May 12, 2024
8d1b1ac
Merge pull request #1266 from Zovjsra/feature/disable-mmap
kohya-ss May 12, 2024
9ddb4d7
update readme and help message etc.
kohya-ss May 12, 2024
7802093
Merge pull request #1278 from Cauldrath/catch_latent_error_file
kohya-ss May 12, 2024
3701507
raise original error if error is occured in checking latents
kohya-ss May 12, 2024
39b82f2
update readme
kohya-ss May 12, 2024
e96a521
Merge pull request #1291 from frodo821/patch-1
kohya-ss May 12, 2024
1c296f7
Merge pull request #1312 from rockerBOO/patch-2
kohya-ss May 12, 2024
a384bf2
Merge pull request #1313 from rockerBOO/patch-3
kohya-ss May 12, 2024
16677da
fix create_network_from_weights doesn't work
kohya-ss May 12, 2024
589c2aa
update README
kohya-ss May 13, 2024
153764a
add prompt option '--f' for filename
kohya-ss May 15, 2024
146edce
support Diffusers' based SDXL LoRA key for inference
kohya-ss May 18, 2024
2f19175
update README
kohya-ss May 19, 2024
0640f01
Merge pull request #1322 from aria1th/patch-1
kohya-ss May 19, 2024
e3ddd1f
update README and format code
kohya-ss May 19, 2024
47187f7
Merge pull request #1285 from ccharest93/main
kohya-ss May 19, 2024
c68baae
add `--log_config` option to enable/disable output training config
kohya-ss May 19, 2024
de0e0b9
Merge pull request #1284 from sdbds/fix_traincontrolnet
kohya-ss May 19, 2024
e4d9e3c
remove dependency for omegaconf #ref 1284
kohya-ss May 19, 2024
38e4c60
Merge pull request #1277 from Cauldrath/negative_learning
kohya-ss May 19, 2024
4c79812
update README
kohya-ss May 19, 2024
febc5c5
update README
kohya-ss May 19, 2024
db67529
画像のアルファチャンネルをlossのマスクとして使用するオプションを追加 (#1223)
u-haru May 19, 2024
f2dd43e
revert kwargs to explicit declaration
kohya-ss May 19, 2024
da6fea3
simplify and update alpha mask to work with various cases
kohya-ss May 19, 2024
00513b9
Add LoRA+ LR Ratio info message to logger
rockerBOO May 24, 2024
fb12b6d
Merge pull request #1347 from rockerBOO/lora-plus-log-info
kohya-ss May 26, 2024
e8cfd4b
fix to work cond mask and alpha mask
kohya-ss May 26, 2024
d50c1b3
Update issue link
rockerBOO May 27, 2024
58cadf4
Merge branch 'dev' into alpha-masked-loss
kohya-ss May 27, 2024
a4c3155
add doc for mask loss
kohya-ss May 27, 2024
ffce3b5
Merge pull request #1349 from rockerBOO/patch-4
kohya-ss May 27, 2024
71ad3c0
Update masked_loss_README-ja.md
kohya-ss May 27, 2024
2870be9
Merge branch 'dev' into alpha-masked-loss
kohya-ss May 27, 2024
fc85496
update docs for masked loss
kohya-ss May 27, 2024
0d96e10
Merge pull request #1339 from kohya-ss/alpha-masked-loss
kohya-ss May 27, 2024
b2363f1
Final implementation
KohakuBlueleaf May 31, 2024
3eb27ce
Skip the final 1 step
KohakuBlueleaf May 31, 2024
e5bab69
fix alpha mask without disk cache closes #1351, ref #1339
kohya-ss Jun 2, 2024
321e24d
Merge pull request #1353 from KohakuBlueleaf/train_resume_step
kohya-ss Jun 4, 2024
4dbcef4
update for corner cases
kohya-ss Jun 4, 2024
4ecbac1
Bump crate-ci/typos from 1.19.0 to 1.21.0, fix typos, and updated _ty…
shirayu Jun 5, 2024
5bfe5e4
Merge pull request #1361 from shirayu/update/github_actions/crate-ci/…
kohya-ss Jun 6, 2024
58fb648
set static graph flag when DDP ref #1363
kohya-ss Jun 9, 2024
1a104dc
make forward/backward pathes same ref #1363
kohya-ss Jun 9, 2024
3259928
Merge branch 'dev' of https://github.com/kohya-ss/sd-scripts into dev
kohya-ss Jun 9, 2024
4a44188
Merge branch 'dev' into train_resume_step
kohya-ss Jun 11, 2024
18d7597
update README
kohya-ss Jun 11, 2024
22413a5
Merge pull request #1359 from kohya-ss/train_resume_step
kohya-ss Jun 11, 2024
56bb81c
add grad_hook after restore state closes #1344
kohya-ss Jun 12, 2024
9dd1ee4
Merge branch 'main' into dev
kohya-ss Jun 23, 2024
0b3e4f7
show file name if error in load_image ref #1385
kohya-ss Jun 25, 2024
8752694
judge image size for using diff interpolation
sdbds Jul 12, 2024
2e67978
Generate sample images without having CUDA (such as on Macs)
millie-v Jul 18, 2024
1f16b80
Revert "judge image size for using diff interpolation"
sdbds Jul 20, 2024
9ca7a5b
instead cv2 LANCZOS4 resize to pil resize
sdbds Jul 20, 2024
74f91c2
correct option name closes #1446
kohya-ss Aug 11, 2024
afb971f
fix SD1.5 LoRA extraction #1490
kohya-ss Aug 22, 2024
1e8108f
Handle args.v_parameterization properly for MinSNR and changed predic…
liesened Aug 23, 2024
4ca29ed
Merge pull request #1505 from liesened/patch-2
kohya-ss Aug 24, 2024
d5c076c
update readme
kohya-ss Aug 24, 2024
319e4d9
Merge pull request #1433 from millie-v/sample-image-without-cuda
kohya-ss Sep 7, 2024
16bb569
Merge pull request #1426 from sdbds/resize
kohya-ss Sep 7, 2024
0005867
update README, format code
kohya-ss Sep 7, 2024
62ec3e6
Merge branch 'main' into dev
kohya-ss Sep 7, 2024
fd68703
Add New lr scheduler (#1393)
sdbds Sep 11, 2024
6dbfd47
Fix to work PIECEWISE_CONSTANT, update requirement.txt and README #1393
kohya-ss Sep 11, 2024
c7c666b
fix typo
kohya-ss Sep 11, 2024
9d28607
Merge branch 'main' into dev
kohya-ss Sep 13, 2024
43ad738
Merge branch 'main' into dev
kohya-ss Sep 13, 2024
93d9fbf
improve OFT implementation closes #944
kohya-ss Sep 13, 2024
e704066
Bug fix: alpha_mask load
Maru-mee Sep 19, 2024
d7e1472
Merge branch 'main' into dev
kohya-ss Sep 19, 2024
0b7927e
Merge pull request #1615 from Maru-mee/patch-1
kohya-ss Sep 19, 2024
e1f23af
make timestep sampling behave in the standard way when huber loss is …
Sep 21, 2024
29177d2
retain alpha in pil_resize backport #1619
kohya-ss Sep 23, 2024
ab7b231
init
sdbds Sep 25, 2024
c1d16a7
Merge pull request #1628 from recris/huber-timesteps
kohya-ss Sep 25, 2024
e74f581
update README
kohya-ss Sep 25, 2024
1beddd8
delete code for cleaning
sdbds Sep 25, 2024
bf91bea
fix flip_aug, alpha_mask, random_crop issue in caching
kohya-ss Sep 26, 2024
4296e28
Merge pull request #1640 from sdbds/ademamix8bit
kohya-ss Sep 26, 2024
a94bc84
fix to work bitsandbytes optimizers with full path #1640
kohya-ss Sep 26, 2024
ce49ced
update readme
kohya-ss Sep 26, 2024
fe2aa32
adjust min/max bucket reso divisible by reso steps #1632
kohya-ss Sep 29, 2024
1567549
update help text #1632
kohya-ss Sep 29, 2024
012e7e6
fix to work linear/cosine scheduler closes #1651 ref #1393
kohya-ss Sep 29, 2024
8fc30f8
Fix training for V-pred and ztSNR
catboxanon Oct 21, 2024
e1b63c2
Only add warning for deprecated scaling vpred loss function
catboxanon Oct 21, 2024
0e7c592
Remove scale_v_pred_loss_like_noise_pred deprecation
catboxanon Oct 22, 2024
be14c06
Remove v-pred warnings
catboxanon Oct 22, 2024
c632af8
Merge pull request #1715 from catboxanon/vpred-ztsnr-fixes
kohya-ss Oct 25, 2024
b8ae745
Merge pull request #1717 from catboxanon/fix/remove-vpred-warnings
kohya-ss Oct 25, 2024
b1e6504
update README
kohya-ss Oct 25, 2024
900d551
Merge branch 'main' into dev
kohya-ss Oct 26, 2024
e070bd9
Merge branch 'main' into dev
kohya-ss Oct 27, 2024
6adb69b
Merge branch 'main' into dev
kohya-ss Nov 7, 2024
345daaa
update README for merging
kohya-ss Jan 17, 2025
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
Prev Previous commit
Next Next commit
add disable_mmap to args
  • Loading branch information
Zovjsra committed Apr 16, 2024
commit 64916a35b2378c4a8cdf3e9efeef8b8ab7ccb41c
14 changes: 9 additions & 5 deletions library/sdxl_model_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import torch
import safetensors
from accelerate import init_empty_weights
from accelerate.utils.modeling import set_module_tensor_to_device
from safetensors.torch import load_file, save_file
Expand Down Expand Up @@ -163,17 +164,20 @@ def _load_state_dict_on_device(model, state_dict, device, dtype=None):
raise RuntimeError("Error(s) in loading state_dict for {}:\n\t{}".format(model.__class__.__name__, "\n\t".join(error_msgs)))


def load_models_from_sdxl_checkpoint(model_version, ckpt_path, map_location, dtype=None):
def load_models_from_sdxl_checkpoint(model_version, ckpt_path, map_location, dtype=None, disable_mmap=False):
# model_version is reserved for future use
# dtype is used for full_fp16/bf16 integration. Text Encoder will remain fp32, because it runs on CPU when caching

# Load the state dict
if model_util.is_safetensors(ckpt_path):
checkpoint = None
try:
state_dict = load_file(ckpt_path, device=map_location)
except:
state_dict = load_file(ckpt_path) # prevent device invalid Error
if(disable_mmap):
state_dict = safetensors.torch.load(open(ckpt_path, 'rb').read())
else:
try:
state_dict = load_file(ckpt_path, device=map_location)
except:
state_dict = load_file(ckpt_path) # prevent device invalid Error
epoch = None
global_step = None
else:
Expand Down
9 changes: 7 additions & 2 deletions library/sdxl_train_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def load_target_model(args, accelerator, model_version: str, weight_dtype):
weight_dtype,
accelerator.device if args.lowram else "cpu",
model_dtype,
args.disable_mmap_load_safetensors
)

# work on low-ram device
Expand All @@ -60,7 +61,7 @@ def load_target_model(args, accelerator, model_version: str, weight_dtype):


def _load_target_model(
name_or_path: str, vae_path: Optional[str], model_version: str, weight_dtype, device="cpu", model_dtype=None
name_or_path: str, vae_path: Optional[str], model_version: str, weight_dtype, device="cpu", model_dtype=None, disable_mmap=False
):
# model_dtype only work with full fp16/bf16
name_or_path = os.readlink(name_or_path) if os.path.islink(name_or_path) else name_or_path
Expand All @@ -75,7 +76,7 @@ def _load_target_model(
unet,
logit_scale,
ckpt_info,
) = sdxl_model_util.load_models_from_sdxl_checkpoint(model_version, name_or_path, device, model_dtype)
) = sdxl_model_util.load_models_from_sdxl_checkpoint(model_version, name_or_path, device, model_dtype, disable_mmap)
else:
# Diffusers model is loaded to CPU
from diffusers import StableDiffusionXLPipeline
Expand Down Expand Up @@ -332,6 +333,10 @@ def add_sdxl_training_arguments(parser: argparse.ArgumentParser):
action="store_true",
help="cache text encoder outputs to disk / text encoderの出力をディスクにキャッシュする",
)
parser.add_argument(
"--disable_mmap_load_safetensors",
action="store_true",
)


def verify_sdxl_training_args(args: argparse.Namespace, supportTextEncoderCaching: bool = True):
Expand Down