Skip to content

Commit

Permalink
add flux symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
noskill committed Sep 6, 2024
1 parent cfa27a3 commit 0b1ddff
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
cd tests/models-sd/SDXL/tiny-sdxl && git lfs pull
- name: pull lfs
run: |
cd tests/models-sd/tiny-flux-pipe && git lfs pull
cd tests/models-sd/flux/tiny-flux-pipe && git lfs pull
- name: symlink models directory
run: ln -s ../../../../models tests/models-full
- name: Test with pytest
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
[submodule "tests/models-sd/SDXL/tiny-sdxl"]
path = tests/models-sd/SDXL/tiny-sdxl
url = https://huggingface.co/hf-internal-testing/tiny-sdxl-pipe
[submodule "tests/models-sd/tiny-flux-pipe"]
[submodule "tests/models-sd/flux/tiny-flux-pipe"]
path = tests/models-sd/flux/tiny-flux-pipe
url = https://huggingface.co/hf-internal-testing/tiny-flux-pipe
9 changes: 5 additions & 4 deletions multigen/loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Type, List
import random
import copy
import copy as cp
from contextlib import nullcontext
import torch
import logging
Expand Down Expand Up @@ -28,10 +28,11 @@ def weightshare_copy(pipe):
ctx = init_empty_weights if is_accelerate_available() else nullcontext
with ctx():
for key, component in copy.components.items():
if key in ('tokenizer', 'tokenizer_2', 'feature_extractor'):
continue
if getattr(copy, key) is None:
continue
if key in ('tokenizer', 'tokenizer_2', 'feature_extractor'):
setattr(copy, key, cp.deepcopy(getattr(copy, key)))
continue
cls = getattr(copy, key).__class__
if hasattr(cls, 'from_config'):
setattr(copy, key, cls.from_config(getattr(copy, key).config))
Expand Down Expand Up @@ -141,7 +142,7 @@ def cache_pipeline(self, pipe: DiffusionPipeline, model_id):
self._cpu_pipes.pop(key_to_delete)
item = pipe
if pipe.device.type == 'cuda':
item = copy.deepcopy(pipe).to('cpu')
item = cp.deepcopy(pipe).to('cpu')
self._cpu_pipes[model_id] = item
logger.debug(f'storing {model_id} on cpu')
assert pipe.device == device
Expand Down
1 change: 1 addition & 0 deletions tests/models-sd/flux/tiny-flux-pipe1
1 change: 1 addition & 0 deletions tests/models-sd/flux/tiny-flux-pipe2
1 change: 1 addition & 0 deletions tests/models-sd/flux/tiny-flux-pipe3
1 change: 1 addition & 0 deletions tests/models-sd/flux/tiny-flux-pipe4

0 comments on commit 0b1ddff

Please sign in to comment.