-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (75 loc) · 2.81 KB
/
Makefile
File metadata and controls
83 lines (75 loc) · 2.81 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
# Auto-discover compilable examples (those defining create_network_parts)
COMPILABLE := $(shell grep -rl 'def create_network_parts' examples/*.py \
| sed 's|examples/||; s|\.py||')
ONNX_FILES := $(addsuffix .onnx, $(COMPILABLE))
.PHONY: compile
compile: $(ONNX_FILES)
%.onnx: examples/%.py examples/compile.py torchwright/compiler/*.py torchwright/graph/*.py
uv run python -m examples.compile $*
.PHONY: lint
lint:
uv run black --check .
uv run mypy .
.PHONY: test
test:
@bash -c ' \
LOGFILE=/tmp/torchwright-test-$$(date +%Y%m%d-%H%M%S).log ; \
ln -sfn "$$LOGFILE" /tmp/torchwright-test.log ; \
echo "=== Log file: $$LOGFILE ===" | tee "$$LOGFILE" ; \
echo "=== Running tests on Modal ===" | tee -a "$$LOGFILE" ; \
echo "=== Monitor: make test-logs ===" | tee -a "$$LOGFILE" ; \
start=$$(date +%s) ; \
uv run modal run modal_test.py \
--file $(if $(FILE),$(FILE),tests) \
$(if $(ARGS),--args "$(ARGS)") \
2>&1 | tee -a "$$LOGFILE" ; \
rc=$${PIPESTATUS[0]} ; \
end=$$(date +%s) ; \
echo "" | tee -a "$$LOGFILE" ; \
echo "=== Tests finished in $$((end - start))s (exit $$rc) ===" | tee -a "$$LOGFILE" ; \
echo "=== Log file: $$LOGFILE ===" | tee -a "$$LOGFILE" ; \
exit $$rc \
'
.PHONY: test-logs
test-logs:
@tail -f /tmp/torchwright-test.log
.PHONY: test-local
test-local:
@if [ -z "$(FILE)" ]; then \
echo "Error: FILE=<path> is required for test-local." >&2 ; \
echo " test-local runs pytest on the local machine and must target" >&2 ; \
echo " a single file to avoid accidentally running the whole suite" >&2 ; \
echo " (which belongs on Modal via 'make test')." >&2 ; \
echo "Example: make test-local FILE=tests/graph/test_embedding.py" >&2 ; \
exit 2 ; \
fi
uv run pytest $(FILE) $(ARGS)
.PHONY: measure-noise
measure-noise:
uv run python -m scripts.measure_op_noise $(ARGS)
.PHONY: modal-run
modal-run:
@if [ -z "$(MODULE)$(SCRIPT)" ]; then \
echo "Error: MODULE=<dotted.name> or SCRIPT=<path> required." >&2 ; \
echo "Example: make modal-run MODULE=scripts.investigate_phase_e" >&2 ; \
exit 2 ; \
fi
@bash -c ' \
LOGFILE=/tmp/torchwright-modal-run-$$(date +%Y%m%d-%H%M%S).log ; \
ln -sfn "$$LOGFILE" /tmp/torchwright-modal-run.log ; \
echo "=== Log file: $$LOGFILE ===" | tee "$$LOGFILE" ; \
echo "=== Running on Modal ===" | tee -a "$$LOGFILE" ; \
start=$$(date +%s) ; \
uv run modal run modal_run.py \
$(if $(MODULE),--module $(MODULE)) \
$(if $(SCRIPT),--script $(SCRIPT)) \
$(if $(ARGS),--args "$(ARGS)") \
$(if $(CPU_ONLY),--cpu-only) \
2>&1 | tee -a "$$LOGFILE" ; \
rc=$${PIPESTATUS[0]} ; \
end=$$(date +%s) ; \
echo "" | tee -a "$$LOGFILE" ; \
echo "=== Finished in $$((end - start))s (exit $$rc) ===" | tee -a "$$LOGFILE" ; \
echo "=== Log file: $$LOGFILE ===" | tee -a "$$LOGFILE" ; \
exit $$rc \
'