Skip to content
Latchkey

Run FA2-related unit tests workflow (huggingface/nanotron)

The Run FA2-related unit tests workflow from huggingface/nanotron, explained and optimized by Latchkey.

C

CI health: C - fair

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: huggingface/nanotron.github/workflows/fa2_unit_tests.yamlLicense Apache-2.0View source

What it does

This is the Run FA2-related unit tests workflow from the huggingface/nanotron repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Run FA2-related unit tests

on:
  workflow_dispatch:
  push:
    branches: [ main ]
    # Only run tests if we modify the following files
    paths:
      - "src/**/*.py"
      - "examples/**/*.py"
      - "tests/**/*.py"

  pull_request:
    branches: [ '**' ]
    paths:
     - "src/**/*.py"
     - "examples/**/*.py"
     - "tests/**/*.py"

jobs:
  tests:
    runs-on:
      group: aws-g5-4xlarge-plus
    container:
      image: runpod/pytorch:2.1.1-py3.10-cuda12.1.1-devel-ubuntu22.04
      ports:
        - 80
      options: --gpus all --shm-size "8G"
    steps:
    - uses: actions/checkout@v3

    - name: Python environment
      run: |
        which python
        python --version

    - name: Check Pytorch version
      run: |
        nvidia-smi
        python -c "import torch; print('torch:', torch.__version__, torch)"
        python -c "import torch; print('CUDA available:', torch.cuda.is_available())"

    - name: Install nanotron
      run: |
        python -m pip install --upgrade pip
        pip install packaging
        pip install wheel
        pip install "flash-attn>=2.5.0" --no-build-isolation
        pip install -e .
        pip install -e .[dev]
        pip install -e .[test]

    - name: Show installed libraries and their versions
      run: pip freeze | tee installed.txt

    - name: Run tests
      # NOTE: -m fa2 will only run the unit tests that have the mark
      # "fa2" (these are FA2-related tests)
      run: pytest -m fa2 --color=yes --durations=0 --ignore tests/fp8 --ignore tests/nanoset --verbose tests/

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Run FA2-related unit tests
 
on:
  workflow_dispatch:
  push:
    branches: [ main ]
    # Only run tests if we modify the following files
    paths:
      - "src/**/*.py"
      - "examples/**/*.py"
      - "tests/**/*.py"
 
  pull_request:
    branches: [ '**' ]
    paths:
     - "src/**/*.py"
     - "examples/**/*.py"
     - "tests/**/*.py"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    runs-on:
      group: aws-g5-4xlarge-plus
    container:
      image: runpod/pytorch:2.1.1-py3.10-cuda12.1.1-devel-ubuntu22.04
      ports:
        - 80
      options: --gpus all --shm-size "8G"
    steps:
    - uses: actions/checkout@v3
 
    - name: Python environment
      run: |
        which python
        python --version
 
    - name: Check Pytorch version
      run: |
        nvidia-smi
        python -c "import torch; print('torch:', torch.__version__, torch)"
        python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
 
    - name: Install nanotron
      run: |
        python -m pip install --upgrade pip
        pip install packaging
        pip install wheel
        pip install "flash-attn>=2.5.0" --no-build-isolation
        pip install -e .
        pip install -e .[dev]
        pip install -e .[test]
 
    - name: Show installed libraries and their versions
      run: pip freeze | tee installed.txt
 
    - name: Run tests
      # NOTE: -m fa2 will only run the unit tests that have the mark
      # "fa2" (these are FA2-related tests)
      run: pytest -m fa2 --color=yes --durations=0 --ignore tests/fp8 --ignore tests/nanoset --verbose tests/
 

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow