Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
# The test suite exercises the benchmark harness (plots, stats, HPO
# baselines, CMA-ES), so the benchmark extra is required for collection
# to succeed — conftest.py imports matplotlib.
pip install -e .[dev,benchmark]

- name: Lint with Ruff
run: ruff check .
Expand Down
31 changes: 27 additions & 4 deletions notebooks/gpu_vs_numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "7fb27b941602401d91542211134fc71a",
"metadata": {},
"source": [
"# `swarmtorch` GPU vs NumPy headline benchmark\n",
Expand All @@ -27,6 +28,7 @@
},
{
"cell_type": "markdown",
"id": "acae54e37e7d407bbb7b55eff062a284",
"metadata": {},
"source": [
"## 1. Install"
Expand All @@ -35,12 +37,15 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9a63283cbaf04dbcab1f6479b197f3a8",
"metadata": {},
"outputs": [],
"source": [
"# Clone the repo and install with benchmark + cmaes extras.\n",
"# Skip the clone step if you've already uploaded the repo to your Colab/Kaggle session.\n",
"import os, sys, subprocess\n",
"import os\n",
"import sys\n",
"import subprocess\n",
"\n",
"if not os.path.isdir('swarmtorch'):\n",
" subprocess.check_call(['git', 'clone', 'https://github.com/hallelx2/swarmtorch.git'])\n",
Expand All @@ -58,6 +63,7 @@
},
{
"cell_type": "markdown",
"id": "8dd0d8092fe74a7c96281538738b07e2",
"metadata": {},
"source": [
"## 2. Quick smoke run\n",
Expand All @@ -68,6 +74,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "72eea5119410473aa328ad9291626812",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -76,6 +83,7 @@
},
{
"cell_type": "markdown",
"id": "8edb47106e1a46a883d545849b8ab81b",
"metadata": {},
"source": [
"## 3. Headline benchmark grid\n",
Expand All @@ -88,6 +96,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "10185d26023b46108eb7d9f57d49d2b3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,6 +111,7 @@
},
{
"cell_type": "markdown",
"id": "8763a12b2bbd4a93a75aff182afb95dc",
"metadata": {},
"source": [
"## 4. View the speedup report"
Expand All @@ -110,6 +120,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7623eae2785240b9bd12b16a66d81610",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -119,6 +130,7 @@
},
{
"cell_type": "markdown",
"id": "7cdc8c89c7104fffa095e18ddfef8986",
"metadata": {},
"source": [
"## 5. Plot the speedup curve\n",
Expand All @@ -130,10 +142,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b118ea5561624da68c537baed56e602f",
"metadata": {},
"outputs": [],
"source": [
"import json, glob\n",
"import json\n",
"import glob\n",
"from collections import defaultdict\n",
"import matplotlib.pyplot as plt\n",
"\n",
Expand Down Expand Up @@ -174,6 +188,7 @@
},
{
"cell_type": "markdown",
"id": "938c804e27f84196a10c8828c723f798",
"metadata": {},
"source": [
"## 6. (Optional) Download results\n",
Expand All @@ -184,6 +199,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "504fb2a444614c0babb325280ed9130a",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -200,8 +216,15 @@
}
],
"metadata": {
"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"},
"language_info": {"name": "python", "version": "3.10"}
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
Expand Down
48 changes: 42 additions & 6 deletions notebooks/kaggle_full_benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "7fb27b941602401d91542211134fc71a",
"metadata": {},
"source": [
"# `swarmtorch` — full standardised benchmark suite (Kaggle GPU)\n",
Expand Down Expand Up @@ -48,6 +49,7 @@
},
{
"cell_type": "markdown",
"id": "acae54e37e7d407bbb7b55eff062a284",
"metadata": {},
"source": [
"## 1. Clone + install + identify the machine\n",
Expand All @@ -59,10 +61,13 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9a63283cbaf04dbcab1f6479b197f3a8",
"metadata": {},
"outputs": [],
"source": [
"import os, sys, subprocess\n",
"import os\n",
"import sys\n",
"import subprocess\n",
"\n",
"REPO_URL = 'https://github.com/hallelx2/swarmtorch.git'\n",
"if not os.path.isdir('swarmtorch'):\n",
Expand All @@ -79,6 +84,7 @@
},
{
"cell_type": "markdown",
"id": "8dd0d8092fe74a7c96281538738b07e2",
"metadata": {},
"source": [
"## 2. Smoke test (~1 minute)\n",
Expand All @@ -90,6 +96,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "72eea5119410473aa328ad9291626812",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -98,6 +105,7 @@
},
{
"cell_type": "markdown",
"id": "8edb47106e1a46a883d545849b8ab81b",
"metadata": {},
"source": [
"## 3. Helper — preview a `report.md` inline\n",
Expand All @@ -109,6 +117,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "10185d26023b46108eb7d9f57d49d2b3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -131,6 +140,7 @@
},
{
"cell_type": "markdown",
"id": "8763a12b2bbd4a93a75aff182afb95dc",
"metadata": {},
"source": [
"## 4. Stage 4.4 — Init-strategy ablation (~15 min)\n",
Expand All @@ -146,6 +156,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7623eae2785240b9bd12b16a66d81610",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -161,6 +172,7 @@
},
{
"cell_type": "markdown",
"id": "7cdc8c89c7104fffa095e18ddfef8986",
"metadata": {},
"source": [
"## 5. Stage 4.4 — Swarm-size ablation (~20 min)\n",
Expand All @@ -173,6 +185,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b118ea5561624da68c537baed56e602f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -188,6 +201,7 @@
},
{
"cell_type": "markdown",
"id": "938c804e27f84196a10c8828c723f798",
"metadata": {},
"source": [
"## 6. Stage 4.3 — HPO comparison (~30 min)\n",
Expand All @@ -200,6 +214,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "504fb2a444614c0babb325280ed9130a",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -213,6 +228,7 @@
},
{
"cell_type": "markdown",
"id": "59bbdb311c014d738909a11f9e486628",
"metadata": {},
"source": [
"## 7. Stage 6 — GPU vs NumPy headline (~30 min) ⭐\n",
Expand All @@ -228,6 +244,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b43b363d81ae4b689946ece5c682cd59",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -244,6 +261,7 @@
},
{
"cell_type": "markdown",
"id": "8a65eabff63a45729fe45fb5ade58bdc",
"metadata": {},
"source": [
"### 7b. Speedup plot — the figure that goes in the paper"
Expand All @@ -252,10 +270,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c3933fab20d04ec698c2621248eb3be0",
"metadata": {},
"outputs": [],
"source": [
"import json, glob\n",
"import json\n",
"import glob\n",
"from collections import defaultdict\n",
"import matplotlib.pyplot as plt\n",
"\n",
Expand Down Expand Up @@ -288,6 +308,7 @@
},
{
"cell_type": "markdown",
"id": "4dd4641cc4064e0191573fe9c69df29b",
"metadata": {},
"source": [
"## 8. Stage 4.1 — Synthetic dimensionality-wall study (~1.5 hours)\n",
Expand All @@ -304,6 +325,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8309879909854d7188b41380fd92a7c3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -319,6 +341,7 @@
},
{
"cell_type": "markdown",
"id": "3ed186c9a28b402fb0bc4494df01f08d",
"metadata": {},
"source": [
"## 9. Stage 4.2 — Real NN training (~2–3 hours)\n",
Expand All @@ -334,10 +357,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cb1e1581032b452c9409d6c6813c49d1",
"metadata": {},
"outputs": [],
"source": [
"import subprocess, sys\n",
"import subprocess\n",
"import sys\n",
"# torchvision is preinstalled on Kaggle; if not, install it.\n",
"try:\n",
" import torchvision # noqa: F401\n",
Expand All @@ -355,6 +380,7 @@
},
{
"cell_type": "markdown",
"id": "379cbbc1e968416e875cc15c1202d7eb",
"metadata": {},
"source": [
"## 10. Bundle everything for download\n",
Expand All @@ -367,10 +393,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "277c27b1587741f2af2001be3712ef0d",
"metadata": {},
"outputs": [],
"source": [
"import shutil, time\n",
"import shutil\n",
"import time\n",
"stamp = time.strftime('%Y%m%d_%H%M')\n",
"out = f'/kaggle/working/swarmtorch_results_{stamp}'\n",
"shutil.make_archive(out, 'zip', root_dir='.', base_dir='results')\n",
Expand All @@ -386,6 +414,7 @@
},
{
"cell_type": "markdown",
"id": "db7b79bc585a40fcaf58bf750017e135",
"metadata": {},
"source": [
"---\n",
Expand All @@ -407,8 +436,15 @@
}
],
"metadata": {
"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"},
"language_info": {"name": "python", "version": "3.10"}
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ include = ["swarmtorch*"]
[tool.ruff]
line-length = 88
target-version = "py310"
# Notebooks are demo/cell code (compact one-liners, post-install imports);
# they are not part of the importable library surface, so we don't lint them.
extend-exclude = ["notebooks", "paper", "results"]

[tool.ruff.lint]
# E731 (lambda assignment) and E70x (compound one-liners) are deliberate,
# readable choices in the benchmark/experiment scripts where a closure or a
# tight timing block reads better on one line. They are stylistic, not bugs.
ignore = ["E731", "E701", "E702"]

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down
Loading
Loading