Skip to content
Open
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
28 changes: 20 additions & 8 deletions text_to_video/wan-2.2-t2v-a14b/run_mlperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def load_prompts(dataset_path):


class Model:
def __init__(self, model_path, device, config, prompts, fixed_latent=None, rank=0):
def __init__(self, model_path, device, config,
prompts, fixed_latent=None, rank=0):
self.device = device
self.rank = rank
self.height = config["height"]
Expand Down Expand Up @@ -106,7 +107,8 @@ def flush_queries(self):


class DebugModel:
def __init__(self, model_path, device, config, prompts, fixed_latent=None, rank=0):
def __init__(self, model_path, device, config,
prompts, fixed_latent=None, rank=0):
self.prompts = prompts

def issue_queries(self, query_samples):
Expand Down Expand Up @@ -186,7 +188,8 @@ def get_args():
parser.add_argument(
"--scenario",
default="SingleStream",
help="mlperf benchmark scenario, one of " + str(list(SCENARIO_MAP.keys())),
help="mlperf benchmark scenario, one of " +
str(list(SCENARIO_MAP.keys())),
)
parser.add_argument(
"--user_conf",
Expand All @@ -202,7 +205,10 @@ def get_args():
help="performance sample count",
default=5000,
)
parser.add_argument("--accuracy", action="store_true", help="enable accuracy pass")
parser.add_argument(
"--accuracy",
action="store_true",
help="enable accuracy pass")
# Dont overwrite these for official submission
parser.add_argument("--count", type=int, help="dataset items to use")
parser.add_argument("--time", type=int, help="time to scan in seconds")
Expand Down Expand Up @@ -271,7 +277,10 @@ def run_mlperf(args, config):

audit_config = os.path.abspath(args.audit_conf)
if os.path.exists(audit_config):
settings.FromConfig(audit_config, "wan-2.2-t2v-a14b", args.scenario)
settings.FromConfig(
audit_config,
"wan-2.2-t2v-a14b",
args.scenario)
settings.scenario = SCENARIO_MAP[args.scenario]

settings.mode = lg.TestMode.PerformanceOnly
Expand All @@ -297,8 +306,10 @@ def run_mlperf(args, config):
if args.samples_per_query:
settings.multi_stream_samples_per_query = args.samples_per_query
if args.max_latency:
settings.server_target_latency_ns = int(args.max_latency * NANO_SEC)
settings.multi_stream_expected_latency_ns = int(args.max_latency * NANO_SEC)
settings.server_target_latency_ns = int(
args.max_latency * NANO_SEC)
settings.multi_stream_expected_latency_ns = int(
args.max_latency * NANO_SEC)

performance_sample_count = (
args.performance_sample_count
Expand All @@ -311,7 +322,8 @@ def run_mlperf(args, config):
count, performance_sample_count, load_query_samples, unload_query_samples
)

lg.StartTestWithLogSettings(sut, qsl, settings, log_settings, audit_config)
lg.StartTestWithLogSettings(
sut, qsl, settings, log_settings, audit_config)

lg.DestroyQSL(qsl)
lg.DestroySUT(sut)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from torch.utils.data import DataLoader, Dataset

import torchvision.transforms as transforms
from torchvision.models.quantization import *
import torchvision.models.quantization as torchvision_quantization_models


class CalibrationDataset(Dataset):
Expand Down Expand Up @@ -73,7 +73,11 @@ def main():
)
dataloader = DataLoader(dataset, batch_size=1)

model = eval(args.model)(pretrained=True, progress=True, quantize=False)
if not hasattr(torchvision_quantization_models, args.model):
raise ValueError(f"Model {args.model} not found in torchvision quantization models")


model = getattr(torchvision_quantization_models, args.model)(pretrained=True, progress=True, quantize=False)
quantize_model(model, dataloader)
print(model)

Expand Down