Skip to content

Commit 96b5322

Browse files
authored
Merge pull request #87 from control-toolbox/86-general-add-moonshot-cpu
Add moonshot CPU
2 parents 22372be + 3db0cc9 commit 96b5322

24 files changed

Lines changed: 12043 additions & 767 deletions

.github/workflows/benchmark-core-moonshot.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/benchmark-core-mothra.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/benchmark-core-ubuntu-latest.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/benchmark-reusable.yml

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ permissions:
3131
jobs:
3232
run:
3333
runs-on: ${{ fromJSON(inputs.runs_on) }}
34-
timeout-minutes: 600
34+
timeout-minutes: 600 # max is 360 on GitHub runners
3535
env:
3636
SCRIPT_PATH: ${{ inputs.script_path }}
3737

@@ -241,84 +241,84 @@ jobs:
241241
fi
242242
243243
# ---------------------------
244-
# Commit benchmark results
244+
# Commit benchmark results (silent version)
245245
# ---------------------------
246246
- name: Commit benchmark results to current branch
247247
if: steps.benchmark.outputs.benchmark_success == 'true'
248248
run: |
249-
echo "🔧 Configuring git user..."
249+
echo "🔧 Configuring git..."
250250
git config --global user.name "github-actions[bot]"
251251
git config --global user.email "github-actions[bot]@users.noreply.github.com"
252-
echo "✅ Git user configured"
253252
254-
echo "🌳 Checking current git state..."
255-
echo "Current HEAD: $(git rev-parse --short HEAD)"
256-
echo "Current branch: $(git branch --show-current || echo 'DETACHED HEAD')"
257-
253+
# Identify current branch (works for PRs and pushes)
258254
if [ -n "${{ github.head_ref }}" ]; then
259255
BRANCH_NAME="${{ github.head_ref }}"
260-
echo "🔄 This is a PR, switching to branch: $BRANCH_NAME"
261-
git checkout -B "$BRANCH_NAME"
262-
echo "✅ Now on branch: $(git branch --show-current)"
263256
else
264257
BRANCH_NAME="${{ github.ref_name }}"
265-
echo "🔄 This is a push, switching to branch: $BRANCH_NAME"
266-
git checkout -B "$BRANCH_NAME"
267-
echo "✅ Now on branch: $(git branch --show-current)"
268258
fi
259+
echo "🌳 Working branch: $BRANCH_NAME"
269260
270-
echo "📊 Adding benchmark results to current branch..."
271-
261+
# Fetch latest remote state quietly
262+
if git ls-remote --exit-code origin "$BRANCH_NAME" >/dev/null 2>&1; then
263+
git fetch origin "$BRANCH_NAME" --quiet
264+
git reset --mixed origin/"$BRANCH_NAME" --quiet
265+
fi
266+
267+
# Determine output directory
272268
if [ -f "$BENCHMARK_OUTPUT_FILE" ]; then
273269
OUTPUT_DIR=$(cat "$BENCHMARK_OUTPUT_FILE")
274-
echo "📁 Using benchmark output directory: $OUTPUT_DIR"
275270
else
276271
echo "❌ ERROR: $BENCHMARK_OUTPUT_FILE not found"
277272
exit 1
278273
fi
279274
275+
echo "📁 Benchmark output directory: $OUTPUT_DIR"
280276
DIR_NAME=$(basename "$OUTPUT_DIR")
281-
277+
282278
ARTIFACTS=(
283279
"$OUTPUT_DIR/data.json"
284280
"$OUTPUT_DIR/Project.toml"
285281
"$OUTPUT_DIR/Manifest.toml"
286282
"$OUTPUT_DIR/$DIR_NAME.jl"
287283
)
288284
289-
git add "${ARTIFACTS[@]}"
290-
291-
STAGED_ALL=true
292-
for artifact in "${ARTIFACTS[@]}"; do
293-
if git diff --cached --name-only | grep -q "$artifact"; then
294-
echo "✅ $artifact staged for commit"
295-
else
296-
echo "⚠️ $artifact not staged (possibly no changes)"
297-
STAGED_ALL=false
298-
fi
299-
done
285+
# Add only benchmark artifacts
286+
git add "${ARTIFACTS[@]}" >/dev/null 2>&1
300287
301-
if [ "$STAGED_ALL" = true ]; then
302-
echo "📋 Files to be committed:"
303-
git diff --cached --name-status
288+
# Quick summary of staged files
289+
STAGED=$(git diff --cached --name-only | wc -l)
290+
if [ "$STAGED" -eq 0 ]; then
291+
echo "ℹ️ No changes detected in benchmark results — skipping commit"
292+
exit 0
304293
fi
305294
306-
if ! git diff --cached --quiet; then
307-
echo "📝 Committing benchmark results to current branch..."
308-
git commit -m "📊 Add benchmark results" -m "Generated by reusable benchmark workflow" -m "Results saved to ${OUTPUT_DIR}/data.json" -m "Includes environment TOMLs and benchmark script"
309-
echo "✅ Benchmark results committed successfully"
310-
311-
echo "🔄 Fetching remote branch state before overwrite..."
312-
git fetch origin "$BRANCH_NAME" || echo "⚠️ Remote branch does not exist yet, will create it"
295+
echo "📝 Committing $STAGED file(s) to branch $BRANCH_NAME..."
296+
git commit -m "📊 Add benchmark results (${DIR_NAME})" \
297+
-m "Results saved to ${OUTPUT_DIR}/data.json" \
298+
-m "Includes environment TOMLs and benchmark script" \
299+
>/dev/null 2>&1 || {
300+
echo "❌ Commit failed"
301+
exit 1
302+
}
313303
314-
echo "🚀 Force-pushing benchmark results to branch: $BRANCH_NAME"
315-
git push --force-with-lease origin "$BRANCH_NAME"
316-
echo "✅ Benchmark results force-pushed to $BRANCH_NAME"
317-
else
318-
echo "ℹ️ No changes detected in benchmark results"
319-
echo "📊 Current results are identical to previous run"
304+
# Try to rebase quietly before pushing (handle concurrent runs)
305+
if git ls-remote --exit-code origin "$BRANCH_NAME" >/dev/null 2>&1; then
306+
git pull --rebase --autostash origin "$BRANCH_NAME" --quiet || {
307+
echo "⚠️ Rebase conflict — retrying with merge"
308+
git rebase --abort || true
309+
git pull --strategy=ours origin "$BRANCH_NAME" --quiet
310+
}
320311
fi
321312
313+
# Push only updated results
314+
echo "🚀 Pushing results to $BRANCH_NAME..."
315+
git push origin HEAD:"$BRANCH_NAME" --quiet || {
316+
echo "❌ Push failed (possible concurrency issue)"
317+
exit 1
318+
}
319+
320+
echo "✅ Benchmark results pushed successfully for $OUTPUT_DIR"
321+
322322
# ---------------------------
323323
# Workflow summary
324324
# ---------------------------

.github/workflows/benchmarks-orchestrator.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ jobs:
9797
9898
# Check for individual benchmark labels
9999
for bench_id in $BENCHMARK_IDS; do
100-
if echo "$LABELS" | grep -q "run bench $bench_id"; then
100+
ESCAPED_BENCH_ID=$(printf '%s' "$bench_id" | sed 's/[][\\.^$*+?(){}|/-]/\\&/g')
101+
if echo "$LABELS" | grep -qE "(^| )run bench ${ESCAPED_BENCH_ID}( |$)"; then
101102
echo "✅ Found 'run bench $bench_id' label"
102103
103104
# Get full benchmark config from JSON
@@ -245,6 +246,13 @@ jobs:
245246
const prNumber = context.payload.pull_request.number;
246247
const failedJobs = [];
247248
249+
const now = new Date();
250+
const utcMillis = now.getTime() + now.getTimezoneOffset() * 60000;
251+
const tzMillis = utcMillis - 2 * 60 * 60 * 1000; // UTC-2
252+
const tzDate = new Date(tzMillis);
253+
const pad = (value) => value.toString().padStart(2, '0');
254+
const timestamp = `${tzDate.getFullYear()}-${pad(tzDate.getMonth() + 1)}-${pad(tzDate.getDate())} ${pad(tzDate.getHours())}:${pad(tzDate.getMinutes())}:${pad(tzDate.getSeconds())} (UTC-2)`;
255+
248256
// Check benchmark job
249257
if (process.env.BENCHMARK_RESULT === 'failure') {
250258
failedJobs.push('Benchmarks');
@@ -276,7 +284,7 @@ jobs:
276284
- Remove and re-add the benchmark label to restart
277285
278286
---
279-
*🤖 This notification was automatically generated*`;
287+
*🤖 This notification was automatically generated* ${timestamp}`;
280288
281289
// Find existing failure comment
282290
const { data: comments } = await github.rest.issues.listComments({
@@ -332,7 +340,14 @@ jobs:
332340
const benchmarksSummary = process.env.BENCHMARKS_SUMMARY;
333341
const runUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`;
334342
const branchName = context.payload.pull_request.head.ref;
335-
343+
344+
const now = new Date();
345+
const utcMillis = now.getTime() + now.getTimezoneOffset() * 60000;
346+
const tzMillis = utcMillis - 2 * 60 * 60 * 1000; // UTC-2
347+
const tzDate = new Date(tzMillis);
348+
const pad = (value) => value.toString().padStart(2, '0');
349+
const timestamp = `${tzDate.getFullYear()}-${pad(tzDate.getMonth() + 1)}-${pad(tzDate.getDate())} ${pad(tzDate.getHours())}:${pad(tzDate.getMinutes())}:${pad(tzDate.getSeconds())} (UTC-2)`;
350+
336351
const previewSection = `
337352
### 📖 Documentation Preview
338353
- 🌐 **[📚 View Documentation Preview](${previewUrl})** ← Click to see your changes!
@@ -358,7 +373,7 @@ jobs:
358373
- 🌿 [View your feature branch](${context.payload.repository.html_url}/tree/${branchName})
359374
360375
---
361-
*🤖 This notification was automatically generated*`;
376+
*🤖 This notification was automatically generated* ${timestamp}`;
362377
363378
// Find existing success comment
364379
const { data: comments } = await github.rest.issues.listComments({

benchmarks/benchmarks-config.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@
88
"runner": "github"
99
},
1010
{
11-
"id": "core-moonshot",
11+
"id": "core-moonshot-cpu",
1212
"julia_version": "1.11",
1313
"julia_arch": "x64",
1414
"runs_on": "[\"self-hosted\", \"Linux\", \"gpu\", \"cuda\", \"cuda12\"]",
1515
"runner": "self-hosted"
1616
},
1717
{
18-
"id": "core-mothra",
18+
"id": "core-moonshot-gpu",
19+
"julia_version": "1.11",
20+
"julia_arch": "x64",
21+
"runs_on": "[\"self-hosted\", \"Linux\", \"gpu\", \"cuda\", \"cuda12\"]",
22+
"runner": "self-hosted"
23+
},
24+
{
25+
"id": "core-mothra-gpu",
1926
"julia_version": "1.11",
2027
"julia_arch": "x64",
2128
"runs_on": "[\"self-hosted\", \"Linux\", \"gpu\", \"cuda\", \"cuda13\"]",

benchmarks/core-moonshot-cpu.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Benchmark script for core-moonshot-cpu
2+
# Setup (Pkg.activate, instantiate, update, using CTBenchmarks) is handled by the workflow
3+
4+
function main()
5+
project_dir = normpath(@__DIR__, "..")
6+
outpath=joinpath(
7+
project_dir, "docs", "src", "assets", "benchmarks", "core-moonshot-cpu"
8+
)
9+
CTBenchmarks.benchmark(;
10+
outpath=outpath,
11+
problems=[
12+
:beam,
13+
:chain,
14+
:double_oscillator,
15+
# :ducted_fan,
16+
:electric_vehicle,
17+
:glider,
18+
:insurance,
19+
:jackson,
20+
:robbins,
21+
:robot,
22+
:rocket,
23+
:space_shuttle,
24+
:steering,
25+
:vanderpol,
26+
],
27+
solver_models=[:ipopt => [:JuMP, :adnlp, :exa], :madnlp => [:JuMP, :adnlp, :exa]],
28+
grid_sizes=[200, 500, 1000, 2000, 5000],
29+
disc_methods=[:trapeze],
30+
tol=1e-6,
31+
ipopt_mu_strategy="adaptive",
32+
print_trace=false,
33+
max_iter=1000,
34+
max_wall_time=200.0,
35+
)
36+
println("✅ Benchmark completed successfully!")
37+
return outpath
38+
end

docs/src/assets/benchmarks/core-moonshot/core-moonshot.jl renamed to benchmarks/core-moonshot-gpu.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
function main()
55
project_dir = normpath(@__DIR__, "..")
6-
outpath = joinpath(project_dir, "docs", "src", "assets", "benchmarks", "core-moonshot")
6+
outpath = joinpath(project_dir, "docs", "src", "assets", "benchmarks", "core-moonshot-gpu")
77
CTBenchmarks.benchmark(;
88
outpath=outpath,
99
problems=[
@@ -23,7 +23,7 @@ function main()
2323
:vanderpol,
2424
],
2525
solver_models=[:madnlp => [:exa, :exa_gpu]],
26-
grid_sizes=[1000, 5000, 10000],
26+
grid_sizes=[1000, 5000, 10000, 20000],
2727
disc_methods=[:trapeze],
2828
tol=1e-6,
2929
ipopt_mu_strategy="adaptive",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
function main()
55
project_dir = normpath(@__DIR__, "..")
6-
outpath = joinpath(project_dir, "docs", "src", "assets", "benchmarks", "core-mothra")
6+
outpath = joinpath(project_dir, "docs", "src", "assets", "benchmarks", "core-mothra-gpu")
77
CTBenchmarks.benchmark(;
88
outpath=outpath,
99
problems=[

0 commit comments

Comments
 (0)