Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -56,7 +56,9 @@ def update_explorer(dataset_name, split_name):
|
|
| 56 |
splits = df["split"].unique().tolist() if "split" in df.columns else ["all"]
|
| 57 |
|
| 58 |
filtered = df[df["split"] == split_name].head(10) if "split" in df.columns else df.head(10)
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
|
| 61 |
return gr.update(choices=splits), filtered, qasm_sample
|
| 62 |
|
|
@@ -84,6 +86,7 @@ def run_model_demo(dataset_name):
|
|
| 84 |
importances = model.feature_importances_
|
| 85 |
indices = np.argsort(importances)[-10:]
|
| 86 |
ax2.barh(range(10), importances[indices], color='#EF553B')
|
|
|
|
| 87 |
ax2.set_yticklabels([feature_cols[i] for i in indices])
|
| 88 |
ax2.set_title("Top 10 Features")
|
| 89 |
|
|
@@ -96,7 +99,7 @@ def run_model_demo(dataset_name):
|
|
| 96 |
|
| 97 |
def load_benchmark():
|
| 98 |
path = Path(LOCAL_BENCHMARK_CSV)
|
| 99 |
-
if not path.exists(): return None, None,
|
| 100 |
df = pd.read_csv(path)
|
| 101 |
fig_r2, ax = plt.subplots(figsize=(8, 4))
|
| 102 |
ax.bar(df["dataset"], df["r2"], color=['#636EFA', '#EF553B', '#00CC96', '#AB63FA'])
|
|
@@ -107,7 +110,7 @@ def load_benchmark():
|
|
| 107 |
# =========================================================
|
| 108 |
# INTERFACE
|
| 109 |
# =========================================================
|
| 110 |
-
with gr.Blocks(title="QSBench Unified Explorer"
|
| 111 |
gr.Markdown("# π QSBench: Quantum Synthetic Benchmark Explorer\n**Professional-grade datasets for Noise-Aware QML and Hardware Optimization.**")
|
| 112 |
|
| 113 |
with gr.Tabs():
|
|
@@ -117,12 +120,13 @@ with gr.Blocks(title="QSBench Unified Explorer", theme=gr.themes.Soft()) as demo
|
|
| 117 |
split_selector = gr.Dropdown(choices=["train", "test", "validation"], value="train", label="Split")
|
| 118 |
|
| 119 |
data_table = gr.Dataframe(interactive=False)
|
| 120 |
-
qasm_view = gr.Code(label="Circuit QASM Preview (First row of selection)", language="
|
| 121 |
|
| 122 |
ds_selector.change(update_explorer, [ds_selector, split_selector], [split_selector, data_table, qasm_view])
|
| 123 |
split_selector.change(update_explorer, [ds_selector, split_selector], [split_selector, data_table, qasm_view])
|
| 124 |
|
| 125 |
with gr.TabItem("π€ ML Baseline Demo"):
|
|
|
|
| 126 |
model_ds_selector = gr.Dropdown(choices=list(DATASET_MAP.keys()), value="Core (Clean)", label="Select Target Pack")
|
| 127 |
train_btn = gr.Button("Train Baseline Model", variant="primary")
|
| 128 |
plot_output = gr.Plot()
|
|
@@ -130,6 +134,7 @@ with gr.Blocks(title="QSBench Unified Explorer", theme=gr.themes.Soft()) as demo
|
|
| 130 |
train_btn.click(run_model_demo, [model_ds_selector], [plot_output, text_output])
|
| 131 |
|
| 132 |
with gr.TabItem("π Cross-Dataset Benchmark"):
|
|
|
|
| 133 |
bench_btn = gr.Button("Analyze Robustness Across All Packs")
|
| 134 |
bench_table = gr.Dataframe()
|
| 135 |
bench_plot = gr.Plot()
|
|
@@ -137,19 +142,15 @@ with gr.Blocks(title="QSBench Unified Explorer", theme=gr.themes.Soft()) as demo
|
|
| 137 |
|
| 138 |
gr.Markdown("""
|
| 139 |
---
|
| 140 |
-
### π¬
|
| 141 |
-
|
| 142 |
-
- **Demographic**: 8-10 Qubits, Depth 6-8.
|
| 143 |
-
- **Features**: Includes gate entropy, Meyer-Wallach entanglement, and transpilation metrics.
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
)
|
| 150 |
|
| 151 |
-
# Initial load
|
| 152 |
demo.load(update_explorer, [ds_selector, split_selector], [split_selector, data_table, qasm_view])
|
| 153 |
|
| 154 |
if __name__ == "__main__":
|
| 155 |
-
demo.launch()
|
|
|
|
| 56 |
splits = df["split"].unique().tolist() if "split" in df.columns else ["all"]
|
| 57 |
|
| 58 |
filtered = df[df["split"] == split_name].head(10) if "split" in df.columns else df.head(10)
|
| 59 |
+
|
| 60 |
+
qasm_col = "circuit_qasm" if "circuit_qasm" in df.columns else None
|
| 61 |
+
qasm_sample = filtered[qasm_col].iloc[0] if qasm_col and not filtered.empty else "// QASM not available in this pack"
|
| 62 |
|
| 63 |
return gr.update(choices=splits), filtered, qasm_sample
|
| 64 |
|
|
|
|
| 86 |
importances = model.feature_importances_
|
| 87 |
indices = np.argsort(importances)[-10:]
|
| 88 |
ax2.barh(range(10), importances[indices], color='#EF553B')
|
| 89 |
+
ax2.set_yticks(range(10))
|
| 90 |
ax2.set_yticklabels([feature_cols[i] for i in indices])
|
| 91 |
ax2.set_title("Top 10 Features")
|
| 92 |
|
|
|
|
| 99 |
|
| 100 |
def load_benchmark():
|
| 101 |
path = Path(LOCAL_BENCHMARK_CSV)
|
| 102 |
+
if not path.exists(): return None, None, "File noise_benchmark_results.csv not found."
|
| 103 |
df = pd.read_csv(path)
|
| 104 |
fig_r2, ax = plt.subplots(figsize=(8, 4))
|
| 105 |
ax.bar(df["dataset"], df["r2"], color=['#636EFA', '#EF553B', '#00CC96', '#AB63FA'])
|
|
|
|
| 110 |
# =========================================================
|
| 111 |
# INTERFACE
|
| 112 |
# =========================================================
|
| 113 |
+
with gr.Blocks(title="QSBench Unified Explorer") as demo:
|
| 114 |
gr.Markdown("# π QSBench: Quantum Synthetic Benchmark Explorer\n**Professional-grade datasets for Noise-Aware QML and Hardware Optimization.**")
|
| 115 |
|
| 116 |
with gr.Tabs():
|
|
|
|
| 120 |
split_selector = gr.Dropdown(choices=["train", "test", "validation"], value="train", label="Split")
|
| 121 |
|
| 122 |
data_table = gr.Dataframe(interactive=False)
|
| 123 |
+
qasm_view = gr.Code(label="Circuit QASM Preview (First row of selection)", language="python")
|
| 124 |
|
| 125 |
ds_selector.change(update_explorer, [ds_selector, split_selector], [split_selector, data_table, qasm_view])
|
| 126 |
split_selector.change(update_explorer, [ds_selector, split_selector], [split_selector, data_table, qasm_view])
|
| 127 |
|
| 128 |
with gr.TabItem("π€ ML Baseline Demo"):
|
| 129 |
+
gr.Markdown("Train a Random Forest regressor to evaluate how well structural circuit features predict expectation values.")
|
| 130 |
model_ds_selector = gr.Dropdown(choices=list(DATASET_MAP.keys()), value="Core (Clean)", label="Select Target Pack")
|
| 131 |
train_btn = gr.Button("Train Baseline Model", variant="primary")
|
| 132 |
plot_output = gr.Plot()
|
|
|
|
| 134 |
train_btn.click(run_model_demo, [model_ds_selector], [plot_output, text_output])
|
| 135 |
|
| 136 |
with gr.TabItem("π Cross-Dataset Benchmark"):
|
| 137 |
+
gr.Markdown("Comparison of model performance across different noise environments and hardware transpilation stages.")
|
| 138 |
bench_btn = gr.Button("Analyze Robustness Across All Packs")
|
| 139 |
bench_table = gr.Dataframe()
|
| 140 |
bench_plot = gr.Plot()
|
|
|
|
| 142 |
|
| 143 |
gr.Markdown("""
|
| 144 |
---
|
| 145 |
+
### π¬ Research Resources
|
| 146 |
+
This interface provides a structural overview of the QSBench dataset family. These datasets are designed to support reproducible research in quantum error mitigation and machine learning.
|
|
|
|
|
|
|
| 147 |
|
| 148 |
+
- **GitHub**: [QSBench/QSBench-Demo](https://github.com/QSBench/QSBench-Demo)
|
| 149 |
+
- **Website**: [qsbench.github.io](https://qsbench.github.io)
|
| 150 |
+
- **Hugging Face**: [Explore all datasets](https://huggingface.co/QSBench)
|
| 151 |
+
""")
|
|
|
|
| 152 |
|
|
|
|
| 153 |
demo.load(update_explorer, [ds_selector, split_selector], [split_selector, data_table, qasm_view])
|
| 154 |
|
| 155 |
if __name__ == "__main__":
|
| 156 |
+
demo.launch(theme=gr.themes.Soft())
|