Run Inference in Parallel #114
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Inference in Parallel | |
on: | |
workflow_dispatch: | |
inputs: | |
model-id: | |
required: true | |
type: string | |
sample-only: | |
required: false | |
type: string | |
n-workers: | |
description: 'number of workers to use (max 50)' | |
required: true | |
default: '50' | |
type: string | |
permissions: | |
contents: read | |
jobs: | |
start-time: | |
runs-on: ubuntu-latest | |
outputs: | |
start-time: ${{ steps.start-time.outputs.start-time }} | |
steps: | |
- name: Get start time | |
id: start-time | |
run: echo "start-time=$(date +%s)" >> "$GITHUB_OUTPUT" | |
pull-model-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Remove unnecessary files | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
sudo rm -rf /opt/ghc | |
sudo rm -rf "/usr/local/share/boost" | |
- name: cache model Docker image | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/${{ inputs.model-id }}.tar | |
key: ${{ runner.os }}-docker-${{ inputs.model-id }} | |
restore-keys: | | |
${{ runner.os }}-docker-${{ inputs.model-id }} | |
- name: pull and save requested model image | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
docker pull ersiliaos/${{ inputs.model-id }}:latest | |
docker save ersiliaos/${{ inputs.model-id }} -o /tmp/${{ inputs.model-id }}.tar | |
generate-matrix: | |
needs: pull-model-image | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- id: set-matrix | |
run: | | |
start='1' | |
end=${{ inputs.n-workers }} | |
matrix=$(seq -s ',' $start $end) | |
echo "matrix=[${matrix}]" >> $GITHUB_OUTPUT | |
matrix-inference: | |
needs: generate-matrix | |
if: github.repository != 'ersilia-os/eos-template' | |
strategy: | |
matrix: | |
numerator: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
uses: ./.github/workflows/predict.yml | |
with: | |
numerator: ${{ matrix.numerator }} | |
denominator: ${{ inputs.n-workers }} | |
model-id: ${{ inputs.model-id }} | |
sample-only: ${{ inputs.sample-only }} | |
SHA: ${{ github.sha }} | |
secrets: inherit | |