bench_job.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. # List existing exo processes
  59. echo "Existing exo processes:"
  60. ps aux | grep exo || true
  61. CALLING_JOB="${{ inputs.calling_job_name }}"
  62. UNIQUE_JOB_ID="${CALLING_JOB}_${model}_${GITHUB_RUN_ID}"
  63. ALL_NODE_IDS=$(for i in $(seq ${{ strategy.job-total }} -1 0); do echo -n "${UNIQUE_JOB_ID}_${i},"; done | sed 's/,$//')
  64. MY_NODE_ID="${UNIQUE_JOB_ID}_${{ strategy.job-index }}"
  65. echo "Starting exo process with:"
  66. echo "MY_NODE_ID: ${MY_NODE_ID}"
  67. echo "ALL_NODE_IDS: ${ALL_NODE_IDS}"
  68. echo "Total expected nodes: ${{ strategy.job-total }}"
  69. source env/bin/activate
  70. export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
  71. echo "Starting exo daemon..."
  72. DEBUG=6 DEBUG_DISCOVERY=6 exo --node-id="${MY_NODE_ID}" --node-id-filter="${ALL_NODE_IDS}" --interface-type-filter="Ethernet" --chatgpt-api-port 52415 > output1.log 2>&1 &
  73. PID1=$!
  74. echo "Exo process started with PID: $PID1"
  75. tail -f output1.log &
  76. TAIL1=$!
  77. trap 'kill $TAIL1' EXIT
  78. trap 'kill $PID1' EXIT
  79. echo "Waiting for all nodes to connect..."
  80. for i in {1..100}; do
  81. echo "Attempt $i: Checking node count..."
  82. nodes=$(curl -s http://localhost:52415/topology | jq ".nodes | length")
  83. echo "Current node count: $nodes"
  84. if [ "$nodes" -eq "${{ strategy.job-total }}" ]; then
  85. echo "All nodes connected successfully!"
  86. break
  87. fi
  88. sleep 5
  89. done
  90. if ! kill -0 $PID1 2>/dev/null; then
  91. echo "ERROR: Instance (PID $PID1) died unexpectedly. Full log output:"
  92. cat output1.log
  93. exit 1
  94. fi
  95. if [ "${{ strategy.job-index }}" -eq "0" ]; then
  96. sleep 10
  97. echo "This is the primary node (index 0). Running benchmark..."
  98. GITHUB_JOB=$CALLING_JOB python .github/bench.py
  99. else
  100. echo "This is a secondary node (index ${{ strategy.job-index }}). Waiting for completion..."
  101. sleep 10
  102. while true; do
  103. echo "Checking if primary node is still running..."
  104. nodes=$(curl -s http://localhost:52415/topology | jq ".nodes | length")
  105. echo "Current node count: $nodes"
  106. if [ "$nodes" -lt "${{ strategy.job-total }}" ]; then
  107. echo "Primary node completed, exiting..."
  108. break
  109. fi
  110. sleep 5
  111. done
  112. fi