-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
162 lines (134 loc) · 5.62 KB
/
Makefile
File metadata and controls
162 lines (134 loc) · 5.62 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# =============================================================================
# Makefile — SpectralQuant project automation
#
# Usage:
# make setup Complete B200 setup (run once)
# make test Run the full pytest test suite
# make test-quick Run tests with reduced verbosity
# make lint Check code style (ruff + black)
# make format Auto-format code (black + ruff --fix)
# make typecheck Run mypy type checks
# make experiments Run all experiments
# make paper Compile the paper
# make clean Remove generated files (keeps results structure)
# make clean-all Remove everything including results/
# =============================================================================
.PHONY: setup test test-quick lint format typecheck experiments paper \
clean clean-all help
PYTHON := python
PYTEST := python -m pytest
RUFF := ruff
BLACK := black
MYPY := mypy
PYTHONPATH := src
# Default target
all: help
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
setup:
@echo "=== Running B200 setup script ==="
bash scripts/setup_b200.sh
# ---------------------------------------------------------------------------
# Testing
# ---------------------------------------------------------------------------
test:
@echo "=== Running test suite ==="
PYTHONPATH=$(PYTHONPATH) $(PYTEST) tests/ -v
test-quick:
@echo "=== Running test suite (brief output) ==="
PYTHONPATH=$(PYTHONPATH) $(PYTEST) tests/ -q
test-cov:
@echo "=== Running test suite with coverage ==="
PYTHONPATH=$(PYTHONPATH) $(PYTEST) tests/ -v \
--cov=spectralquant \
--cov-report=term-missing \
--cov-report=html:htmlcov/
# ---------------------------------------------------------------------------
# Code quality
# ---------------------------------------------------------------------------
lint:
@echo "=== Running ruff ==="
$(RUFF) check src/ experiments/ tests/ scripts/
@echo "=== Checking black formatting ==="
$(BLACK) --check src/ experiments/ tests/
format:
@echo "=== Formatting with black ==="
$(BLACK) src/ experiments/ tests/
@echo "=== Fixing with ruff ==="
$(RUFF) check --fix src/ experiments/ tests/
typecheck:
@echo "=== Running mypy ==="
$(MYPY) src/spectralquant/
# ---------------------------------------------------------------------------
# Experiments
# ---------------------------------------------------------------------------
experiments:
@echo "=== Running all experiments ==="
bash scripts/run_all.sh
experiments-quick:
@echo "=== Running quick experiment run (debug config) ==="
bash scripts/run_all.sh --quick
phase1:
@echo "=== Running Phase 1: Eigenspectral analysis ==="
PYTHONPATH=$(PYTHONPATH) $(PYTHON) experiments/phase1_eigenspectral.py
phase2:
@echo "=== Running Phase 2: SpectralQuant integration ==="
PYTHONPATH=$(PYTHONPATH) $(PYTHON) experiments/phase2_integration.py
exp1:
@echo "=== Running Experiment 1: Attention quality ==="
PYTHONPATH=$(PYTHONPATH) $(PYTHON) experiments/phase3_exp1_attention_quality.py
exp2:
@echo "=== Running Experiment 2: Ablation ==="
PYTHONPATH=$(PYTHONPATH) $(PYTHON) experiments/phase3_exp2_ablation.py
# ---------------------------------------------------------------------------
# Paper
# ---------------------------------------------------------------------------
paper:
@echo "=== Compiling paper ==="
cd paper_output && $(PYTHON) generate_paper.py
# ---------------------------------------------------------------------------
# Cleaning
# ---------------------------------------------------------------------------
clean:
@echo "=== Cleaning generated files (preserving results structure) ==="
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "htmlcov" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name ".coverage" -delete 2>/dev/null || true
rm -rf dist/ build/
@echo "Clean complete."
clean-results:
@echo "=== Cleaning results (plots, CSVs, JSONs) ==="
find results/ -name "*.png" -delete 2>/dev/null || true
find results/ -name "*.csv" -delete 2>/dev/null || true
find results/ -name "*.json" -delete 2>/dev/null || true
find results/ -name "*.npz" -delete 2>/dev/null || true
find results/ -name "*.npy" -delete 2>/dev/null || true
@echo "Results cleaned."
clean-all: clean clean-results
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
help:
@echo ""
@echo "SpectralQuant Makefile"
@echo "======================"
@echo ""
@echo " make setup Complete B200 setup (run once)"
@echo " make test Run full pytest test suite"
@echo " make test-quick Run tests with brief output"
@echo " make test-cov Run tests with coverage report"
@echo " make lint Check code style (ruff + black)"
@echo " make format Auto-format code in place"
@echo " make typecheck Run mypy type checks"
@echo " make experiments Run all experiments (default config)"
@echo " make experiments-quick Run with quick.yaml config"
@echo " make phase1 Run Phase 1 only"
@echo " make paper Compile the paper"
@echo " make clean Remove __pycache__, .pyc, etc."
@echo " make clean-results Remove all result files"
@echo " make clean-all clean + clean-results"
@echo ""