bench_job.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # This is the reusable workflow file
  2. name: Distributed Job Runner
  3. on:
  4. workflow_call:
  5. inputs:
  6. config:
  7. required: true
  8. type: string
  9. model:
  10. required: true
  11. type: string
  12. calling_job_name: # New input parameter
  13. required: true
  14. type: string
  15. jobs:
  16. generate-matrix:
  17. runs-on: ubuntu-latest
  18. outputs:
  19. matrix: ${{ steps.set-matrix.outputs.matrix }}
  20. steps:
  21. - id: set-matrix
  22. env:
  23. CONFIG: ${{ inputs.config }}
  24. run: |
  25. MATRIX=$(echo $CONFIG | jq -c '{cpu: [to_entries | .[] | .key as $k | range(.value) | $k]}')
  26. echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
  27. run-distributed-job:
  28. needs: generate-matrix
  29. strategy:
  30. matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
  31. runs-on: ['self-hosted', 'macOS', '${{ matrix.cpu }}']
  32. env:
  33. HARDWARE_CONFIG: ${{ inputs.config }}
  34. model: ${{ inputs.model }}
  35. steps:
  36. - uses: actions/checkout@v4
  37. - name: Install dependencies
  38. run: |
  39. # First, find where python3.12 is installed
  40. which python3.12 || echo "python3.12 not in PATH"
  41. # Add common Python installation locations to PATH
  42. export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
  43. # Now try to create the venv with explicit python3.12
  44. python3.12 -m venv env || {
  45. echo "Failed to find python3.12. Checking installation locations:"
  46. ls -l /usr/local/bin/python* /opt/homebrew/bin/python* 2>/dev/null || true
  47. exit 1
  48. }
  49. source env/bin/activate
  50. pip install --upgrade pip
  51. pip install .
  52. pip install boto3==1.35.76
  53. - name: Run exo
  54. env:
  55. aws_access_key_id: ${{ secrets.S3_EXO_BENCHMARKS_AWS_ACCESS_KEY_ID }}
  56. aws_secret_key: ${{ secrets.S3_EXO_BENCHMARKS_AWS_SECRET_ACCESS_KEY }}
  57. run: |
  58. CALLING_JOB="${{ inputs.calling_job_name }}"
  59. UNIQUE_JOB_ID="${CALLING_JOB}_${GITHUB_RUN_ID}"
  60. ALL_NODE_IDS=$(for i in $(seq ${{ strategy.job-total }} -1 0); do echo -n "${UNIQUE_JOB_ID}_${i},"; done | sed 's/,$//')
  61. MY_NODE_ID="${UNIQUE_JOB_ID}_${{ strategy.job-index }}"
  62. source env/bin/activate
  63. export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
  64. exo --node-id="${MY_NODE_ID}" --node-id-filter="${ALL_NODE_IDS}" --chatgpt-api-port 52415 > output1.log 2>&1 &
  65. PID1=$!
  66. tail -f output1.log &
  67. TAIL1=$!
  68. trap 'kill $TAIL1' EXIT
  69. trap 'kill $PID1' EXIT
  70. for i in {1..100}; do
  71. nodes=$(curl http://localhost:52415/topology | jq ".nodes | length")
  72. if [ "$nodes" -eq "${{ strategy.job-total }}" ]; then
  73. break
  74. fi
  75. sleep 5
  76. done
  77. if ! kill -0 $PID1 2>/dev/null; then
  78. echo "Instance (PID $PID1) died unexpectedly. Log output:"
  79. cat output1.log
  80. exit 1
  81. fi
  82. if [ "${{ strategy.job-index }}" -eq "0" ]; then
  83. GITHUB_JOB=$CALLING_JOB python .github/bench.py
  84. else
  85. sleep 10
  86. while true; do
  87. nodes=$(curl http://localhost:52415/topology | jq ".nodes | length")
  88. if [ "$nodes" -lt "${{ strategy.job-total }}" ]; then
  89. break
  90. fi
  91. sleep 5
  92. done
  93. fi