Skip to content

Commit 4c3516f

Browse files
committed
block invalid RAS usages #22
1 parent 25ba42f commit 4c3516f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

dgenerate/pipelinewrapper/wrapper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,6 +3050,17 @@ def _auto_ras_check(self, args: DiffusionArguments):
30503050
raise _pipelines.UnsupportedPipelineConfigError(
30513051
'RAS does not support model CPU offloading.')
30523052

3053+
if args.ras_index_fusion and self.model_sequential_offload:
3054+
raise _pipelines.UnsupportedPipelineConfigError(
3055+
'Index fusion is not supported for RAS when sequential offloading is enabled.')
3056+
3057+
if args.ras_index_fusion and (
3058+
self.quantizer_uri or (self._unet_uri and _uris.UNetUri.parse(self._unet_uri).quantizer)
3059+
):
3060+
raise _pipelines.UnsupportedPipelineConfigError(
3061+
'Index fusion is not supported for RAS when UNet quantization is enabled, '
3062+
'quantize the text encoders individually.')
3063+
30533064
start_step = _types.default(args.ras_start_step, _constants.DEFAULT_RAS_START_STEP)
30543065
end_step = _types.default(args.ras_end_step, args.inference_steps)
30553066
if start_step > end_step:

dgenerate/renderloopconfig.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,13 +1301,13 @@ def _check_help_arguments(self, a_namer: typing.Callable[[str], str]) -> bool:
13011301

13021302
if text_encoder_help and len(self.text_encoder_uris) > 1:
13031303
raise RenderLoopConfigError(
1304-
f'You cannot specify "help" or "helpargs" to {a_namer("text_encoders")} '
1304+
f'You cannot specify "help" or "helpargs" to {a_namer("text_encoder_uris")} '
13051305
f'with multiple values involved.'
13061306
)
13071307

13081308
if second_model_text_encoder_help and len(self.second_model_text_encoder_uris) > 1:
13091309
raise RenderLoopConfigError(
1310-
f'You cannot specify "help" or "helpargs" to {a_namer("second_model_text_encoders")} '
1310+
f'You cannot specify "help" or "helpargs" to {a_namer("second_model_text_encoder_uris")} '
13111311
f'with multiple values involved.'
13121312
)
13131313

@@ -1340,6 +1340,18 @@ def _check_optimization_features(self, a_namer: typing.Callable[[str], str]):
13401340
f'{a_namer("model_cpu_offload")} is not compatible '
13411341
f'with {a_namer("ras")} and related arguments.'
13421342
)
1343+
if self.ras_index_fusion and self.model_sequential_offload:
1344+
raise RenderLoopConfigError(
1345+
f'{a_namer("ras_index_fusion")} is not compatible '
1346+
f'with {a_namer("model_sequential_offload")}.'
1347+
)
1348+
1349+
if self.ras_index_fusion and (
1350+
self.quantizer_uri or (self.unet_uri and _pipelinewrapper.UNetUri.parse(self.unet_uri).quantizer)
1351+
):
1352+
raise RenderLoopConfigError(
1353+
f'{a_namer("ras_index_fusion")} is not supported for RAS when UNet quantization is enabled, '
1354+
f'quantize the text encoders individually using {a_namer("text_encoder_uris")}.')
13431355

13441356
def _check_second_model_compatibility(self, a_namer: typing.Callable[[str], str]):
13451357
"""Check compatibility of second model arguments with the primary model type."""

0 commit comments

Comments
 (0)