-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[PEFT / LoRA] PEFT integration - text encoder
#5058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
ba24f2a
more fixes
younesbelkada c17634c
up
younesbelkada 2a6e535
up
younesbelkada 01f6d1d
style
younesbelkada 5a150b2
add in setup
younesbelkada 961e776
oops
younesbelkada cdbe739
more changes
younesbelkada 691368b
v1 rzfactor CI
younesbelkada 7918851
Apply suggestions from code review
younesbelkada 14db139
few todos
younesbelkada c06c40b
Merge branch 'main' into peftpart-1
younesbelkada d56a14d
protect torch import
younesbelkada ec87c19
style
younesbelkada 40a6028
fix fuse text encoder
younesbelkada 0c62ef3
Merge remote-tracking branch 'upstream/main' into peftpart-1
younesbelkada c4295c9
Update src/diffusers/loaders.py
younesbelkada 4162ddf
replace with `recurse_replace_peft_layers`
younesbelkada 1d13f40
keep old modules for BC
younesbelkada 78a860d
adjustments on `adjust_lora_scale_text_encoder`
younesbelkada 78a01d5
Merge branch 'main' into peftpart-1
younesbelkada ecbc714
Merge remote-tracking branch 'upstream/main' into peftpart-1
younesbelkada 9d650c9
Merge branch 'peftpart-1' of https://github.com/younesbelkada/diffuse…
younesbelkada 6f1adcd
nit
younesbelkada f890906
move tests
younesbelkada f8e87f6
add conversion utils
younesbelkada 3ba2d4e
Merge remote-tracking branch 'upstream/main' into peftpart-1
younesbelkada dc83fa0
remove unneeded methods
younesbelkada b83fcba
use class method instead
younesbelkada 74e33a9
oops
younesbelkada 9cb8563
use `base_version`
younesbelkada c90f85d
fix examples
younesbelkada 40a4894
fix CI
younesbelkada ea05959
fix weird error with python 3.8
younesbelkada 27e3da6
fix
younesbelkada 3d7c567
better fix
younesbelkada d01a292
style
younesbelkada e836b14
Apply suggestions from code review
younesbelkada cb48405
Apply suggestions from code review
younesbelkada 325462d
add comment
younesbelkada b412adc
Apply suggestions from code review
younesbelkada b72ef23
conv2d support for recurse remove
younesbelkada e072655
added docstrings
younesbelkada bd46ae9
more docstring
younesbelkada 724b52b
add deprecate
younesbelkada 5e6f343
revert
younesbelkada 71650d4
try to fix merge conflicts
younesbelkada 920333f
Merge remote-tracking branch 'upstream/main' into peftpart-1
younesbelkada c7f2099
v1 tests
younesbelkada 7fd5295
add new decorator
younesbelkada e65daa7
add saving utilities test
younesbelkada 209081b
adapt tests a bit
younesbelkada 43b237e
add save / from_pretrained tests
younesbelkada 7e01caf
add saving tests
younesbelkada fc16c44
add scale tests
younesbelkada 5805c02
Merge branch 'main' into peftpart-1
sayakpaul 831bbaa
fix deps tests
younesbelkada d1d1f22
Merge branch 'peftpart-1' of https://github.com/younesbelkada/diffuse…
younesbelkada 24b38a8
fix lora CI
younesbelkada 651de85
fix tests
younesbelkada 26af3ea
add comment
younesbelkada 6e3d33b
fix
younesbelkada 6903825
style
younesbelkada 7aadd30
add slow tests
younesbelkada aedffbf
slow tests pass
younesbelkada 2a64c88
style
younesbelkada 557404f
Update src/diffusers/utils/import_utils.py
younesbelkada 5de8506
Apply suggestions from code review
younesbelkada 65fe519
circumvents pattern finding issue
younesbelkada 9303d04
left a todo
younesbelkada 29bfc56
Merge branch 'main' into peftpart-1
patrickvonplaten 90974ea
Merge remote-tracking branch 'upstream/main' into peftpart-1
younesbelkada 053c827
Merge branch 'peftpart-1' of https://github.com/younesbelkada/diffuse…
younesbelkada 03f7431
Apply suggestions from code review
younesbelkada d4637f7
update hub path
younesbelkada 17ac967
add lora workflow
younesbelkada 5295aa2
fix
younesbelkada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: Fast tests for PRs - PEFT backend | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| DIFFUSERS_IS_CI: yes | ||
| OMP_NUM_THREADS: 4 | ||
| MKL_NUM_THREADS: 4 | ||
| PYTEST_TIMEOUT: 60 | ||
|
|
||
| jobs: | ||
| run_fast_tests: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| config: | ||
| - name: LoRA | ||
| framework: lora | ||
| runner: docker-cpu | ||
| image: diffusers/diffusers-pytorch-cpu | ||
| report: torch_cpu_lora | ||
|
|
||
|
|
||
| name: ${{ matrix.config.name }} | ||
|
|
||
| runs-on: ${{ matrix.config.runner }} | ||
|
|
||
| container: | ||
| image: ${{ matrix.config.image }} | ||
| options: --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/ | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| steps: | ||
| - name: Checkout diffusers | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 2 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| apt-get update && apt-get install libsndfile1-dev libgl1 -y | ||
| python -m pip install -e .[quality,test] | ||
| python -m pip install git+https://github.com/huggingface/accelerate.git | ||
| python -m pip install -U git+https://github.com/huggingface/transformers.git | ||
| python -m pip install -U git+https://github.com/huggingface/peft.git | ||
|
|
||
| - name: Environment | ||
| run: | | ||
| python utils/print_env.py | ||
|
|
||
| - name: Run fast PyTorch LoRA CPU tests with PEFT backend | ||
| if: ${{ matrix.config.framework == 'lora' }} | ||
| run: | | ||
| python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \ | ||
| -s -v \ | ||
| --make-reports=tests_${{ matrix.config.report }} \ | ||
| tests/lora/test_lora_layers_peft.py |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,7 +303,7 @@ def encode_prompt( | |
| self._lora_scale = lora_scale | ||
|
|
||
| # dynamically adjust the LoRA scale | ||
| adjust_lora_scale_text_encoder(self.text_encoder, lora_scale) | ||
| adjust_lora_scale_text_encoder(self.text_encoder, lora_scale, self.use_peft_backend) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent use of reusing subclass variable (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks ! |
||
|
|
||
| if prompt is not None and isinstance(prompt, str): | ||
| batch_size = 1 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯