Skip to content

Commit 115f350

Browse files
committed
Install sub directories with folders correctly, ensure consistent dtype of tensors in flux pipeline and vae
1 parent be6cb2c commit 115f350

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

invokeai/app/invocations/flux_text_to_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _run_diffusion(
7272
t5_embeddings: torch.Tensor,
7373
):
7474
transformer_info = context.models.load(self.transformer.transformer)
75-
inference_dtype = TorchDevice.choose_torch_dtype()
75+
inference_dtype = torch.bfloat16
7676

7777
# Prepare input noise.
7878
# TODO(ryand): Does the seed behave the same on different devices? Should we re-implement this to always use a

invokeai/app/services/model_install/model_install_default.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,9 @@ def _multifile_download(
783783
# So what we do is to synthesize a folder named "sdxl-turbo_vae" here.
784784
if subfolder:
785785
top = Path(remote_files[0].path.parts[0]) # e.g. "sdxl-turbo/"
786-
path_to_remove = top / subfolder.parts[-1] # sdxl-turbo/vae/
787-
path_to_add = Path(f"{top}_{subfolder}")
786+
path_to_remove = top / subfolder # sdxl-turbo/vae/
787+
subfolder_rename = subfolder.name.replace('/', '_').replace('\\', '_')
788+
path_to_add = Path(f"{top}_{subfolder_rename}")
788789
else:
789790
path_to_remove = Path(".")
790791
path_to_add = Path(".")

invokeai/backend/model_manager/load/model_loaders/flux.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ def _load_model(
6464
params = AutoEncoderParams(**filtered_data)
6565

6666
with SilenceWarnings():
67-
model = load_class(params).to(self._torch_dtype)
68-
# load_sft doesn't support torch.device
67+
model = load_class(params)
6968
sd = load_file(model_path)
7069
model.load_state_dict(sd, strict=False, assign=True)
7170

@@ -203,8 +202,6 @@ def _load_from_singlefile(
203202
with accelerate.init_empty_weights():
204203
model = load_class(params)
205204
model = quantize_model_nf4(model, modules_to_not_convert=set(), compute_dtype=torch.bfloat16)
206-
# TODO(ryand): Right now, some of the weights are loaded in bfloat16. Think about how best to handle
207-
# this on GPUs without bfloat16 support.
208205
sd = load_file(model_path)
209206
model.load_state_dict(sd, strict=False, assign=True)
210207
return model

invokeai/backend/model_manager/util/select_hf_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def filter_files(
6969
# limit search to subfolder if requested
7070
if subfolder:
7171
subfolder = root / subfolder
72-
paths = [x for x in paths if x.parent == Path(subfolder)]
72+
paths = [x for x in paths if Path(subfolder) in x.parents]
7373

7474
# _filter_by_variant uniquifies the paths and returns a set
7575
return sorted(_filter_by_variant(paths, variant))

invokeai/backend/quantization/bnb_nf4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _convert_linear_layers_to_nf4(
116116
child.in_features,
117117
child.out_features,
118118
bias=has_bias,
119-
compute_dtype=torch.float16,
119+
compute_dtype=compute_dtype,
120120
compress_statistics=compress_statistics,
121121
)
122122
if has_bias:

0 commit comments

Comments
 (0)