-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
142 lines (117 loc) · 3.67 KB
/
Copy pathMakefile
File metadata and controls
142 lines (117 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# swarmtorch — benchmark and dev workflow
#
# Don't have make on Windows? Every target is a one-line python invocation.
# Open the recipe and copy-paste it; or install make via scoop / chocolatey /
# MSYS2. The scripts in scripts/ are self-contained and work without make.
#
# Targets:
#
# make test Run the full pytest suite.
# make lint Run ruff lint + format check.
# make install-bench Install the benchmark dependencies.
#
# make bench-synthetic Stage 4.1 — synthetic CEC-style suite.
# make bench-training-quick Stage 4.2 — training, synthetic data only.
# make bench-training Stage 4.2 — full training, downloads MNIST/CIFAR.
# make bench-hpo Stage 4.3 — HPO comparison.
# make ablation-init Stage 4.4 — init-strategy ablation.
# make ablation-swarm Stage 4.4 — swarm-size ablation.
#
# make report DIR=results/synthetic
# Re-aggregate JSONs in DIR into report.md.
#
# make clean-results Wipe ./results/.
# make clean Wipe results, build artefacts, caches.
#
# All bench-* targets accept overrides on the CLI:
# make bench-synthetic SEEDS="0 1 2" MAX_FE=2000 DIMS="10 50"
PYTHON ?= python
RESULTS ?= results
SEEDS ?= 0 1 2 3 4
MAX_FE ?= 5000
DIMS ?= 10 50 200
SWARM_SIZE ?= 30
# --- Dev -----------------------------------------------------------------
.PHONY: test
test:
$(PYTHON) -m pytest tests/ -q
.PHONY: lint
lint:
$(PYTHON) -m ruff check .
$(PYTHON) -m ruff format --check .
.PHONY: format
format:
$(PYTHON) -m ruff format .
$(PYTHON) -m ruff check --fix .
.PHONY: install-bench
install-bench:
$(PYTHON) -m pip install -e ".[benchmark]"
# --- Stage 4 sweeps ------------------------------------------------------
.PHONY: bench-synthetic
bench-synthetic:
$(PYTHON) scripts/run_synthetic.py \
--output-dir $(RESULTS)/synthetic \
--seeds $(SEEDS) \
--max-fe $(MAX_FE) \
--swarm-size $(SWARM_SIZE) \
--dims $(DIMS)
.PHONY: bench-training-quick
bench-training-quick:
$(PYTHON) scripts/run_training.py \
--output-dir $(RESULTS)/training_quick \
--seeds $(SEEDS) \
--max-fe $(MAX_FE) \
--swarm-size $(SWARM_SIZE) \
--quick
.PHONY: bench-training
bench-training:
$(PYTHON) scripts/run_training.py \
--output-dir $(RESULTS)/training \
--seeds $(SEEDS) \
--max-fe $(MAX_FE) \
--swarm-size $(SWARM_SIZE)
.PHONY: bench-hpo
bench-hpo:
$(PYTHON) scripts/run_hpo.py \
--output-dir $(RESULTS)/hpo \
--seeds $(SEEDS) \
--n-trials 20
.PHONY: ablation-init
ablation-init:
$(PYTHON) scripts/run_ablations.py \
--ablation init_strategy \
--output-dir $(RESULTS)/ablations/init \
--seeds $(SEEDS) \
--max-fe $(MAX_FE) \
--algorithms PSO CA TLBO CMAES
.PHONY: ablation-swarm
ablation-swarm:
$(PYTHON) scripts/run_ablations.py \
--ablation swarm_size \
--output-dir $(RESULTS)/ablations/swarm \
--seeds $(SEEDS) \
--max-fe $(MAX_FE) \
--algorithms PSO CMAES
.PHONY: bench-gpu
bench-gpu:
$(PYTHON) scripts/run_gpu_vs_numpy.py \
--output-dir $(RESULTS)/gpu_vs_numpy \
--seeds $(SEEDS) \
--max-fe $(MAX_FE)
.PHONY: bench-gpu-quick
bench-gpu-quick:
$(PYTHON) scripts/run_gpu_vs_numpy.py --quick \
--output-dir $(RESULTS)/gpu_quick
# --- Reporting -----------------------------------------------------------
DIR ?= $(RESULTS)/synthetic
.PHONY: report
report:
$(PYTHON) -m swarmtorch.summarize_results $(DIR)
# --- Cleanup -------------------------------------------------------------
.PHONY: clean-results
clean-results:
rm -rf $(RESULTS)
.PHONY: clean
clean: clean-results
rm -rf build dist *.egg-info .pytest_cache .ruff_cache __pycache__
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true