Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/diffusers/quantization/diffusion_trt.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ def main():

image_name = args.save_image_as if args.save_image_as else f"{args.model}.png"

pipe = PipelineManager.create_pipeline_from(MODEL_ID[args.model], dtype_map[args.model_dtype])
pipe = PipelineManager.create_pipeline_from(
MODEL_ID[args.model],
dtype_map[args.model_dtype],
override_model_path=args.override_model_path,
)

# Save the backbone of the pipeline and move it to the GPU
add_embedding = None
Expand Down
8 changes: 6 additions & 2 deletions examples/diffusers/quantization/quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ def __init__(self, config: ModelConfig, logger: logging.Logger):

@staticmethod
def create_pipeline_from(
model_type: ModelType, torch_dtype: torch.dtype = torch.bfloat16
model_type: ModelType,
torch_dtype: torch.dtype = torch.bfloat16,
override_model_path: str | None = None,
) -> DiffusionPipeline:
"""
Create and return an appropriate pipeline based on configuration.
Expand All @@ -321,7 +323,9 @@ def create_pipeline_from(
ValueError: If model type is unsupported
"""
try:
model_id = MODEL_REGISTRY[model_type]
model_id = (
MODEL_REGISTRY[model_type] if override_model_path is None else override_model_path
)
if model_type == ModelType.SD3_MEDIUM:
pipe = StableDiffusion3Pipeline.from_pretrained(model_id, torch_dtype=torch_dtype)
elif model_type in [ModelType.FLUX_DEV, ModelType.FLUX_SCHNELL]:
Expand Down
1 change: 1 addition & 0 deletions examples/diffusers/quantization/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cuda-python
diffusers<=0.34.0
nvtx
onnx_graphsurgeon
opencv-python>=4.8.1.78,<4.12.0.88
Expand Down
Loading