Skip to content

Commit f243ff0

Browse files
authored
Merge pull request #1429 from bghira/feature/disable-text-enc-offload-at-startup
disable offload at startup by default, allow opt-in via --offload_during_startup
2 parents 485d213 + c489e81 commit f243ff0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

helpers/configuration/cmd_args.py

+8
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,14 @@ def get_argument_parser():
12681268
" remote repository specified with --pretrained_model_name_or_path."
12691269
),
12701270
)
1271+
parser.add_argument(
1272+
"--offload_during_startup",
1273+
action="store_true",
1274+
help=(
1275+
"When set, text encoders, the VAE, or other models will be moved to and from the CPU as needed, which can slow"
1276+
" down startup, but saves VRAM. This is useful for video models or high-resolution pre-caching of latent embeds."
1277+
),
1278+
)
12711279
parser.add_argument(
12721280
"--offload_param_path",
12731281
type=str,

helpers/data_backend/factory.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def configure_parquet_database(backend: dict, args, data_backend: BaseDataBacken
455455

456456
def move_text_encoders(args, text_encoders: list, target_device: str):
457457
"""Move text encoders to the target device."""
458-
if text_encoders is None:
458+
if text_encoders is None or not args.offload_during_startup:
459459
return
460460
# we'll move text encoder only if their precision arg is no_change
461461
# otherwise, we assume the user has already moved them to the correct device due to quantisation.

0 commit comments

Comments
 (0)