Skip to content

Conversation

rockerBOO
Copy link
Contributor

What does this PR do?

Converts the alpha + weight for embedders (guidance, txt/img, vector, timestep) from Kohya sd-scripts into diffusers format. There was a # TODO: alphas and this uses the function to convert these over using the one with alphas. Remaining is the final_layer but that is a bit different due to the transform function.

Added a test from a LoRA I made with these using Kohya sd-scripts.

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@sayakpaul

Comment on lines -561 to -562
assign_remaining_weights(
[
Copy link
Member

Choose a reason for hiding this comment

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

Why is this going away? From what I understand, assign_remaining_weights() is doing the same thing as what the changes in this PR are doing no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It isn't converting the alphas so instead of making assign_remaining_weights do the alpha I thought to use the other function (_convert_to_ai_toolkit) here. Maybe I'm missing the key reason this was being used instead.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay. That makes sense.

Could we run the integration tests for Flux LoRA before we merge this PR?

class FluxLoRAIntegrationTests(unittest.TestCase):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't run all the tests due to my PC and even these I had to disable all the skips for this to run. But I was able to complete the test for the new test. If you need more of the tests run I can try though.

RUN_SLOW=1 RUN_NIGHTLY=1 python -m pytest tests/lora/test_lora_layers_flux.py -k test_flux_kohya_embedders_conversion
platform linux -- Python 3.13.5, pytest-8.4.2, pluggy-1.6.0
rootdir: /home/rockerboo/code/others/diffusers
configfile: pyproject.toml
plugins: timeout-2.4.0, requests-mock-1.10.0, xdist-3.8.0
collected 122 items / 121 deselected / 1 selected

tests/lora/test_lora_layers_flux.py .

1 passed, 121 deselected, 3 warnings in 555.38s (0:09:15)

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant the other tests that we have in the test suite. Let me try to run them.

@sayakpaul
Copy link
Member

@bot /style

Copy link
Contributor

github-actions bot commented Sep 18, 2025

Style bot fixed some files and pushed the changes.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sayakpaul
Copy link
Member

Just ran all the tests and they pass. Will merge the PR after the CI is through.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Super cool!

@sayakpaul sayakpaul merged commit 7e7e62c into huggingface:main Sep 18, 2025
10 checks passed
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.

3 participants