add paper artifact
Validate Operations / validate-operations (push) Has been cancelled

This commit is contained in:
Niccolò Nicolosi
2026-11-03 14:37:25 +01:00
parent aff9482db1
commit 66db4b66da
21 changed files with 1161 additions and 311 deletions
+13
View File
@@ -0,0 +1,13 @@
*
!Dockerfile
!pins.env
!requirements.lock
!models.sha256
!build.sh
!run.py
!plot_ablation.py
!source.tar.gz
!source.sha256
!validation-overlay/
!validation-overlay/**
!validation-overlay.sha256
+7
View File
@@ -0,0 +1,7 @@
/source.tar.gz
/source.tar.gz.tmp
/source.sha256
/dist/
/results/
/validation-overlay/
/validation-overlay.sha256
+46
View File
@@ -0,0 +1,46 @@
FROM python:3.12.12-slim-trixie AS python-deps
ENV DEBIAN_FRONTEND=noninteractive \
CC=clang-19 CXX=clang++-19 \
LDFLAGS=-fuse-ld=mold \
RUSTFLAGS="-C linker=clang-19 -C link-arg=-fuse-ld=mold" \
CARGO_HOME=/opt/cargo RUSTUP_HOME=/opt/rustup \
PATH=/opt/raptor/.venv/bin:/opt/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 MPLBACKEND=Agg \
PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 \
HOME=/tmp XDG_CACHE_HOME=/tmp/cache MPLCONFIGDIR=/tmp/matplotlib
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential ca-certificates clang-19 curl git libomp-19-dev \
libzstd-dev mold ninja-build pkg-config zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/artifact
COPY pins.env requirements.lock models.sha256 build.sh ./
RUN python -m venv /opt/raptor/.venv \
&& /opt/raptor/.venv/bin/python -m pip install --no-cache-dir --only-binary=onnx -r requirements.lock
FROM python-deps AS artifact
ARG BUILD_JOBS
RUN . ./pins.env && curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs -o /tmp/rustup.sh \
&& sh /tmp/rustup.sh -y --profile minimal --default-toolchain "$RUST_VERSION" \
&& rm /tmp/rustup.sh
COPY source.tar.gz source.sha256 ./
RUN sha256sum -c source.sha256 \
&& . ./pins.env \
&& gzip -dc source.tar.gz > /tmp/raptor-source.tar \
&& test "$(git get-tar-commit-id < /tmp/raptor-source.tar)" = "$RAPTOR_COMMIT" \
&& tar -xf /tmp/raptor-source.tar -C /opt/raptor \
&& rm source.tar.gz /tmp/raptor-source.tar
RUN bash build.sh "${BUILD_JOBS:-$(env -u OMP_NUM_THREADS -u OMP_THREAD_LIMIT nproc)}"
COPY validation-overlay/ ./validation-overlay/
COPY validation-overlay.sha256 ./
RUN sha256sum -c validation-overlay.sha256 \
&& cp -R validation-overlay/validation/. /opt/raptor/validation/ \
&& cp validation-overlay.sha256 /opt/artifact/provenance/
COPY run.py plot_ablation.py ./
WORKDIR /opt/raptor
ENTRYPOINT ["/opt/raptor/.venv/bin/python", "/opt/artifact/run.py"]
CMD ["reproduce"]
+32
View File
@@ -0,0 +1,32 @@
# Raptor paper artifact
Raptor is fixed to commit `4a1fe710b2f0e4e9c0504f4fd9b4c4dd3df53b7d`.
Requires Docker on Linux or WSL2. The build downloads dependencies and uses Clang 19 and mold.
Install the host dependencies:
```bash
sudo apt install -y docker.io docker-cli docker-buildx git
sudo systemctl enable --now docker
sudo usermod -aG docker "$USER"
newgrp docker
```
Log out and back in, then run from this directory:
```bash
bash artifact.sh build
bash artifact.sh reproduce
```
Open `results/full/index.html` to view the plots and result tables.
The page also links to the CSV files and logs. Failed numerical validation remains visible in the results.
For a small VGG8 run, use `bash artifact.sh smoke` and open `results/smoke/index.html`.
Build jobs, run jobs, and threads per job default to the available logical processor count.
Override with `BUILD_JOBS`, `JOBS`, and `THREADS_PER_JOB`, or run `bash artifact.sh reproduce --jobs 8 --threads-per-job 4`.
For another run, set `OUTPUT_DIR` to a new directory.
To prepare the paper attachment, run `bash artifact/artifact.sh package` from the repository root.
The archive is written to `artifact/dist/` and includes the pinned sources and models.
Updated scheduling code is included separately; compiler and simulator sources stay pinned.
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
source pins.env
image="raptor-artifact:${RAPTOR_COMMIT:0:12}"
command=${1:-help}
if (($#)); then shift; fi
case "$command" in
prepare)
exec bash prepare.sh
;;
package)
bash prepare.sh
mkdir -p dist
archive="raptor-artifact-${RAPTOR_COMMIT:0:12}.tar.gz"
package_dir=$(mktemp -d)
trap 'rm -rf -- "$package_dir"' EXIT
mkdir "$package_dir/raptor-artifact"
cp \
README.md artifact.sh prepare.sh Dockerfile .dockerignore pins.env \
requirements.lock models.sha256 build.sh run.py plot_ablation.py source.tar.gz source.sha256 \
"$package_dir/raptor-artifact/"
cp -R validation-overlay "$package_dir/raptor-artifact/"
cp validation-overlay.sha256 "$package_dir/raptor-artifact/"
tar -czf "dist/$archive" -C "$package_dir" raptor-artifact
(cd dist && sha256sum "$archive" > "$archive.sha256")
printf 'Attachment: %s/dist/%s\n' "$PWD" "$archive"
;;
build)
[[ -f source.tar.gz ]] || bash prepare.sh
if [[ -f ../validation/raptor_validation/experiment_scheduler.py ]]; then
bash prepare.sh --overlay-only
fi
sha256sum -c source.sha256
docker build --build-arg "BUILD_JOBS=${BUILD_JOBS:-$(env -u OMP_NUM_THREADS -u OMP_THREAD_LIMIT nproc)}" -t "$image" .
;;
reproduce|smoke|plots)
output=${OUTPUT_DIR:-"$PWD/results"}
mkdir -p "$output"
output=$(cd -- "$output" && pwd)
image_id=$(docker image inspect --format '{{.Id}}' "$image")
status=0
docker run --rm --init --network none \
--user "$(id -u):$(id -g)" \
--env "ARTIFACT_IMAGE_ID=$image_id" \
--env "JOBS=${JOBS:-$(env -u OMP_NUM_THREADS -u OMP_THREAD_LIMIT nproc)}" \
--env "THREADS_PER_JOB=${THREADS_PER_JOB:-$(env -u OMP_NUM_THREADS -u OMP_THREAD_LIMIT nproc)}" \
--mount "type=bind,src=$output,dst=/results" \
"$image" "$command" "$@" || status=$?
profile=full
if [[ "$command" = smoke || " $* " = *' --smoke '* ]]; then profile=smoke; fi
if [[ -f "$output/$profile/index.html" ]]; then
printf '\nOpen %s/%s/index.html\n' "$output" "$profile"
fi
exit "$status"
;;
*)
echo 'Usage: bash artifact.sh {build|smoke|reproduce|plots|package}'
[[ "$command" = help ]]
;;
esac
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
set -euo pipefail
source /opt/artifact/pins.env
export CMAKE_BUILD_PARALLEL_LEVEL=${1:-$(env -u OMP_NUM_THREADS -u OMP_THREAD_LIMIT nproc)}
[[ "$CMAKE_BUILD_PARALLEL_LEVEL" =~ ^[1-9][0-9]*$ ]]
cd /opt/raptor
sha256sum -c /opt/artifact/models.sha256
checkout() {
local url=$1 revision=$2 destination=$3
git init "$destination"
git -C "$destination" remote add origin "$url"
git -C "$destination" fetch --depth 1 origin "$revision"
git -C "$destination" checkout --detach FETCH_HEAD
test "$(git -C "$destination" rev-parse HEAD)" = "$revision"
git -C "$destination" submodule update --init --recursive --depth 1
}
checkout https://github.com/onnx/onnx-mlir.git "$ONNX_MLIR_COMMIT" onnx-mlir
checkout https://github.com/llvm/llvm-project.git "$LLVM_COMMIT" onnx-mlir/llvm-project
checkout https://github.com/HEAPLab/PIMCOMP-NN.git "$PIMCOMP_COMMIT" third_party/PIMCOMP-NN
checkout https://github.com/HEAPLab/pimsim-nn.git "$PIMSIM_COMMIT" backend-simulators/pim/pimsim-nn
checkout https://github.com/protocolbuffers/protobuf.git "$PROTOBUF_COMMIT" /opt/protobuf
common=(-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold
-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=mold
-DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=mold)
cmake -S /opt/protobuf -B /opt/protobuf/build "${common[@]}" \
-Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_ABSL_PROVIDER=module \
-DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_CXX_STANDARD=17
cmake --build /opt/protobuf/build
cmake --install /opt/protobuf/build
ldconfig
llvm=onnx-mlir/llvm-project
cmake -S "$llvm/llvm" -B "$llvm/build_release" "${common[@]}" \
'-DLLVM_ENABLE_PROJECTS=mlir;clang' -DLLVM_ENABLE_RUNTIMES=openmp \
-DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_RTTI=ON \
-DENABLE_LIBOMPTARGET=OFF -DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_PARALLEL_LINK_JOBS="$CMAKE_BUILD_PARALLEL_LEVEL"
cmake --build "$llvm/build_release"
cmake -S . -B build_release "${common[@]}" \
-DONNX_MLIR_ACCELERATORS=PIM -DLLVM_ENABLE_ASSERTIONS=ON \
-DONNX_MLIR_ENABLE_JAVA=OFF -DONNX_MLIR_BUILD_TESTS=OFF \
-DMLIR_DIR="$PWD/$llvm/build_release/lib/cmake/mlir"
cmake --build ./build_release
cmake -S third_party/PIMCOMP-NN -B third_party/PIMCOMP-NN/build "${common[@]}"
cmake --build third_party/PIMCOMP-NN/build --target PIMCOMP-NN
sim=backend-simulators/pim/pimsim-nn
cmake -S "$sim" -B "$sim/build" "${common[@]}"
cmake --build "$sim/build"
ctest --test-dir "$sim/build" --output-on-failure
crate=backend-simulators/pim/pim-simulator
cargo build --locked --release --no-default-features --manifest-path "$crate/Cargo.toml" \
--package pim-simulator --bin pim-simulator --jobs "$CMAKE_BUILD_PARALLEL_LEVEL"
# The experiment driver uses cargo run. All dependencies must be available offline.
cargo fetch --locked --manifest-path "$crate/Cargo.toml"
mkdir -p /opt/artifact/provenance
cp /opt/artifact/pins.env /opt/artifact/source.sha256 /opt/artifact/models.sha256 /opt/artifact/provenance/
for dir in onnx-mlir "$llvm" third_party/PIMCOMP-NN "$sim" /opt/protobuf; do
printf '%s %s\n' "$dir" "$(git -C "$dir" rev-parse HEAD)"
git -C "$dir" submodule status --recursive
done > /opt/artifact/provenance/revisions.txt
dpkg-query -W > /opt/artifact/provenance/system-packages.txt
.venv/bin/python -m pip freeze > /opt/artifact/provenance/python-packages.txt
{ clang-19 --version; mold --version; cmake --version; rustc --version; } \
> /opt/artifact/provenance/toolchain.txt
# Runtime uses an arbitrary host UID. Cargo and the runners need writable caches
# and ONNX-MLIR writes temporary shims/configurations inside its source tree.
chmod -R a+rwX /opt/raptor /opt/cargo /opt/rustup
+5
View File
@@ -0,0 +1,5 @@
788088b908e233d924c7c26b997e89ee861290c7bc56783a306e8201d79aac8f validation/networks/pimcomp_models/resnet18/resnet18-v1-7.onnx
c3231061d081bdd47884137b02134f85142752a39e87263c529cd14ed242b096 validation/networks/pimcomp_models/resnet34/resnet34-v1-7.onnx
c960c195953423388733cd0e60712cf425ca1f8917e264f5cf98e028752c61cf validation/networks/pimcomp_models/googlenet/googlenet-12-no-lrn.onnx
396cdea21e5e7d02c3f26f14d22ef20975171702493f5c5e79b8e0d896e541ef validation/networks/pimcomp_models/vgg8/vgg8-mnist-reconstructed.onnx
5e7bd85dc60b252674f8d7e1ad24f2317d00dfb8c524826536698462de04620d validation/networks/pimcomp_models/yolo11n/yolo11n.onnx
+8
View File
@@ -0,0 +1,8 @@
# Raptor main at artifact preparation time. Do not replace this with a branch.
RAPTOR_COMMIT=4a1fe710b2f0e4e9c0504f4fd9b4c4dd3df53b7d
ONNX_MLIR_COMMIT=eb54c2afc46d00c6b196d1f275b6bfee17e12f69
LLVM_COMMIT=0c2701fe7fa002e1befc5f86c268a7964f96d286
PIMCOMP_COMMIT=7b6be6da4d33bf19f68d073eccac2a78e326a5af
PIMSIM_COMMIT=17e37c15da5473362e53268dabdd07dff5fe8fbf
PROTOBUF_COMMIT=6a6cd88c262ffdb1738167a47d5fcc7a3eb4edac
RUST_VERSION=1.90.0
+59
View File
@@ -0,0 +1,59 @@
"""Plot planning and synchronization gains without hiding invalid programs."""
from __future__ import annotations
import argparse
import csv
import math
from pathlib import Path
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--input', type=Path, required=True)
parser.add_argument('--output-dir', type=Path, required=True)
args = parser.parse_args()
with args.input.open(newline='') as stream:
rows = list(csv.DictReader(stream))
if not rows:
raise ValueError('The ablation CSV is empty')
panels = [('plan', 'latency', 'latency_gain_percent', 'Planning: latency reduction (%)'),
('plan', 'throughput', 'throughput_gain_percent', 'Planning: throughput increase (%)'),
('sync', 'throughput', 'throughput_gain_percent', 'Synchronization: throughput increase (%)')]
fig, axes = plt.subplots(3, 1, figsize=(11, 9), layout='constrained')
for ax, (comparison, mode, field, label) in zip(axes, panels):
selected = sorted((r for r in rows if r['comparison'] == comparison and r['mode'] == mode),
key=lambda r: (r['arch'], r['model'], int(r['raptor_pipeline'])))
for x, row in enumerate(selected):
try:
value = float(row[field].rstrip('%'))
except (ValueError, TypeError):
value = math.nan
valid = row['functional_validation'] == row['baseline_functional_validation'] == 'PASS'
if math.isfinite(value):
ax.bar(x, value, color='#B3D5CA' if valid else '#FF9494',
edgecolor='#222222', hatch='' if valid else '//')
ax.annotate(f'{value:.1f}' + ('' if valid else ' INVALID'),
(x, value), xytext=(0, 4 if value >= 0 else -4),
textcoords='offset points', ha='center',
va='bottom' if value >= 0 else 'top', fontsize=7)
else:
ax.text(x, 0, 'NA', ha='center', va='bottom', fontsize=8)
ax.set_xticks(range(len(selected)),
[f"{r['model']}\n{r['arch']} p{r['raptor_pipeline']}" for r in selected], fontsize=8)
ax.set_ylabel(label)
ax.axhline(0, color='#222222', linewidth=.7)
ax.set_xlim(-.6, max(.6, len(selected) - .4))
ax.margins(y=.3)
fig.suptitle('Raptor ablation (red hatching: functional validation failed)')
args.output_dir.mkdir(parents=True, exist_ok=True)
for extension in ('pdf', 'svg', 'png'):
fig.savefig(args.output_dir / f'ablation.{extension}', dpi=200)
plt.close(fig)
if __name__ == '__main__':
main()
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
source pins.env
repo=$(git -C .. rev-parse --show-toplevel)
test "$(git -C "$repo" rev-parse "$RAPTOR_COMMIT^{commit}")" = "$RAPTOR_COMMIT"
for item in "onnx-mlir:$ONNX_MLIR_COMMIT" \
"third_party/PIMCOMP-NN:$PIMCOMP_COMMIT" \
"backend-simulators/pim/pimsim-nn:$PIMSIM_COMMIT"; do
path=${item%:*}
expected=${item##*:}
actual=$(git -C "$repo" rev-parse "$RAPTOR_COMMIT:$path")
test "$actual" = "$expected"
done
if [[ "${1:-}" != --overlay-only ]]; then
# Include the complete compiler and evaluation code, plus only the suite models.
# The last two paths are the targets of the suite's relative model symlinks.
git -C "$repo" archive --format=tar "$RAPTOR_COMMIT" \
CMakeLists.txt README.md .gitmodules src test docs backend-simulators \
validation/README.md validation/validate.py validation/raptor_validation \
validation/tools validation/pimsim_configs validation/networks/pimcomp_models \
validation/networks/resnet18/depth_68/resnet18_depth_68.onnx \
validation/networks/yolo11n/depth_51/yolo11n_depth_51.onnx \
| gzip -n > source.tar.gz.tmp
mv source.tar.gz.tmp source.tar.gz
sha256sum source.tar.gz > source.sha256
fi
overlay=(validation/raptor_validation/experiment_scheduler.py
validation/tools/pim/pimcomp/compare/run_pimcomp_models.py
validation/tools/pim/pimcomp/compare/compare_raptor_pimcomp_model.py
validation/tools/pim/ablation/run_ablation.py
validation/tools/pim/pimcomp/compare/README.md
validation/tools/pim/ablation/README.md)
for path in "${overlay[@]}"; do
mkdir -p "validation-overlay/$(dirname "$path")"
cp "$repo/$path" "validation-overlay/$path"
done
sha256sum "${overlay[@]/#/validation-overlay/}" > validation-overlay.sha256
printf 'Prepared Raptor %s\n' "$RAPTOR_COMMIT"
+23
View File
@@ -0,0 +1,23 @@
# Evaluation and ONNX-MLIR build dependencies. The Graph Explorer is not required.
cmake==3.31.6
colorama==0.4.6
contourpy==1.3.2
cycler==0.12.1
execnet==2.1.1
fonttools==4.58.0
iniconfig==2.1.0
kiwisolver==1.4.8
lit==15.0.7
matplotlib==3.10.3
numpy==2.2.6
onnx==1.17.0
packaging==25.0
pillow==11.2.1
pluggy==1.5.0
protobuf==7.34.0
pyparsing==3.2.3
pytest==8.3.5
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
six==1.17.0
+140
View File
@@ -0,0 +1,140 @@
"""Container commands for the pinned Raptor paper artifact."""
from __future__ import annotations
import argparse
import csv
from datetime import datetime, timezone
from html import escape
import json
import os
from pathlib import Path
import platform
import shutil
import subprocess
import sys
import time
HERE = Path(__file__).resolve().parent
REPO = Path('/opt/raptor')
PYTHON = REPO / '.venv/bin/python'
COMPARE = Path('validation/tools/pim/pimcomp/compare')
ABLATION = Path('validation/tools/pim/ablation/run_ablation.py')
def stage(name: str, command: list[str], root: Path) -> dict:
print(f'[{name}] {command}', flush=True)
start = time.monotonic()
with (root / f'{name}.log').open('wb') as log:
with subprocess.Popen(command, cwd=REPO, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) as process:
for line in process.stdout:
sys.stdout.buffer.write(line)
sys.stdout.buffer.flush()
log.write(line)
returncode = process.wait()
return {'command': command, 'exit_code': returncode,
'seconds': round(time.monotonic() - start, 3)}
def plots(root: Path, smoke: bool) -> dict:
commands = {'ablation-plots': [str(PYTHON), str(HERE / 'plot_ablation.py'),
'--input', str(root / 'ablation/results_ablation.csv'),
'--output-dir', str(root / 'plots/ablation')]}
if not smoke:
commands['comparison-plots'] = [str(PYTHON), str(COMPARE / 'generate_plots.py'),
'--input', str(root / 'comparison/results_comparison.csv'),
'--output-dir', str(root / 'plots/comparison')]
return {name: stage(name, command, root) for name, command in commands.items()}
def show_results(root: Path) -> None:
page = ['<!doctype html><html lang="en"><meta charset="utf-8">',
'<meta name="viewport" content="width=device-width, initial-scale=1">',
'<title>Raptor results</title><style>',
'body{font:16px sans-serif;max-width:1100px;margin:2rem auto;padding:0 1rem}',
'img{max-width:100%}table{border-collapse:collapse;font-size:13px}',
'th,td{padding:6px;border:1px solid #ccc;white-space:nowrap}',
'.table{overflow-x:auto}</style><h1>Raptor results</h1>',
'<p>Functional validation status is shown in the tables and plots.</p>']
for title, relative in (
('Comparison', 'plots/comparison/png/performance_energy_compact.png'),
('Pipeline throughput', 'plots/comparison/png/raptor_pipeline_throughput.png'),
('Ablation', 'plots/ablation/ablation.png'),
):
if (root / relative).is_file():
page.append(f'<h2>{title}</h2><a href="{relative}"><img src="{relative}" alt="{title}"></a>')
for title, relative in (('Comparison', 'comparison/results_comparison.csv'),
('Ablation', 'ablation/results_ablation.csv')):
path = root / relative
if path.is_file():
page.append(f'<h2>{title} data</h2><p><a href="{relative}">Download CSV</a></p><div class="table"><table>')
with path.open(newline='') as stream:
for index, row in enumerate(csv.reader(stream)):
tag = 'th' if index == 0 else 'td'
page.append('<tr>' + ''.join(f'<{tag}>{escape(value)}</{tag}>' for value in row) + '</tr>')
page.append('</table></div>')
page.append('<h2>Files</h2><ul>')
for path in sorted([*root.glob('*.log'), *root.glob('plots/*')]):
relative = path.relative_to(root).as_posix()
page.append(f'<li><a href="{relative}">{escape(relative)}</a></li>')
page.append('</ul></html>')
(root / 'index.html').write_text('\n'.join(page) + '\n')
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('command', choices=('reproduce', 'smoke', 'plots'))
parser.add_argument('--smoke', action='store_true', help='Plot the smoke results.')
parser.add_argument('--jobs', type=int, default=int(os.environ.get('JOBS', len(os.sched_getaffinity(0)))))
parser.add_argument('--threads-per-job', type=int,
default=int(os.environ.get('THREADS_PER_JOB', len(os.sched_getaffinity(0)))))
args = parser.parse_args()
smoke = args.command == 'smoke' or args.smoke
root = Path('/results') / ('smoke' if smoke else 'full')
os.environ['CARGO_NET_OFFLINE'] = 'true'
if args.command == 'plots':
manifest_path = root / 'run.json'
manifest = json.loads(manifest_path.read_text())
records = plots(root, smoke)
manifest['stages'].update(records)
manifest_path.write_text(json.dumps(manifest, indent=2) + '\n')
show_results(root)
return int(any(record['exit_code'] for record in records.values()))
if root.exists():
parser.error(f'{root} exists. Select a fresh OUTPUT_DIR to prevent stale result reuse.')
jobs = args.jobs
if jobs < 1 or args.threads_per_job < 1:
parser.error('jobs and threads-per-job must be positive')
root.mkdir(parents=True)
shutil.copytree(HERE / 'provenance', root / 'provenance')
# Copy the artifact scripts so each result identifies its orchestration code.
shutil.copytree(HERE, root / 'provenance/artifact',
ignore=shutil.ignore_patterns('provenance', '__pycache__'))
manifest = {'started_utc': datetime.now(timezone.utc).isoformat(),
'profile': 'smoke' if smoke else 'full', 'image_id': os.environ.get('ARTIFACT_IMAGE_ID'),
'platform': platform.platform(), 'machine': platform.machine(),
'cpu_count': os.cpu_count(), 'jobs': jobs, 'threads_per_job': args.threads_per_job,
'batch_size': 64, 'fast': False, 'stages': {}}
common = ['--jobs', str(jobs), '--threads-per-job', str(args.threads_per_job),
'--batch-size', '64', '--no-fast']
subset = ['--models', 'vgg8', '--archs', 'arch-a', '--mode', 'latency', '--pipeline', '1'] if smoke else []
commands = {
'experiments': [str(PYTHON), str(COMPARE / 'run_pimcomp_models.py'),
'--out-dir', str(root / 'comparison'),
'--with-ablation', '--ablation-out-dir', str(root / 'ablation'),
'--common-dir', str(root / 'references'), *common, *subset],
}
manifest_path = root / 'run.json'
manifest_path.write_text(json.dumps(manifest, indent=2) + '\n')
for name, command in commands.items():
manifest['stages'][name] = stage(name, command, root)
manifest_path.write_text(json.dumps(manifest, indent=2) + '\n')
manifest['stages'].update(plots(root, smoke))
manifest['finished_utc'] = datetime.now(timezone.utc).isoformat()
manifest_path.write_text(json.dumps(manifest, indent=2) + '\n')
show_results(root)
return int(any(record['exit_code'] for record in manifest['stages'].values()))
if __name__ == '__main__':
raise SystemExit(main())