-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
170 lines (127 loc) · 7.01 KB
/
Copy pathjustfile
File metadata and controls
170 lines (127 loc) · 7.01 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
163
164
165
166
167
168
169
170
# mainarch. `just` with no args lists every task.
default:
@just --list
# ─── start here ────────────────────────────────────────────────────────────────
# THE one command: build, prove the stack on this machine, serve the demo page.
demo:
@bash scripts/demo.sh
# A guided CPU-only tour of what the stack is made of. No GPU required.
tour:
@bash scripts/tour.sh
# ─── the real model ────────────────────────────────────────────────────────────
# Fetch allenai/OLMo-2-0425-1B. ~6 GB, fully open weights, data and training code.
olmo-fetch dir='./olmo-2-1b':
@bash scripts/olmo_fetch.sh {{dir}}
# Generate with the real model on the raw KFD/AQL path. Needs an AMD GPU.
olmo prompt='The capital of France is' dir='./olmo-2-1b': build
./target/release/mainarch olmo2-generate \
--config {{dir}}/config.json \
--index {{dir}}/model.safetensors.index.json \
--tokenizer {{dir}}/tokenizer.json \
--prompt "{{prompt}}" --max-new 32
# Serve the real model over /v1/chat/completions.
olmo-serve dir='./olmo-2-1b' bind='127.0.0.1:8080': build
./target/release/mainarch demo-serve --bind {{bind}} \
--olmo-config {{dir}}/config.json \
--olmo-index {{dir}}/model.safetensors.index.json \
--olmo-tokenizer {{dir}}/tokenizer.json
# CPU-only: does this checkpoint satisfy the contract this runtime implements?
olmo-preflight dir='./olmo-2-1b': build
./target/release/mainarch olmo2-preflight \
--config {{dir}}/config.json \
--index {{dir}}/model.safetensors.index.json
# The four OLMo gates, on hardware.
olmo-gates node='2': build
./target/release/mainarch olmo2-preflight-selftest
./target/release/mainarch gpu-mha-attention-equivalence-selftest --node {{node}}
./target/release/mainarch gpu-olmo2-qk-rope-selftest --node {{node}}
./target/release/mainarch gpu-olmo2-post-norm-selftest --node {{node}}
# ─── inner loop ────────────────────────────────────────────────────────────────
# fast type-check across the workspace
check:
cargo check --workspace --all-targets
# clippy at CI grade
lint:
cargo clippy --workspace --all-targets -- -D warnings
fmt:
cargo fmt --all
# fast test runner (falls back to plain cargo test if nextest is absent)
test:
cargo nextest run --workspace || cargo test --workspace
# re-check on every save, leave this running while you work
watch:
cargo watch -x 'check --workspace --all-targets'
# build the release CLI
build:
cargo build --release -p mainarch-cli
# ─── CPU-only gates (these are what CI runs; no GPU needed) ────────────────────
# the public model-API contract gate
check-model-api:
python3 tools/check_model_api_public_examples.py
python3 tools/check_model_api_boundary_helpers.py --self-test
python3 tools/check_model_api_boundary_helpers.py
# the demo sandbox contract gate (starts the GPU-free server, asserts the seam)
check-demo:
python3 tools/check_demo_sandbox_static.py
# "no ROCm/HIP/HSA/CUDA/PyTorch in a production path" is a policy, so it is a test
check-policy:
python3 tools/check_runtime_dependency_policy.py --self-test
python3 tools/check_runtime_dependency_policy.py
python3 tools/check_crate_publish_policy.py --self-test
python3 tools/check_crate_publish_policy.py
# the OLMo 2 checkpoint contract, no GPU and no checkpoint needed
check-olmo: build
./target/release/mainarch olmo2-preflight-selftest
# everything CI runs, in one go
ci: check-policy fmt-check check test check-model-api check-demo check-olmo
fmt-check:
cargo fmt --all -- --check
# ─── hardware lane (needs an AMD GPU on /dev/kfd) ──────────────────────────────
# open /dev/kfd, read the amdkfd version, enumerate GPU nodes
probe: build
./target/release/mainarch probe
# prove live kernel execution: hand-built AQL packet + doorbell, no ROCm
gpu-selftest: build
./target/release/mainarch gpu-selftest
# 8-GPU all-reduce, bit-exact against a CPU oracle
gpu-multi-check: build
./target/release/mainarch gpu-multi-check
# busbw sweep in the rccl-tests table shape
gpu-allreduce-bench: build
./target/release/mainarch gpu-allreduce-bench
# FlashDecoding attention: correctness + FP16/FP8/FP4/GQA/paged sweep
attn-decode node='2': build
./target/release/mainarch attn-decode --node {{node}}
# decode-layer primitives: RMSNorm, RoPE, SwiGLU, KV quantization
decode-layer node='2': build
./target/release/mainarch decode-layer --node {{node}}
# the assembled multi-layer decode model, validated against an f64 reference
model-decode node='2': build
./target/release/mainarch model-decode --node {{node}}
# rccl-tests-style all-reduce sweep (add --backend gpu on hardware)
rccl-test *ARGS: build
./target/release/mainarch rccl-test all-reduce {{ARGS}}
# ─── containers ────────────────────────────────────────────────────────────────
# package the release CLI for sibling-container benchmark runs
build-mainarch-image image='localhost/mainarch:latest': build
@${DOCKER_BIN:-docker} build --tag {{image}} -f Dockerfile.mainarch-bench .
# build and run the one-page demo as its own container image
build-demo-image image='localhost/mainarch-demo:latest': build
@MAINARCH_DEMO_IMAGE={{image}} bash tools/demo_container.sh build
run-demo-container image='localhost/mainarch-demo:latest':
@MAINARCH_DEMO_IMAGE={{image}} bash tools/demo_container.sh run
smoke-demo-container:
@bash tools/demo_container.sh smoke
stop-demo-container:
@bash tools/demo_container.sh stop
# ─── baselines ─────────────────────────────────────────────────────────────────
# how to capture an upstream rccl-tests reference run
baseline:
@cat baseline/README.md
# side-by-side rccl: a ROCm baseline image vs mainarch, as sibling containers
# usage: just bench <rocm-image-with-rccl-tests> [mainarch-image] [ngpus]
bench rocm_image='' mainarch_image='localhost/mainarch:latest' ngpus='8' min_bytes='8' max_bytes='134217728':
ROCM_IMAGE={{rocm_image}} MAINARCH_IMAGE={{mainarch_image}} bash bench/compare-rccl.sh {{ngpus}} {{min_bytes}} {{max_bytes}}
# dry-run the benchmark command line before burning cycles
bench-dry rocm_image='' mainarch_image='localhost/mainarch:latest' ngpus='8' min_bytes='8' max_bytes='134217728':
DRY_RUN=1 ROCM_IMAGE={{rocm_image}} MAINARCH_IMAGE={{mainarch_image}} bash bench/compare-rccl.sh {{ngpus}} {{min_bytes}} {{max_bytes}}