even better more structured throughput scheduling
Validate Operations / validate-operations (push) Has been cancelled

plot adjustments
validation adjustments
This commit is contained in:
NiccoloN
2026-10-27 17:46:46 +01:00
parent 49d6fb42cf
commit a77edafcbf
46 changed files with 3265 additions and 1043 deletions
+69 -26
View File
@@ -37,10 +37,6 @@ VARIANTS = (
Variant("baseline", ()),
Variant("no-sync", ("--pim-disable-synchronization",)),
Variant("no-plan", ("--pim-disable-spatial-planning",)),
Variant(
"no-sync-no-plan",
("--pim-disable-synchronization", "--pim-disable-spatial-planning"),
),
)
VARIANT_BY_NAME = {variant.name: variant for variant in VARIANTS}
COMPARISON_RESULTS_FILENAME = "results_comparison.csv"
@@ -53,17 +49,19 @@ PERCENTAGE_FIELDS = (
("raptor_power_mw", "power"),
("raptor_energy_pj", "energy"),
)
RESULT_FIELDS = (*CASE_FIELDS, "functional_validation", *(target for _, target in PERCENTAGE_FIELDS))
RESULT_FIELDS = (
"comparison", *CASE_FIELDS, "baseline_variant", "baseline_functional_validation",
"functional_validation", *(f"{target}_gain_percent" for _, target in PERCENTAGE_FIELDS),
)
DEFAULT_CASE_ARGUMENTS = (
("latency", ("--mode", "latency")),
("throughput/pipeline4", ("--mode", "throughput", "--pipeline", "4")),
)
DEFAULT_CASE_KEYS = frozenset({("latency", "1"), ("throughput", "4")})
def parse_args(argv: list[str] | None = None) -> tuple[argparse.Namespace, list[str]]:
parser = argparse.ArgumentParser(
description="Run the complete compiler ablation matrix on the Pimcomp model suite.",
description="Measure planning and synchronization gains on the Pimcomp model suite.",
allow_abbrev=False,
)
parser.add_argument(
@@ -97,12 +95,30 @@ def has_option(arguments: list[str], option: str) -> bool:
def runner_argument_sets(forwarded: list[str]) -> tuple[tuple[str, list[str]], ...]:
if has_option(forwarded, "--mode") or has_option(forwarded, "--pipeline"):
return (("requested", forwarded),)
return tuple(
(label, [*forwarded, *case_arguments])
for label, case_arguments in DEFAULT_CASE_ARGUMENTS
)
if not has_option(forwarded, "--mode") and not has_option(forwarded, "--pipeline"):
return tuple(
(label, [*forwarded, *case_arguments])
for label, case_arguments in DEFAULT_CASE_ARGUMENTS
)
parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
parser.add_argument("--mode", nargs="+", choices=("latency", "throughput"))
parser.add_argument("--pipeline", type=int, choices=(1, 2, 4, 8))
args, remaining = parser.parse_known_args(forwarded)
cases = [(mode, pipeline) for mode, pipeline in
(("latency", 1), ("throughput", 2), ("throughput", 4), ("throughput", 8))
if (args.mode is None or mode in args.mode)
and (args.pipeline is None or pipeline == args.pipeline)]
if not cases:
parser.error("--pipeline does not belong to the selected --mode")
return tuple((f"{mode}/pipeline{pipeline}",
[*remaining, "--mode", mode, "--pipeline", str(pipeline)])
for mode, pipeline in cases)
def case_key(arguments: list[str]) -> tuple[str, str]:
mode = arguments[arguments.index("--mode") + 1]
pipeline = arguments[arguments.index("--pipeline") + 1] if "--pipeline" in arguments else "1"
return mode, pipeline
def variant_output_dir(out_dir: Path, variant: Variant) -> Path:
@@ -154,7 +170,9 @@ def terminate_process_group(process: subprocess.Popen[bytes]) -> None:
process.wait()
def percentage_difference(value: str | None, reference: str | None) -> str:
def percentage_difference(
value: str | None, reference: str | None, *, lower_is_better: bool = False
) -> str:
try:
current = float(value) if value is not None else math.nan
baseline = float(reference) if reference is not None else math.nan
@@ -162,7 +180,8 @@ def percentage_difference(value: str | None, reference: str | None) -> str:
return "NA"
if not math.isfinite(current) or not math.isfinite(baseline) or current <= 0 or baseline <= 0:
return "NA"
change = (current / baseline - 1) * 100
ratio = current / baseline
change = (1 - ratio if lower_is_better else ratio - 1) * 100
return f"{change:+.2f}%" if math.isfinite(change) else "NA"
@@ -202,25 +221,43 @@ def aggregate_results(
selected_rows.append(row)
if fields is None:
return None, failures
baseline_rows = {
enabled_rows = {
tuple(row.get(field, "") for field in CASE_FIELDS): row
for row in rows_by_variant.get("baseline", [])
}
if "baseline" not in rows_by_variant:
failures.append("baseline: missing percentage reference results")
failures.append("baseline: missing fully enabled results")
result_rows = []
variant_order = {variant.name: index for index, variant in enumerate(VARIANTS)}
for variant in variants:
if variant.name == "baseline":
continue
disabled_keys = {
tuple(row.get(field, "") for field in CASE_FIELDS)
for row in rows_by_variant.get(variant.name, [])
}
for key, row in enabled_rows.items():
if variant.name == "no-sync" and row.get("mode") != "throughput":
continue
if key not in disabled_keys:
failures.append(f"{variant.name}: missing baseline case " + "/".join(key))
for row in rows_by_variant.get(variant.name, []):
reference = baseline_rows.get(tuple(row.get(field, "") for field in CASE_FIELDS))
if variant.name == "no-sync" and row.get("mode") != "throughput":
continue
enabled = enabled_rows.get(tuple(row.get(field, "") for field in CASE_FIELDS))
if enabled is None:
failures.append(f"{variant.name}: missing fully enabled case "
+ "/".join(row.get(field, "") for field in CASE_FIELDS))
result_rows.append(
{
"variant": variant.name,
"comparison": "plan" if variant.name == "no-plan" else "sync",
**{field: row.get(field, "") for field in CASE_FIELDS},
"functional_validation": row.get("raptor_functional_validation", "NA"),
"baseline_variant": variant.name,
"baseline_functional_validation": row.get("raptor_functional_validation", "NA"),
"functional_validation": enabled.get("raptor_functional_validation", "NA") if enabled else "NA",
**{
target: percentage_difference(
row.get(source), reference.get(source) if reference else None
f"{target}_gain_percent": percentage_difference(
enabled.get(source) if enabled else None, row.get(source),
lower_is_better=target != "throughput",
)
for source, target in PERCENTAGE_FIELDS
},
@@ -231,14 +268,14 @@ def aggregate_results(
row["arch"],
row["model"],
row["mode"],
variant_order[row["variant"]],
int(row["raptor_pipeline"]),
row["comparison"],
)
)
output = output if output is not None else out_dir / ABLATION_RESULTS_FILENAME
output.parent.mkdir(parents=True, exist_ok=True)
with output.open("w", newline="", encoding="utf-8") as stream:
writer = csv.DictWriter(stream, fieldnames=("variant", *RESULT_FIELDS), lineterminator="\n")
writer = csv.DictWriter(stream, fieldnames=RESULT_FIELDS, lineterminator="\n")
writer.writeheader()
writer.writerows(result_rows)
return output, failures
@@ -252,9 +289,13 @@ def main(argv: list[str] | None = None) -> int:
variants = selected_variants(args.variants)
out_dir = args.out_dir.resolve() if args.out_dir is not None else DEFAULT_OUT_DIR
case_sets = runner_argument_sets(forwarded)
if not any(case_key(arguments)[0] == "throughput" for _, arguments in case_sets):
variants = [variant for variant in variants if variant.name != "no-sync"]
if args.dry_run:
for variant in variants:
for _, case_forwarded in case_sets:
if variant.name == "no-sync" and case_key(case_forwarded)[0] != "throughput":
continue
print(
shlex.join(
runner_command(
@@ -275,6 +316,8 @@ def main(argv: list[str] | None = None) -> int:
try:
for variant in variants:
for case_label, case_forwarded in case_sets:
if variant.name == "no-sync" and case_key(case_forwarded)[0] != "throughput":
continue
command = runner_command(
out_dir, variant, args.models, case_forwarded, out_dir, False
)
@@ -296,7 +339,7 @@ def main(argv: list[str] | None = None) -> int:
return 130
remove_lock_files(out_dir)
selected_cases = DEFAULT_CASE_KEYS if len(case_sets) > 1 else None
selected_cases = frozenset(case_key(arguments) for _, arguments in case_sets)
output, aggregation_failures = aggregate_results(
out_dir,
variants,