-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (97 loc) · 4.94 KB
/
Copy pathMakefile
File metadata and controls
128 lines (97 loc) · 4.94 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
.PHONY: setup setup-lean setup-all download-data extract train-sft train-expert-iter train-dapo eval export test lint format clean
CONFIG ?= configs/sft_qwen35_2b.yaml
WORKERS ?= 4
LEAN_VERSION ?= v4.28.0
MATHLIB_VERSION ?= v4.28.0
ELAN_BIN = $(HOME)/.elan/bin
LEAN_DIR = lean
PANTOGRAPH_DIR = vendor/Pantograph
# ── Full pipeline (one command on a fresh instance) ──────────────────
all: setup get-data train-sft
@echo "Pipeline complete. Run 'make eval' to benchmark."
# Full pipeline with Lean (for re-extraction or expert iteration)
all-lean: setup-all download-data extract train-sft
@echo "Pipeline complete. Run 'make eval' to benchmark."
# ── Setup ────────────────────────────────────────────────────────────
setup:
pip install -e ".[dev]"
pre-commit install || true
setup-lean: setup-lean-toolchain setup-lean-mathlib setup-lean-pantograph
@echo "=== Lean + Pantograph setup complete ==="
setup-lean-toolchain:
@echo "=== Installing elan (Lean toolchain manager) ==="
@if [ ! -f $(ELAN_BIN)/lean ]; then \
curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain leanprover/lean4:$(LEAN_VERSION); \
else \
echo " elan already installed"; \
fi
setup-lean-mathlib:
@echo "=== Setting up Lean project with Mathlib ==="
bash scripts/setup_lean_project.sh $(LEAN_VERSION) $(MATHLIB_VERSION) $(LEAN_DIR)
cd $(LEAN_DIR) && $(ELAN_BIN)/lake update
@echo "=== Downloading Mathlib cache ==="
cd $(LEAN_DIR) && $(ELAN_BIN)/lake exe cache get || ( \
echo " Cache failed, fixing ProofWidgets manually..." && \
curl -sL -o /tmp/pw.tar.gz https://github.com/leanprover-community/ProofWidgets4/releases/download/v0.0.87/ProofWidgets4.tar.gz && \
mkdir -p .lake/packages/proofwidgets/.lake/build && \
tar --no-same-owner -xzf /tmp/pw.tar.gz -C .lake/packages/proofwidgets/.lake/build && \
$(ELAN_BIN)/lake exe cache get \
)
setup-lean-pantograph:
@echo "=== Building Pantograph for Lean $(LEAN_VERSION) ==="
@# Clean slate: remove any previous build
rm -rf $(PANTOGRAPH_DIR)
git clone --depth 1 --branch dev https://github.com/leanprover/Pantograph.git $(PANTOGRAPH_DIR)
@# Apply 4.28 compatibility: override Library.lean and set toolchain
cp scripts/pantograph-overrides/Library.lean $(PANTOGRAPH_DIR)/Pantograph/Library.lean
echo "leanprover/lean4:$(LEAN_VERSION)" > $(PANTOGRAPH_DIR)/lean-toolchain
cd $(PANTOGRAPH_DIR) && $(ELAN_BIN)/lake update && $(ELAN_BIN)/lake build repl
@echo " Pantograph REPL built at $(PANTOGRAPH_DIR)/.lake/build/bin/repl"
setup-all: setup setup-lean
# ── Data ─────────────────────────────────────────────────────────────
get-data:
python scripts/download_processed.py
download-data:
bash scripts/download_data.sh
extract:
python scripts/extract_tactics.py \
--input data/raw \
--output data/processed/train.jsonl \
--val-output data/processed/val.jsonl \
--val-split 0.05 \
--pantograph $(PANTOGRAPH_DIR)/.lake/build/bin/repl \
--lean-project $(LEAN_DIR) \
--workers $(WORKERS)
extract-fast:
python scripts/extract_tactics.py \
--input data/raw \
--output data/processed/train.jsonl \
--val-output data/processed/val.jsonl \
--val-split 0.05 \
--skip-phase2
# ── Training ─────────────────────────────────────────────────────────
NUM_GPUS := $(shell nvidia-smi -L 2>/dev/null | wc -l || echo 1)
train-sft:
torchrun --nproc_per_node=$(NUM_GPUS) --master_port=29500 scripts/run_sft.py --config $(CONFIG)
train-expert-iter:
python -m openproof_ml.training.expert_iteration --config $(CONFIG)
train-dapo:
python -m openproof_ml.training.dapo --config $(CONFIG)
# ── Evaluation ───────────────────────────────────────────────────────
eval:
python -m openproof_ml.eval.minif2f --config $(CONFIG)
# ── Export ────────────────────────────────────────────────────────────
export:
python scripts/export_gguf.py --config $(CONFIG)
# ── Dev ──────────────────────────────────────────────────────────────
test:
python -m pytest tests/ -v
lint:
ruff check src/ scripts/ tests/
ruff format --check src/ scripts/ tests/
format:
ruff check --fix src/ scripts/ tests/
ruff format src/ scripts/ tests/
clean:
rm -rf checkpoints/ outputs/ wandb/ __pycache__
find . -type d -name __pycache__ -exec rm -rf {} +