Udayshankar Ravikumar commited on
Updated with ranking feature.
Browse files- README.md +1 -1
- app.py +220 -202
- requirements.txt +3 -2
- surrogate_models_v2_json/model_crc32_ipc.json +0 -0
- surrogate_models_v2_json/model_crc32_ipc_meta.json +14 -0
- surrogate_models_v2_json/model_crc32_l2_miss_rate.json +0 -0
- surrogate_models_v2_json/model_crc32_l2_miss_rate_meta.json +14 -0
- surrogate_models_v2_json/model_dijkstra_ipc.json +0 -0
- surrogate_models_v2_json/model_dijkstra_ipc_meta.json +14 -0
- surrogate_models_v2_json/model_dijkstra_l2_miss_rate.json +0 -0
- surrogate_models_v2_json/model_dijkstra_l2_miss_rate_meta.json +14 -0
- surrogate_models_v2_json/model_fft_ipc.json +0 -0
- surrogate_models_v2_json/model_fft_ipc_meta.json +14 -0
- surrogate_models_v2_json/model_fft_l2_miss_rate.json +0 -0
- surrogate_models_v2_json/model_fft_l2_miss_rate_meta.json +14 -0
- surrogate_models_v2_json/model_matrix_mul_ipc.json +0 -0
- surrogate_models_v2_json/model_matrix_mul_ipc_meta.json +14 -0
- surrogate_models_v2_json/model_matrix_mul_l2_miss_rate.json +0 -0
- surrogate_models_v2_json/model_matrix_mul_l2_miss_rate_meta.json +14 -0
- surrogate_models_v2_json/model_qsort_ipc.json +0 -0
- surrogate_models_v2_json/model_qsort_ipc_meta.json +14 -0
- surrogate_models_v2_json/model_qsort_l2_miss_rate.json +0 -0
- surrogate_models_v2_json/model_qsort_l2_miss_rate_meta.json +14 -0
- surrogate_models_v2_json/model_sha_ipc.json +0 -0
- surrogate_models_v2_json/model_sha_ipc_meta.json +14 -0
- surrogate_models_v2_json/model_sha_l2_miss_rate.json +0 -0
- surrogate_models_v2_json/model_sha_l2_miss_rate_meta.json +14 -0
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🧠
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: cc-by-nc-sa-4.0
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.12.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: cc-by-nc-sa-4.0
|
app.py
CHANGED
|
@@ -1,25 +1,33 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import numpy as np
|
| 4 |
-
import joblib
|
| 5 |
import os
|
| 6 |
-
|
|
|
|
| 7 |
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
MODEL_DIR = "
|
| 14 |
|
| 15 |
-
|
| 16 |
-
"
|
| 17 |
-
"matmul": "matrix_mul",
|
| 18 |
}
|
| 19 |
|
| 20 |
-
TARGETS =
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
"l1d_size_log2",
|
| 24 |
"l1i_size_log2",
|
| 25 |
"l2_size_log2",
|
|
@@ -28,98 +36,43 @@ FEATURE_COLS = [
|
|
| 28 |
"l2_assoc_log2",
|
| 29 |
"l2_l1d_ratio_log2",
|
| 30 |
"l1d_sets_log2",
|
| 31 |
-
"l2_sets_log2"
|
| 32 |
]
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
"l1i_assoc",
|
| 41 |
-
"l2_assoc",
|
| 42 |
-
]
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
MODEL_CACHE = {}
|
| 48 |
-
|
| 49 |
-
# -------------------------------------------------
|
| 50 |
-
# Model Download
|
| 51 |
-
# -------------------------------------------------
|
| 52 |
-
def ensure_models():
|
| 53 |
-
if not os.path.exists(MODEL_DIR):
|
| 54 |
-
snapshot_download(
|
| 55 |
-
repo_id=HF_REPO_ID,
|
| 56 |
-
local_dir=".",
|
| 57 |
-
allow_patterns="*.pkl",
|
| 58 |
-
)
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
# -------------------------------------------------
|
| 81 |
-
# Preload models (runs once at app start)
|
| 82 |
-
# -------------------------------------------------
|
| 83 |
-
def preload_models():
|
| 84 |
-
ensure_models()
|
| 85 |
-
|
| 86 |
-
workloads = {
|
| 87 |
-
"crc32",
|
| 88 |
-
"dijkstra",
|
| 89 |
-
"fft",
|
| 90 |
-
"matrix_mul",
|
| 91 |
-
"qsort",
|
| 92 |
-
"sha",
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
for workload in workloads:
|
| 96 |
-
for target in TARGETS:
|
| 97 |
-
path = os.path.join(
|
| 98 |
-
MODEL_DIR, f"model_{workload}_{target}.pkl"
|
| 99 |
-
)
|
| 100 |
-
payload = joblib.load(path)
|
| 101 |
-
MODEL_CACHE[(workload, target)] = (
|
| 102 |
-
payload["model"],
|
| 103 |
-
payload["log_target"],
|
| 104 |
-
)
|
| 105 |
-
|
| 106 |
-
return "ready"
|
| 107 |
-
|
| 108 |
-
# -------------------------------------------------
|
| 109 |
-
# Inference Core
|
| 110 |
-
# -------------------------------------------------
|
| 111 |
-
def run_inference(df: pd.DataFrame) -> pd.DataFrame:
|
| 112 |
-
missing = set(REQUIRED_COLS) - set(df.columns)
|
| 113 |
-
if missing:
|
| 114 |
-
raise ValueError(f"Missing required columns: {missing}")
|
| 115 |
|
| 116 |
for col in [
|
| 117 |
-
"l1d_size",
|
| 118 |
-
"
|
| 119 |
-
"l2_size",
|
| 120 |
-
"l1d_assoc",
|
| 121 |
-
"l1i_assoc",
|
| 122 |
-
"l2_assoc",
|
| 123 |
]:
|
| 124 |
df[f"{col}_log2"] = np.log2(df[col])
|
| 125 |
|
|
@@ -127,126 +80,191 @@ def run_inference(df: pd.DataFrame) -> pd.DataFrame:
|
|
| 127 |
df["l1d_sets_log2"] = df["l1d_size_log2"] - df["l1d_assoc_log2"]
|
| 128 |
df["l2_sets_log2"] = df["l2_size_log2"] - df["l2_assoc_log2"]
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
df["pred_ipc"] = np.nan
|
| 131 |
df["pred_l2_miss_rate"] = np.nan
|
| 132 |
-
df["
|
| 133 |
|
| 134 |
-
|
| 135 |
-
workload = resolve_workload(row["workload"])
|
| 136 |
-
X = row[FEATURE_COLS].values.reshape(1, -1)
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
|
|
|
| 140 |
|
| 141 |
-
|
| 142 |
-
model, is_log = load_model(workload, target)
|
| 143 |
-
pred_raw = model.predict(X)[0]
|
| 144 |
-
pred = np.expm1(pred_raw) if is_log else pred_raw
|
| 145 |
-
if target == "l2_miss_rate":
|
| 146 |
-
pred = np.clip(pred, 0, 1)
|
| 147 |
-
preds[target] = float(pred)
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
)
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
df.at[idx, "warnings"] = "; ".join(warn_msgs)
|
| 156 |
|
| 157 |
-
|
|
|
|
| 158 |
|
| 159 |
-
|
| 160 |
-
# Gradio Wrapper
|
| 161 |
-
# -------------------------------------------------
|
| 162 |
-
def infer_from_csv(file):
|
| 163 |
-
df = pd.read_csv(file.name)
|
| 164 |
-
out_df = run_inference(df)
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
if not warning_rows.empty
|
| 173 |
-
else "No sanity warnings detected."
|
| 174 |
-
)
|
| 175 |
|
| 176 |
-
|
|
|
|
| 177 |
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
#
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
"
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
)
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
matrix_mul,128,64,1024,16,8,16
|
| 220 |
-
fft,128,64,2048,16,8,32
|
| 221 |
-
```
|
| 222 |
-
"""
|
| 223 |
)
|
| 224 |
|
| 225 |
-
|
| 226 |
-
run_btn = gr.Button("Run Inference")
|
| 227 |
|
| 228 |
-
|
| 229 |
-
output_csv = gr.File(label="Download Full Output CSV")
|
| 230 |
-
warnings_box = gr.Textbox(label="Sanity Check Summary")
|
| 231 |
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
)
|
| 250 |
|
| 251 |
-
|
| 252 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import json
|
| 3 |
+
import time
|
| 4 |
import tempfile
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import xgboost as xgb
|
| 8 |
+
import shap
|
| 9 |
+
import matplotlib.pyplot as plt
|
| 10 |
+
import gradio as gr
|
| 11 |
|
| 12 |
+
# =========================================================
|
| 13 |
+
# CONFIG
|
| 14 |
+
# =========================================================
|
| 15 |
+
TOP_K = 20
|
| 16 |
+
MODEL_DIR = "surrogate_models_v2_json"
|
| 17 |
|
| 18 |
+
WORKLOADS = {
|
| 19 |
+
"crc32", "dijkstra", "fft", "qsort", "sha", "matrix_mul"
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
+
TARGETS = {"ipc", "l2_miss_rate"}
|
| 23 |
|
| 24 |
+
REQUIRED_INPUT_COLUMNS = {
|
| 25 |
+
"l1d_size", "l1i_size", "l2_size",
|
| 26 |
+
"l1d_assoc", "l1i_assoc", "l2_assoc",
|
| 27 |
+
"workload"
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
FEATURES = [
|
| 31 |
"l1d_size_log2",
|
| 32 |
"l1i_size_log2",
|
| 33 |
"l2_size_log2",
|
|
|
|
| 36 |
"l2_assoc_log2",
|
| 37 |
"l2_l1d_ratio_log2",
|
| 38 |
"l1d_sets_log2",
|
| 39 |
+
"l2_sets_log2"
|
| 40 |
]
|
| 41 |
|
| 42 |
+
# =========================================================
|
| 43 |
+
# LOAD MODELS
|
| 44 |
+
# =========================================================
|
| 45 |
+
def load_models():
|
| 46 |
+
models = {}
|
| 47 |
+
explainers = {}
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
for w in WORKLOADS:
|
| 50 |
+
for t in TARGETS:
|
| 51 |
+
name = f"model_{w}_{t}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
model = xgb.XGBRegressor()
|
| 54 |
+
model.load_model(os.path.join(MODEL_DIR, f"{name}.json"))
|
| 55 |
+
|
| 56 |
+
with open(os.path.join(MODEL_DIR, f"{name}_meta.json")) as f:
|
| 57 |
+
meta = json.load(f)
|
| 58 |
+
|
| 59 |
+
models[name] = (model, meta["log_target"])
|
| 60 |
+
explainers[name] = shap.TreeExplainer(model)
|
| 61 |
+
|
| 62 |
+
return models, explainers
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
MODELS, EXPLAINERS = load_models()
|
| 66 |
+
|
| 67 |
+
# =========================================================
|
| 68 |
+
# FEATURE ENGINEERING
|
| 69 |
+
# =========================================================
|
| 70 |
+
def engineer_features(df):
|
| 71 |
+
df = df.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
for col in [
|
| 74 |
+
"l1d_size", "l1i_size", "l2_size",
|
| 75 |
+
"l1d_assoc", "l1i_assoc", "l2_assoc"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
]:
|
| 77 |
df[f"{col}_log2"] = np.log2(df[col])
|
| 78 |
|
|
|
|
| 80 |
df["l1d_sets_log2"] = df["l1d_size_log2"] - df["l1d_assoc_log2"]
|
| 81 |
df["l2_sets_log2"] = df["l2_size_log2"] - df["l2_assoc_log2"]
|
| 82 |
|
| 83 |
+
return df
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
# =========================================================
|
| 87 |
+
# MAIN INFERENCE
|
| 88 |
+
# =========================================================
|
| 89 |
+
def run_inference(file):
|
| 90 |
+
df = pd.read_csv(file.name)
|
| 91 |
+
|
| 92 |
+
missing = REQUIRED_INPUT_COLUMNS - set(df.columns)
|
| 93 |
+
if missing:
|
| 94 |
+
raise gr.Error(f"Missing required columns: {missing}")
|
| 95 |
+
|
| 96 |
+
start = time.perf_counter()
|
| 97 |
+
|
| 98 |
+
df = engineer_features(df)
|
| 99 |
+
|
| 100 |
df["pred_ipc"] = np.nan
|
| 101 |
df["pred_l2_miss_rate"] = np.nan
|
| 102 |
+
df["was_clipped"] = False
|
| 103 |
|
| 104 |
+
shap_summary_data = []
|
|
|
|
|
|
|
| 105 |
|
| 106 |
+
for workload, idx in df.groupby("workload").groups.items():
|
| 107 |
+
if workload not in WORKLOADS:
|
| 108 |
+
raise gr.Error(f"Unknown workload: {workload}")
|
| 109 |
|
| 110 |
+
X = df.loc[idx, FEATURES]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
+
model_ipc, log_ipc = MODELS[f"model_{workload}_ipc"]
|
| 113 |
+
model_miss, log_miss = MODELS[f"model_{workload}_l2_miss_rate"]
|
|
|
|
| 114 |
|
| 115 |
+
raw_ipc = model_ipc.predict(X)
|
| 116 |
+
ipc = np.expm1(raw_ipc) if log_ipc else raw_ipc
|
|
|
|
| 117 |
|
| 118 |
+
raw_miss = model_miss.predict(X)
|
| 119 |
+
miss = np.expm1(raw_miss) if log_miss else raw_miss
|
| 120 |
|
| 121 |
+
clipped = (ipc > 3.5) | (ipc < 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
+
ipc = np.clip(ipc, 0, 3.5)
|
| 124 |
+
miss = np.clip(miss, 0, 1)
|
| 125 |
|
| 126 |
+
df.loc[idx, "pred_ipc"] = ipc
|
| 127 |
+
df.loc[idx, "pred_l2_miss_rate"] = miss
|
| 128 |
+
df.loc[idx, "was_clipped"] = clipped
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
+
shap_values = EXPLAINERS[f"model_{workload}_ipc"].shap_values(X)
|
| 131 |
+
shap_summary_data.append((X, shap_values))
|
| 132 |
|
| 133 |
+
inference_time = time.perf_counter() - start
|
| 134 |
+
|
| 135 |
+
# Ranking
|
| 136 |
+
df["score"] = df["pred_ipc"] / (1 + df["pred_l2_miss_rate"])
|
| 137 |
+
|
| 138 |
+
group_cols = [
|
| 139 |
+
"l1d_size", "l1i_size", "l2_size",
|
| 140 |
+
"l1d_assoc", "l1i_assoc", "l2_assoc"
|
| 141 |
+
]
|
| 142 |
+
|
| 143 |
+
agg = df.groupby(group_cols).agg({
|
| 144 |
+
"pred_ipc": "mean",
|
| 145 |
+
"pred_l2_miss_rate": "mean"
|
| 146 |
+
}).reset_index()
|
| 147 |
+
|
| 148 |
+
ipc_std = df.groupby(group_cols)["pred_ipc"].std().reset_index()
|
| 149 |
+
ipc_std.rename(columns={"pred_ipc": "ipc_std"}, inplace=True)
|
| 150 |
+
|
| 151 |
+
agg = agg.merge(ipc_std, on=group_cols)
|
| 152 |
+
|
| 153 |
+
agg["score"] = agg["pred_ipc"] / (1 + agg["pred_l2_miss_rate"])
|
| 154 |
+
agg["robust_score"] = agg["score"] / (1 + agg["ipc_std"])
|
| 155 |
+
|
| 156 |
+
agg = agg.sort_values("robust_score", ascending=False)
|
| 157 |
+
|
| 158 |
+
topk = agg.head(TOP_K)
|
| 159 |
+
|
| 160 |
+
# Save CSVs
|
| 161 |
+
ranked_path = tempfile.NamedTemporaryFile(delete=False, suffix=".csv").name
|
| 162 |
+
topk_path = tempfile.NamedTemporaryFile(delete=False, suffix=".csv").name
|
| 163 |
+
|
| 164 |
+
agg.to_csv(ranked_path, index=False)
|
| 165 |
+
topk.to_csv(topk_path, index=False)
|
| 166 |
+
|
| 167 |
+
# Plot topk robust score
|
| 168 |
+
fig_rank, ax = plt.subplots(figsize=(10, 5))
|
| 169 |
+
ax.bar(range(len(topk)), topk["robust_score"])
|
| 170 |
+
ax.set_title("Top-K Robust Scores")
|
| 171 |
+
ax.set_xlabel("Rank")
|
| 172 |
+
ax.set_ylabel("Robust Score")
|
| 173 |
+
plt.tight_layout()
|
| 174 |
+
|
| 175 |
+
# SHAP Global Summary
|
| 176 |
+
X_all = pd.concat([x for x, _ in shap_summary_data], axis=0)
|
| 177 |
+
shap_all = np.vstack([s for _, s in shap_summary_data])
|
| 178 |
+
|
| 179 |
+
fig_shap = plt.figure(figsize=(10, 6))
|
| 180 |
+
shap.summary_plot(
|
| 181 |
+
shap_all,
|
| 182 |
+
X_all,
|
| 183 |
+
feature_names=FEATURES,
|
| 184 |
+
show=False
|
| 185 |
+
)
|
| 186 |
+
plt.tight_layout()
|
| 187 |
+
|
| 188 |
+
summary = f"""
|
| 189 |
+
### Inference Complete
|
| 190 |
+
|
| 191 |
+
- **Inference Time:** {inference_time:.3f}s
|
| 192 |
+
- **Total Pairs:** {len(df):,}
|
| 193 |
+
- **Unique Configs:** {len(agg):,}
|
| 194 |
+
- **OOD / Clipped:** {df['was_clipped'].sum():,}
|
| 195 |
+
"""
|
| 196 |
+
|
| 197 |
+
return (
|
| 198 |
+
summary,
|
| 199 |
+
topk,
|
| 200 |
+
fig_rank,
|
| 201 |
+
fig_shap,
|
| 202 |
+
ranked_path,
|
| 203 |
+
topk_path
|
| 204 |
)
|
| 205 |
|
| 206 |
+
|
| 207 |
+
# =========================================================
|
| 208 |
+
# UI
|
| 209 |
+
# =========================================================
|
| 210 |
+
custom_css = """
|
| 211 |
+
.gradio-container {
|
| 212 |
+
max-width: 1400px !important;
|
| 213 |
+
margin: auto;
|
| 214 |
+
}
|
| 215 |
+
footer {display:none !important;}
|
| 216 |
+
"""
|
| 217 |
+
|
| 218 |
+
with gr.Blocks(
|
| 219 |
+
theme=gr.themes.Soft(
|
| 220 |
+
primary_hue="blue",
|
| 221 |
+
secondary_hue="indigo"
|
| 222 |
+
),
|
| 223 |
+
css=custom_css,
|
| 224 |
+
title="AIDE-Chip Cache Ranker"
|
| 225 |
+
) as demo:
|
| 226 |
+
|
| 227 |
+
gr.Markdown("""
|
| 228 |
+
# 🚀 AIDE-Chip Cache Configuration Ranker
|
| 229 |
+
### Surrogate Model Inference + SHAP Explainability
|
| 230 |
+
Upload workload/config CSV to rank optimal cache configurations.
|
| 231 |
+
""")
|
| 232 |
+
|
| 233 |
+
with gr.Row():
|
| 234 |
+
file_input = gr.File(
|
| 235 |
+
label="Upload Input CSV",
|
| 236 |
+
file_types=[".csv"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
)
|
| 238 |
|
| 239 |
+
run_btn = gr.Button("Run Inference", variant="primary", size="lg")
|
|
|
|
| 240 |
|
| 241 |
+
summary_md = gr.Markdown()
|
|
|
|
|
|
|
| 242 |
|
| 243 |
+
with gr.Tabs():
|
| 244 |
+
with gr.Tab("🏆 Top Configurations"):
|
| 245 |
+
topk_df = gr.Dataframe()
|
| 246 |
+
|
| 247 |
+
with gr.Tab("📈 Ranking Plot"):
|
| 248 |
+
rank_plot = gr.Plot()
|
| 249 |
+
|
| 250 |
+
with gr.Tab("🧠 SHAP Explainability"):
|
| 251 |
+
shap_plot = gr.Plot()
|
| 252 |
+
|
| 253 |
+
with gr.Tab("⬇ Downloads"):
|
| 254 |
+
ranked_csv = gr.File(label="Download Ranked CSV")
|
| 255 |
+
topk_csv = gr.File(label="Download Top-K CSV")
|
| 256 |
|
| 257 |
+
run_btn.click(
|
| 258 |
+
fn=run_inference,
|
| 259 |
+
inputs=file_input,
|
| 260 |
+
outputs=[
|
| 261 |
+
summary_md,
|
| 262 |
+
topk_df,
|
| 263 |
+
rank_plot,
|
| 264 |
+
shap_plot,
|
| 265 |
+
ranked_csv,
|
| 266 |
+
topk_csv
|
| 267 |
+
]
|
| 268 |
)
|
| 269 |
|
| 270 |
+
demo.launch()
|
|
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
|
| 2 |
numpy
|
| 3 |
-
|
| 4 |
xgboost
|
|
|
|
|
|
| 1 |
+
shap
|
| 2 |
numpy
|
| 3 |
+
pandas
|
| 4 |
xgboost
|
| 5 |
+
matplotlib
|
surrogate_models_v2_json/model_crc32_ipc.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_crc32_ipc_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": false
|
| 14 |
+
}
|
surrogate_models_v2_json/model_crc32_l2_miss_rate.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_crc32_l2_miss_rate_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": true
|
| 14 |
+
}
|
surrogate_models_v2_json/model_dijkstra_ipc.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_dijkstra_ipc_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": false
|
| 14 |
+
}
|
surrogate_models_v2_json/model_dijkstra_l2_miss_rate.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_dijkstra_l2_miss_rate_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": true
|
| 14 |
+
}
|
surrogate_models_v2_json/model_fft_ipc.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_fft_ipc_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": false
|
| 14 |
+
}
|
surrogate_models_v2_json/model_fft_l2_miss_rate.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_fft_l2_miss_rate_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": true
|
| 14 |
+
}
|
surrogate_models_v2_json/model_matrix_mul_ipc.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_matrix_mul_ipc_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": false
|
| 14 |
+
}
|
surrogate_models_v2_json/model_matrix_mul_l2_miss_rate.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_matrix_mul_l2_miss_rate_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": true
|
| 14 |
+
}
|
surrogate_models_v2_json/model_qsort_ipc.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_qsort_ipc_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": false
|
| 14 |
+
}
|
surrogate_models_v2_json/model_qsort_l2_miss_rate.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_qsort_l2_miss_rate_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": true
|
| 14 |
+
}
|
surrogate_models_v2_json/model_sha_ipc.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_sha_ipc_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": false
|
| 14 |
+
}
|
surrogate_models_v2_json/model_sha_l2_miss_rate.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
surrogate_models_v2_json/model_sha_l2_miss_rate_meta.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"features": [
|
| 3 |
+
"l1d_size_log2",
|
| 4 |
+
"l1i_size_log2",
|
| 5 |
+
"l2_size_log2",
|
| 6 |
+
"l1d_assoc_log2",
|
| 7 |
+
"l1i_assoc_log2",
|
| 8 |
+
"l2_assoc_log2",
|
| 9 |
+
"l2_l1d_ratio_log2",
|
| 10 |
+
"l1d_sets_log2",
|
| 11 |
+
"l2_sets_log2"
|
| 12 |
+
],
|
| 13 |
+
"log_target": true
|
| 14 |
+
}
|