Skip to content

Conversation

@JCBrouwer
Copy link
Contributor

--save_merged_model was not saving anything for me, just loading the model in and exiting.

Based on my reading, I think only lycoris-based merges get saved with the current logic.

What I've done to address this:

  • Centralized the logic in load_dit_model so that saving works the same regardless of which lora style or process_* function is used
  • Exit immediately after saving with sys.exit(0) rather than returning and relying on all calling code to exit correctly as well
  • Added a progress bar to mem_eff_save_file for some more visual feedback

Copy link
Owner

@kohya-ss kohya-ss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge_lora_weights is called not only by Wan but also by Flux Kontext, FramePack, and Qwen-Image. Is it possible to fix and simplify the issue by including those? If not, please fix only Wan and I will merge this into a new branch and make additional fixes.

f.write(hjson)

for k, v in tensors.items():
for k, v in tqdm(tensors.items(), desc=f"Saving model to {filename}...", total=len(tensors)):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called not only for saving models but also for saving caches, so the logging output by tqdm is too verbose. Could you please remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah woops, yes can do!

I can also make the progress bar an option on mem_eff_save_file.

What do you prefer?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I think anyone who uses this option understands that saving after merging takes some time, so I think it's fine to simply delete tqdm.

@JCBrouwer
Copy link
Contributor Author

merge_lora_weights is called not only by Wan but also by Flux Kontext, FramePack, and Qwen-Image. Is it possible to fix and simplify the issue by including those? If not, please fix only Wan and I will merge this into a new branch and make additional fixes.

I'll take a look and see if I can centralize the fix there instead

@JCBrouwer JCBrouwer force-pushed the fix-save-merged-model branch from f811f89 to 4fcc570 Compare October 4, 2025 12:20
@JCBrouwer
Copy link
Contributor Author

Hi @kohya-ss, I've given a shot at refactoring the other models as well. It's not as simple as only overriding merge_lora_weights as sometimes the lora weights are merged in load_safetensors_with_lora_and_fp8 instead (at least as far as I can tell).

I've made the shortcut model saving + exits in both of those functions and tried to link it up in each of the generation scripts.

I don't have loras to try out all of these different models now, so please give this an extra good read over!

@JCBrouwer
Copy link
Contributor Author

Oh and I removed the progress bar from mem_eff_save_file

@kohya-ss
Copy link
Owner

kohya-ss commented Oct 5, 2025

Thank you for update! Could you please format it in ruff?

Also, please understand that I may make some changes after merging.

@JCBrouwer
Copy link
Contributor Author

JCBrouwer commented Oct 5, 2025

ruff format src doesn't show any changes for me.

Of course, any changes that you see fit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants