Skip to content

chore(deps): bump the pip group across 5 directories with 9 updates #278

chore(deps): bump the pip group across 5 directories with 9 updates

chore(deps): bump the pip group across 5 directories with 9 updates #278

name: PR - PyTorch EC2 CPU
on:
pull_request:
branches: [main]
types: [opened, reopened, synchronize]
paths:
- ".github/config/image/pytorch-*-ec2-cpu.yml"
- ".github/workflows/pr-pytorch-ec2-cpu.yml"
- "docker/pytorch/*/Dockerfile.cpu"
- "docker/pytorch/*/cpu/**"
- "docker/pytorch/*/versions-cpu.env"
- "scripts/common/**"
- "scripts/pytorch/**"
- "scripts/telemetry/**"
- "test/pytorch/**"
- "test/sanity/**"
- "test/telemetry/**"
- "!docs/**"
permissions:
contents: read
pull-requests: read
env:
FORCE_COLOR: "1"
LATEST_PYTORCH_VERSION: "2.11"
jobs:
# ============================================================
# Gate: permission check on base branch
# ============================================================
gatekeeper:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-gate-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout base branch (safe)
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.sha }}
fetch-depth: 1
- name: Run permission gate (from base)
uses: ./.github/actions/pr-permission-gate
# ============================================================
# Detect all changed PyTorch versions + file changes
# ============================================================
check-changes:
needs: [gatekeeper]
if: success()
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-detect-${{ github.event.pull_request.number }}
cancel-in-progress: true
outputs:
versions: ${{ steps.versions.outputs.versions }}
configs: ${{ steps.versions.outputs.configs }}
build-change: ${{ steps.changes.outputs.build-change }}
sanity-test-change: ${{ steps.changes.outputs.sanity-test-change }}
telemetry-test-change: ${{ steps.changes.outputs.telemetry-test-change }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files
- name: Install yq
run: |
if ! command -v yq &> /dev/null; then
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
fi
- name: Detect PyTorch versions and build configs matrix
id: versions
run: |
VERSIONS=$(git diff --name-only origin/main...HEAD \
| grep -oP '(?:docker/pytorch/|pytorch-)\K[0-9]+\.[0-9]+' \
| sort -u)
if [ -z "$VERSIONS" ]; then
VERSIONS="$LATEST_PYTORCH_VERSION"
fi
JSON=$(echo "$VERSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "versions=${JSON}" >> $GITHUB_OUTPUT
echo "Detected versions: ${JSON}"
# Build a configs matrix: each entry carries all metadata fields
CONFIGS="[]"
for V in $VERSIONS; do
CONFIG_FILE=".github/config/image/pytorch-${V}-ec2-cpu.yml"
if [ -f "$CONFIG_FILE" ]; then
CONFIGS=$(echo "$CONFIGS" | jq -c \
--arg v "$V" \
--arg fw "$(yq '.common.framework' $CONFIG_FILE)" \
--arg fwv "$(yq '.common.framework_version' $CONFIG_FILE)" \
--arg py "$(yq '.common.python_version' $CONFIG_FILE)" \
--arg cuda "$(yq '.common.cuda_version' $CONFIG_FILE)" \
--arg os "$(yq '.common.os_version' $CONFIG_FILE)" \
--arg ct "$(yq '.common.job_type' $CONFIG_FILE)" \
--arg dt "$(yq '.common.device_type // "gpu"' $CONFIG_FILE)" \
--arg at "$(yq '.common.arch_type // "x86"' $CONFIG_FILE)" \
--arg contrib "$(yq '.common.contributor // "None"' $CONFIG_FILE)" \
--arg cust "$(yq '.common.customer_type // ""' $CONFIG_FILE)" \
--arg prod "$(yq '.common.prod_image' $CONFIG_FILE)" \
'. + [{"version": $v, "framework": $fw, "framework_version": $fwv, "python_version": $py, "cuda_version": $cuda, "os_version": $os, "container_type": $ct, "device_type": $dt, "arch_type": $at, "contributor": $contrib, "customer_type": $cust, "prod_image": $prod}]')
fi
done
echo "configs=${CONFIGS}" >> $GITHUB_OUTPUT
echo "Configs matrix: ${CONFIGS}"
- name: Detect file changes
id: changes
uses: dorny/paths-filter@v4
with:
filters: |
build-change:
- ".github/config/image/pytorch-*-ec2-cpu.yml"
- "docker/pytorch/*/Dockerfile.cpu"
- "docker/pytorch/*/cpu/**"
- "scripts/common/setup_oss_compliance.sh"
- "scripts/pytorch/configure_ssh.sh"
- "scripts/telemetry/bash_telemetry.sh.template"
sanity-test-change:
- "test/sanity/**"
telemetry-test-change:
- "test/telemetry/**"
# ============================================================
# Build CPU images (matrix over detected versions)
# ============================================================
build-images:
needs: [check-changes]
if: needs.check-changes.outputs.build-change == 'true'
runs-on:
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
fleet:default-runner
buildspec-override:true
strategy:
matrix:
include: ${{ fromJson(needs.check-changes.outputs.configs) }}
fail-fast: false
concurrency:
group: ${{ github.workflow }}-build-${{ matrix.version }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup buildkitd
run: .github/scripts/buildkitd.sh
- name: ECR login
uses: ./.github/actions/ecr-authenticate
with:
aws-account-id: ${{ vars.CI_AWS_ACCOUNT_ID }}
aws-region: ${{ vars.AWS_REGION }}
- name: Build runtime image
id: build-runtime
run: |
VERSION="${{ matrix.version }}"
source docker/pytorch/${VERSION}/versions-cpu.env
CI_IMAGE_URI="${{ vars.CI_AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/ci:pytorch-cpu-runtime-${{ matrix.version }}-pr-${{ github.event.pull_request.number }}"
docker buildx build --progress plain \
--build-arg DLC_PYTORCH_VERSION=${{ matrix.version }} \
--build-arg FRAMEWORK=${{ matrix.framework }} \
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
--build-arg TORCH_VERSION=${TORCH_VERSION} \
--build-arg DLC_MAJOR_VERSION=${DLC_MAJOR_VERSION} \
--build-arg DLC_MINOR_VERSION=${DLC_MINOR_VERSION} \
--build-arg OPEN_MPI_VERSION=${OPEN_MPI_VERSION} \
--cache-to=type=inline \
--cache-from=type=registry,ref=${CI_IMAGE_URI} \
--tag ${CI_IMAGE_URI} \
--push \
--target runtime \
-f docker/pytorch/${VERSION}/Dockerfile.cpu .
echo "image-uri=${CI_IMAGE_URI}" >> $GITHUB_OUTPUT
# ============================================================
# Unit tests (CPU-only, no GPU needed)
# ============================================================
unit-test:
needs: [check-changes, build-images]
if: success()
strategy:
matrix:
include: ${{ fromJson(needs.check-changes.outputs.configs) }}
fail-fast: false
runs-on:
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
fleet:default-runner
buildspec-override:true
concurrency:
group: ${{ github.workflow }}-unit-${{ matrix.version }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: ECR login
uses: ./.github/actions/ecr-authenticate
with:
aws-account-id: ${{ vars.CI_AWS_ACCOUNT_ID }}
aws-region: ${{ vars.AWS_REGION }}
- name: Run unit tests
run: |
VERSION="${{ matrix.version }}"
IMAGE="${{ vars.CI_AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/ci:pytorch-cpu-runtime-${{ matrix.version }}-pr-${{ github.event.pull_request.number }}"
docker pull ${IMAGE}
CONTAINER_ID=$(docker run -d --rm --entrypoint /bin/bash \
-e DLC_WORKDIR=/workdir -e DLC_PYTORCH_VERSION=${VERSION} \
-v $(pwd):/workdir --workdir /workdir \
${IMAGE} -c 'sleep infinity')
docker exec ${CONTAINER_ID} pip install pytest -q
docker exec ${CONTAINER_ID} pytest /workdir/test/pytorch/unit/ -v
docker kill ${CONTAINER_ID}
# ============================================================
# Sanity tests
# ============================================================
sanity-test:
needs: [check-changes, build-images]
if: |
always() && !failure() && !cancelled() &&
(needs.check-changes.outputs.build-change == 'true' || needs.check-changes.outputs.sanity-test-change == 'true')
strategy:
matrix:
include: ${{ fromJson(needs.check-changes.outputs.configs) }}
fail-fast: false
uses: ./.github/workflows/reusable-sanity-tests.yml
with:
image-uri: ${{ needs.build-images.result == 'success' && format('{0}.dkr.ecr.{1}.amazonaws.com/ci:pytorch-cpu-runtime-{2}-pr-{3}', vars.CI_AWS_ACCOUNT_ID, vars.AWS_REGION, matrix.version, github.event.pull_request.number) || format('{0}.dkr.ecr.{1}.amazonaws.com/{2}', vars.PROD_AWS_ACCOUNT_ID, vars.AWS_REGION, matrix.prod_image) }}
aws-account-id: ${{ needs.build-images.result == 'success' && vars.CI_AWS_ACCOUNT_ID || vars.PROD_AWS_ACCOUNT_ID }}
aws-region: ${{ vars.AWS_REGION }}
framework: ${{ matrix.framework }}
framework-version: ${{ matrix.framework_version }}
python-version: ${{ matrix.python_version }}
cuda-version: ${{ matrix.cuda_version }}
os-version: ${{ matrix.os_version }}
customer-type: ${{ matrix.customer_type }}
arch-type: ${{ matrix.arch_type }}
device-type: ${{ matrix.device_type }}
contributor: ${{ matrix.contributor }}
container-type: ${{ matrix.container_type }}
# ============================================================
# Security tests
# ============================================================
security-test:
needs: [check-changes, build-images]
if: success()
strategy:
matrix:
include: ${{ fromJson(needs.check-changes.outputs.configs) }}
fail-fast: false
uses: ./.github/workflows/reusable-security-tests.yml
with:
image-uri: ${{ needs.build-images.result == 'success' && format('{0}.dkr.ecr.{1}.amazonaws.com/ci:pytorch-cpu-runtime-{2}-pr-{3}', vars.CI_AWS_ACCOUNT_ID, vars.AWS_REGION, matrix.version, github.event.pull_request.number) || format('{0}.dkr.ecr.{1}.amazonaws.com/{2}', vars.PROD_AWS_ACCOUNT_ID, vars.AWS_REGION, matrix.prod_image) }}
aws-account-id: ${{ needs.build-images.result == 'success' && vars.CI_AWS_ACCOUNT_ID || vars.PROD_AWS_ACCOUNT_ID }}
aws-region: ${{ vars.AWS_REGION }}
framework: ${{ matrix.framework }}
framework-version: ${{ matrix.framework_version }}
# ============================================================
# Telemetry tests
# ============================================================
telemetry-test:
needs: [check-changes, build-images]
if: |
always() && !failure() && !cancelled() &&
(needs.check-changes.outputs.build-change == 'true' || needs.check-changes.outputs.telemetry-test-change == 'true')
strategy:
matrix:
include: ${{ fromJson(needs.check-changes.outputs.configs) }}
fail-fast: false
uses: ./.github/workflows/reusable-telemetry-tests.yml
with:
image-uri: ${{ needs.build-images.result == 'success' && format('{0}.dkr.ecr.{1}.amazonaws.com/ci:pytorch-cpu-runtime-{2}-pr-{3}', vars.CI_AWS_ACCOUNT_ID, vars.AWS_REGION, matrix.version, github.event.pull_request.number) || format('{0}.dkr.ecr.{1}.amazonaws.com/{2}', vars.PROD_AWS_ACCOUNT_ID, vars.AWS_REGION, matrix.prod_image) }}
aws-account-id: ${{ needs.build-images.result == 'success' && vars.CI_AWS_ACCOUNT_ID || vars.PROD_AWS_ACCOUNT_ID }}
aws-region: ${{ vars.AWS_REGION }}
framework: ${{ matrix.framework }}
framework-version: ${{ matrix.framework_version }}
container-type: ${{ matrix.container_type }}