Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- quanto-exps-2/benchmark.py +135 -0
- quanto-exps-2/benchmark_2.py +147 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@1-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@0-fuse@0_info.json +1 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@[email protected] +3 -0
- quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@1-fuse@0_info.json +1 -0
quanto-exps-2/benchmark.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
from optimum.quanto import freeze, qfloat8, qint4, qint8, quantize
|
| 3 |
+
import torch
|
| 4 |
+
import json
|
| 5 |
+
import torch.utils.benchmark as benchmark
|
| 6 |
+
from diffusers import DiffusionPipeline
|
| 7 |
+
import gc
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
WARM_UP_ITERS = 5
|
| 11 |
+
PROMPT = "ghibli style, a fantasy landscape with castles"
|
| 12 |
+
|
| 13 |
+
TORCH_DTYPES = {"fp32": torch.float32, "fp16": torch.float16, "bf16": torch.bfloat16}
|
| 14 |
+
# QTYPES = {"fp8": qfloat8, "int8": qint8, "int4": qint4, "none": None}
|
| 15 |
+
QTYPES = {"fp8": qfloat8, "int8": qint8, "none": None}
|
| 16 |
+
|
| 17 |
+
PREFIXES = {
|
| 18 |
+
"stabilityai/stable-diffusion-3-medium-diffusers": "sd3",
|
| 19 |
+
"PixArt-alpha/PixArt-Sigma-XL-2-1024-MS": "pixart",
|
| 20 |
+
"fal/AuraFlow": "auraflow",
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
def flush():
|
| 24 |
+
"""Wipes off memory."""
|
| 25 |
+
gc.collect()
|
| 26 |
+
torch.cuda.empty_cache()
|
| 27 |
+
torch.cuda.reset_max_memory_allocated()
|
| 28 |
+
torch.cuda.reset_peak_memory_stats()
|
| 29 |
+
|
| 30 |
+
def load_pipeline(ckpt_id, torch_dtype, qtype=None, exclude_layers=None, qte=False, fuse=False):
|
| 31 |
+
pipe = DiffusionPipeline.from_pretrained(ckpt_id, torch_dtype=torch_dtype).to("cuda")
|
| 32 |
+
if fuse:
|
| 33 |
+
pipe.transformer.fuse_qkv_projections()
|
| 34 |
+
|
| 35 |
+
if qtype:
|
| 36 |
+
quantize(pipe.transformer, weights=qtype, exclude=exclude_layers)
|
| 37 |
+
freeze(pipe.transformer)
|
| 38 |
+
|
| 39 |
+
if qte:
|
| 40 |
+
quantize(pipe.text_encoder, weights=qtype)
|
| 41 |
+
freeze(pipe.text_encoder)
|
| 42 |
+
if hasattr(pipe, "text_encoder_2"):
|
| 43 |
+
quantize(pipe.text_encoder_2, weights=qtype)
|
| 44 |
+
freeze(pipe.text_encoder_2)
|
| 45 |
+
if hasattr(pipe, "text_encoder_3"):
|
| 46 |
+
quantize(pipe.text_encoder_3, weights=qtype)
|
| 47 |
+
freeze(pipe.text_encoder_3)
|
| 48 |
+
|
| 49 |
+
pipe.set_progress_bar_config(disable=True)
|
| 50 |
+
return pipe
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def run_inference(pipe, batch_size=1):
|
| 54 |
+
_ = pipe(
|
| 55 |
+
prompt=PROMPT,
|
| 56 |
+
num_images_per_prompt=batch_size,
|
| 57 |
+
generator=torch.manual_seed(0),
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def benchmark_fn(f, *args, **kwargs):
|
| 62 |
+
t0 = benchmark.Timer(stmt="f(*args, **kwargs)", globals={"args": args, "kwargs": kwargs, "f": f})
|
| 63 |
+
return f"{(t0.blocked_autorange().mean):.3f}"
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def bytes_to_giga_bytes(bytes):
|
| 67 |
+
return f"{(bytes / 1024 / 1024 / 1024):.3f}"
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
if __name__ == "__main__":
|
| 71 |
+
parser = argparse.ArgumentParser()
|
| 72 |
+
parser.add_argument(
|
| 73 |
+
"--ckpt_id",
|
| 74 |
+
type=str,
|
| 75 |
+
default="stabilityai/stable-diffusion-3-medium-diffusers",
|
| 76 |
+
choices=list(PREFIXES.keys()),
|
| 77 |
+
)
|
| 78 |
+
parser.add_argument("--batch_size", type=int, default=1)
|
| 79 |
+
parser.add_argument("--torch_dtype", type=str, default="fp16", choices=list(TORCH_DTYPES.keys()))
|
| 80 |
+
parser.add_argument("--qtype", type=str, default="none", choices=list(QTYPES.keys()))
|
| 81 |
+
parser.add_argument("--qte", type=int, default=0, help="Quantize text encoder")
|
| 82 |
+
parser.add_argument("--fuse", type=int, default=0)
|
| 83 |
+
parser.add_argument("--exclude_layers", metavar="N", type=str, nargs="*", default=None)
|
| 84 |
+
args = parser.parse_args()
|
| 85 |
+
|
| 86 |
+
flush()
|
| 87 |
+
|
| 88 |
+
print(
|
| 89 |
+
f"Running with ckpt_id: {args.ckpt_id}, batch_size: {args.batch_size}, torch_dtype: {args.torch_dtype}, qtype: {args.qtype}, qte: {bool(args.qte)}, {args.exclude_layers=}, {args.fuse=}"
|
| 90 |
+
)
|
| 91 |
+
pipeline = load_pipeline(
|
| 92 |
+
ckpt_id=args.ckpt_id,
|
| 93 |
+
torch_dtype=TORCH_DTYPES[args.torch_dtype],
|
| 94 |
+
qtype=QTYPES[args.qtype],
|
| 95 |
+
exclude_layers=args.exclude_layers,
|
| 96 |
+
qte=args.qte,
|
| 97 |
+
fuse=bool(args.fuse),
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
for _ in range(WARM_UP_ITERS):
|
| 101 |
+
run_inference(pipeline, args.batch_size)
|
| 102 |
+
|
| 103 |
+
time = benchmark_fn(run_inference, pipeline, args.batch_size)
|
| 104 |
+
torch.cuda.empty_cache()
|
| 105 |
+
memory = bytes_to_giga_bytes(torch.cuda.memory_allocated()) # in GBs.
|
| 106 |
+
print(
|
| 107 |
+
f"ckpt: {args.ckpt_id} batch_size: {args.batch_size}, qte: {args.qte}, {args.exclude_layers=} "
|
| 108 |
+
f"torch_dtype: {args.torch_dtype}, qtype: {args.qtype} in {time} seconds and {memory} GBs."
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
ckpt_id = PREFIXES[args.ckpt_id]
|
| 112 |
+
img_name = f"ckpt@{ckpt_id}-bs@{args.batch_size}-dtype@{args.torch_dtype}-qtype@{args.qtype}-qte@{args.qte}-fuse@{args.fuse}"
|
| 113 |
+
if args.exclude_layers:
|
| 114 |
+
exclude_layers = "_".join(args.exclude_layers)
|
| 115 |
+
img_name += f"-exclude@{exclude_layers}"
|
| 116 |
+
image = pipeline(
|
| 117 |
+
prompt=PROMPT,
|
| 118 |
+
num_images_per_prompt=args.batch_size,
|
| 119 |
+
generator=torch.manual_seed(0),
|
| 120 |
+
).images[0]
|
| 121 |
+
image.save(f"{img_name}.png")
|
| 122 |
+
|
| 123 |
+
info = dict(
|
| 124 |
+
batch_size=args.batch_size,
|
| 125 |
+
memory=memory,
|
| 126 |
+
time=time,
|
| 127 |
+
dtype=args.torch_dtype,
|
| 128 |
+
qtype=args.qtype,
|
| 129 |
+
qte=args.qte,
|
| 130 |
+
exclude_layers=args.exclude_layers,
|
| 131 |
+
# fuse=args.fuse,
|
| 132 |
+
)
|
| 133 |
+
info_file = f"{img_name}_info.json"
|
| 134 |
+
with open(info_file, "w") as f:
|
| 135 |
+
json.dump(info, f)
|
quanto-exps-2/benchmark_2.py
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
from optimum.quanto import freeze, qfloat8, qint4, qint8, quantize
|
| 3 |
+
import torch
|
| 4 |
+
import json
|
| 5 |
+
import torch.utils.benchmark as benchmark
|
| 6 |
+
from diffusers import DiffusionPipeline
|
| 7 |
+
import gc
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
WARM_UP_ITERS = 5
|
| 11 |
+
PROMPT = "ghibli style, a fantasy landscape with castles"
|
| 12 |
+
|
| 13 |
+
TORCH_DTYPES = {"fp32": torch.float32, "fp16": torch.float16, "bf16": torch.bfloat16}
|
| 14 |
+
QTYPES = {"fp8": qfloat8, "int8": qint8, "int4": qint4, "none": None}
|
| 15 |
+
|
| 16 |
+
PREFIXES = {
|
| 17 |
+
"stabilityai/stable-diffusion-3-medium-diffusers": "sd3",
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def flush():
|
| 22 |
+
"""Wipes off memory."""
|
| 23 |
+
gc.collect()
|
| 24 |
+
torch.cuda.empty_cache()
|
| 25 |
+
torch.cuda.reset_max_memory_allocated()
|
| 26 |
+
torch.cuda.reset_peak_memory_stats()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def load_pipeline(
|
| 30 |
+
ckpt_id, torch_dtype, qtype=None, exclude_layers=None, qte=False, first=False, second=False, third=False
|
| 31 |
+
):
|
| 32 |
+
pipe = DiffusionPipeline.from_pretrained(ckpt_id, torch_dtype=torch_dtype).to("cuda")
|
| 33 |
+
|
| 34 |
+
if qtype:
|
| 35 |
+
quantize(pipe.transformer, weights=qtype, exclude=exclude_layers)
|
| 36 |
+
freeze(pipe.transformer)
|
| 37 |
+
|
| 38 |
+
if qte:
|
| 39 |
+
if first:
|
| 40 |
+
quantize(pipe.text_encoder, weights=qtype)
|
| 41 |
+
freeze(pipe.text_encoder)
|
| 42 |
+
if second:
|
| 43 |
+
quantize(pipe.text_encoder_2, weights=qtype)
|
| 44 |
+
freeze(pipe.text_encoder)
|
| 45 |
+
if third:
|
| 46 |
+
quantize(pipe.text_encoder_3, weights=qtype)
|
| 47 |
+
freeze(pipe.text_encoder_3)
|
| 48 |
+
|
| 49 |
+
pipe.set_progress_bar_config(disable=True)
|
| 50 |
+
return pipe
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def run_inference(pipe, batch_size=1):
|
| 54 |
+
_ = pipe(
|
| 55 |
+
prompt=PROMPT,
|
| 56 |
+
num_images_per_prompt=batch_size,
|
| 57 |
+
generator=torch.manual_seed(0),
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def benchmark_fn(f, *args, **kwargs):
|
| 62 |
+
t0 = benchmark.Timer(stmt="f(*args, **kwargs)", globals={"args": args, "kwargs": kwargs, "f": f})
|
| 63 |
+
return f"{(t0.blocked_autorange().mean):.3f}"
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def bytes_to_giga_bytes(bytes):
|
| 67 |
+
return f"{(bytes / 1024 / 1024 / 1024):.3f}"
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
if __name__ == "__main__":
|
| 71 |
+
parser = argparse.ArgumentParser()
|
| 72 |
+
parser.add_argument(
|
| 73 |
+
"--ckpt_id",
|
| 74 |
+
type=str,
|
| 75 |
+
default="stabilityai/stable-diffusion-3-medium-diffusers",
|
| 76 |
+
choices=list(PREFIXES.keys()),
|
| 77 |
+
)
|
| 78 |
+
parser.add_argument("--batch_size", type=int, default=1)
|
| 79 |
+
parser.add_argument("--torch_dtype", type=str, default="fp16", choices=list(TORCH_DTYPES.keys()))
|
| 80 |
+
parser.add_argument("--qtype", type=str, default="none", choices=list(QTYPES.keys()))
|
| 81 |
+
parser.add_argument("--qte", type=int, default=0, help="Quantize text encoder")
|
| 82 |
+
parser.add_argument("--first", type=int, default=0, help="Quantize first text encoder")
|
| 83 |
+
parser.add_argument("--second", type=int, default=0, help="Quantize second text encoder")
|
| 84 |
+
parser.add_argument("--third", type=int, default=0, help="Quantize third text encoder")
|
| 85 |
+
parser.add_argument("--exclude_layers", metavar="N", type=str, nargs="*", default=None)
|
| 86 |
+
args = parser.parse_args()
|
| 87 |
+
|
| 88 |
+
flush()
|
| 89 |
+
|
| 90 |
+
print(
|
| 91 |
+
f"Running with ckpt_id: {args.ckpt_id}, batch_size: {args.batch_size}, torch_dtype: {args.torch_dtype}, qtype: {args.qtype}, qte: {bool(args.qte)}"
|
| 92 |
+
)
|
| 93 |
+
pipeline = load_pipeline(
|
| 94 |
+
ckpt_id=args.ckpt_id,
|
| 95 |
+
torch_dtype=TORCH_DTYPES[args.torch_dtype],
|
| 96 |
+
qtype=QTYPES[args.qtype],
|
| 97 |
+
exclude_layers=args.exclude_layers,
|
| 98 |
+
qte=args.qte,
|
| 99 |
+
first=args.first,
|
| 100 |
+
second=args.second,
|
| 101 |
+
third=args.third,
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
for _ in range(WARM_UP_ITERS):
|
| 105 |
+
run_inference(pipeline, args.batch_size)
|
| 106 |
+
|
| 107 |
+
time = benchmark_fn(run_inference, pipeline, args.batch_size)
|
| 108 |
+
memory = bytes_to_giga_bytes(torch.cuda.max_memory_allocated()) # in GBs.
|
| 109 |
+
print(
|
| 110 |
+
f"ckpt: {args.ckpt_id} batch_size: {args.batch_size}, qte: {args.qte}, "
|
| 111 |
+
f"torch_dtype: {args.torch_dtype}, qtype: {args.qtype} in {time} seconds and {memory} GBs."
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
ckpt_id = PREFIXES[args.ckpt_id]
|
| 115 |
+
img_name = f"ckpt@{ckpt_id}-bs@{args.batch_size}-dtype@{args.torch_dtype}-qtype@{args.qtype}-qte@{args.qte}"
|
| 116 |
+
if args.exclude_layers:
|
| 117 |
+
exclude_layers = "_".join(args.exclude_layers)
|
| 118 |
+
img_name += f"-exclude@{exclude_layers}"
|
| 119 |
+
if args.first:
|
| 120 |
+
img_name += f"-first@{args.first}"
|
| 121 |
+
if args.second:
|
| 122 |
+
img_name += f"-second@{args.second}"
|
| 123 |
+
if args.third:
|
| 124 |
+
img_name += f"-third@{args.third}"
|
| 125 |
+
|
| 126 |
+
image = pipeline(
|
| 127 |
+
prompt=PROMPT,
|
| 128 |
+
num_images_per_prompt=args.batch_size,
|
| 129 |
+
generator=torch.manual_seed(0),
|
| 130 |
+
).images[0]
|
| 131 |
+
image.save(f"{img_name}.png")
|
| 132 |
+
|
| 133 |
+
info = dict(
|
| 134 |
+
batch_size=args.batch_size,
|
| 135 |
+
memory=memory,
|
| 136 |
+
time=time,
|
| 137 |
+
dtype=args.torch_dtype,
|
| 138 |
+
qtype=args.qtype,
|
| 139 |
+
qte=args.qte,
|
| 140 |
+
exclude_layers=args.exclude_layers,
|
| 141 |
+
first=args.first,
|
| 142 |
+
second=args.second,
|
| 143 |
+
third=args.third,
|
| 144 |
+
)
|
| 145 |
+
info_file = f"{img_name}_info.json"
|
| 146 |
+
with open(info_file, "w") as f:
|
| 147 |
+
json.dump(info, f)
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "8.861", "time": "14.298", "dtype": "bf16", "qtype": "fp8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@fp8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "7.783", "time": "14.345", "dtype": "bf16", "qtype": "fp8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "8.860", "time": "13.769", "dtype": "bf16", "qtype": "int8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@int8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "7.783", "time": "13.779", "dtype": "bf16", "qtype": "int8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "15.219", "time": "12.468", "dtype": "bf16", "qtype": "none", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@bf16-qtype@none-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "15.219", "time": "12.485", "dtype": "bf16", "qtype": "none", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "9.466", "time": "14.629", "dtype": "fp16", "qtype": "fp8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@fp8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "7.920", "time": "14.624", "dtype": "fp16", "qtype": "fp8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "9.466", "time": "14.021", "dtype": "fp16", "qtype": "int8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@int8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "7.921", "time": "14.031", "dtype": "fp16", "qtype": "int8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "15.821", "time": "12.666", "dtype": "fp16", "qtype": "none", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@1-dtype@fp16-qtype@none-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 1, "memory": "15.821", "time": "12.648", "dtype": "fp16", "qtype": "none", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "8.860", "time": "50.247", "dtype": "bf16", "qtype": "fp8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@fp8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "7.783", "time": "50.217", "dtype": "bf16", "qtype": "fp8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "8.860", "time": "49.705", "dtype": "bf16", "qtype": "int8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@int8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "7.784", "time": "49.671", "dtype": "bf16", "qtype": "int8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "15.218", "time": "48.483", "dtype": "bf16", "qtype": "none", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@bf16-qtype@none-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "15.219", "time": "48.437", "dtype": "bf16", "qtype": "none", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "9.467", "time": "51.857", "dtype": "fp16", "qtype": "fp8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@fp8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "7.921", "time": "51.903", "dtype": "fp16", "qtype": "fp8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "9.467", "time": "51.386", "dtype": "fp16", "qtype": "int8", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@int8-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "7.922", "time": "51.283", "dtype": "fp16", "qtype": "int8", "qte": 1, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@0-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "15.819", "time": "49.271", "dtype": "fp16", "qtype": "none", "qte": 0, "exclude_layers": null}
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@[email protected]
ADDED
|
Git LFS Details
|
quanto-exps-2/ckpt@auraflow-bs@4-dtype@fp16-qtype@none-qte@1-fuse@0_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"batch_size": 4, "memory": "15.819", "time": "49.254", "dtype": "fp16", "qtype": "none", "qte": 1, "exclude_layers": null}
|