Files
2026-08-19 23:45:59 -07:00

137 lines
4.9 KiB
YAML

name: CPU CI Job
on:
workflow_call:
inputs:
execute_command:
type: string
required: true
ref:
description: 'Git ref to check out (empty = the triggering commit). Set by release CI to test a release branch.'
type: string
required: false
default: ''
plan_already_resolved:
description: 'Skip the --list-only preflight when a trusted caller already resolved the execution plan.'
type: boolean
required: false
default: false
secrets:
HF_TOKEN:
required: false
jobs:
# CPU-only path: GitHub-hosted ubuntu-latest, bare pip install.
# Used for fast CPU tests so they don't occupy GPU-fleet runner slots.
run-cpu:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
SGLANG_SOURCE_ROOT: ${{ github.workspace }}/sglang/python
MEGATRON_SOURCE_ROOT: ${{ github.workspace }}/Megatron-LM
steps:
- name: Free disk space
shell: bash
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
df -h
- name: Checkout miles
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
# 3.11 required for BaseException.add_note (PEP 678), used in miles
# source (e.g. miles/rollout/generate_utils/sample_utils.py).
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Resolve dependency refs
id: resolve-refs
shell: bash
env:
PR_BODY: ${{ github.event.pull_request.body || '' }}
INPUT_MEGATRON_PR: ${{ github.event.inputs.ci_megatron_pr || '' }}
INPUT_SGLANG_PR: ${{ github.event.inputs.ci_sglang_pr || '' }}
run: |
MEGATRON_PR="${INPUT_MEGATRON_PR}"
SGLANG_PR="${INPUT_SGLANG_PR}"
if [ -n "$PR_BODY" ]; then
PR_MEGATRON_PR=$(echo "$PR_BODY" | grep -m1 -oP '^ci-megatron-pr:\s+\K\S+' || true)
PR_SGLANG_PR=$(echo "$PR_BODY" | grep -m1 -oP '^ci-sglang-pr:\s+\K\S+' || true)
[ -z "$MEGATRON_PR" ] && [ -n "$PR_MEGATRON_PR" ] && MEGATRON_PR="$PR_MEGATRON_PR"
[ -z "$SGLANG_PR" ] && [ -n "$PR_SGLANG_PR" ] && SGLANG_PR="$PR_SGLANG_PR"
fi
# Release branches carry release-lock.json (written at branch cut) pinning
# the dependency SHAs the release was frozen with. Explicit overrides above
# still win; the moving branch heads are only the last resort.
if [ -f release-lock.json ]; then
LOCK_SGLANG=$(python3 -c "import json; print(json.load(open('release-lock.json'))['sglang_commit'])")
LOCK_MEGATRON=$(python3 -c "import json; print(json.load(open('release-lock.json'))['megatron_commit'])")
[ -z "$SGLANG_PR" ] && SGLANG_PR="$LOCK_SGLANG"
[ -z "$MEGATRON_PR" ] && MEGATRON_PR="$LOCK_MEGATRON"
echo "release-lock.json present: sglang=$LOCK_SGLANG megatron=$LOCK_MEGATRON"
fi
[ -z "$MEGATRON_PR" ] && MEGATRON_PR="miles-main"
[ -z "$SGLANG_PR" ] && SGLANG_PR="sglang-miles"
resolve_fetch_ref() {
local ref="$1"
if [[ "$ref" =~ ^#([0-9]+)$ ]]; then
echo "refs/pull/${BASH_REMATCH[1]}/head"
else
echo "$ref"
fi
}
MEGATRON_FETCH=$(resolve_fetch_ref "$MEGATRON_PR")
SGLANG_FETCH=$(resolve_fetch_ref "$SGLANG_PR")
echo "ci_megatron_pr=$MEGATRON_FETCH" >> $GITHUB_OUTPUT
echo "ci_sglang_pr=$SGLANG_FETCH" >> $GITHUB_OUTPUT
echo "Resolved: megatron=$MEGATRON_PR -> fetch=$MEGATRON_FETCH, sglang=$SGLANG_PR -> fetch=$SGLANG_FETCH"
- name: Checkout sglang
uses: actions/checkout@v4
with:
repository: sgl-project/sglang
ref: ${{ steps.resolve-refs.outputs.ci_sglang_pr }}
path: sglang
- name: Checkout Megatron-LM
uses: actions/checkout@v4
with:
repository: radixark/Megatron-LM
ref: ${{ steps.resolve-refs.outputs.ci_megatron_pr }}
path: Megatron-LM
- name: Configure source paths
shell: bash
run: echo "PYTHONPATH=$GITHUB_WORKSPACE:$SGLANG_SOURCE_ROOT:$MEGATRON_SOURCE_ROOT" >> "$GITHUB_ENV"
- name: Install dependencies
shell: bash
env:
UV_SYSTEM_PYTHON: "1"
run: |
uv pip install -r requirements.txt -r tests/ci/requirements-ci-cpu.txt
python tests/ci/verify_source_resolution.py
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v4.2.3
- name: Resolve suite plan
if: ${{ !inputs.plan_already_resolved }}
shell: bash
run: ${{ inputs.execute_command }} --list-only
- name: Run tests
shell: bash
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: ${{ inputs.execute_command }}