run-tests.yaml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: Tests
  2. on:
  3. push:
  4. branches: [ main ]
  5. pull_request:
  6. jobs:
  7. run-tests:
  8. runs-on: ubuntu-latest
  9. strategy:
  10. matrix:
  11. python-version: [ '3.7', '3.8', '3.9', '3.10' ]
  12. fail-fast: false
  13. timeout-minutes: 15
  14. steps:
  15. - name: Checkout
  16. uses: actions/checkout@v3
  17. - name: Set up Python
  18. uses: actions/setup-python@v3
  19. with:
  20. python-version: ${{ matrix.python-version }}
  21. - name: Cache dependencies
  22. uses: actions/cache@v3
  23. with:
  24. path: ~/.cache/pip
  25. key: Key-v1-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
  26. - name: Install dependencies
  27. run: |
  28. python -m pip install --upgrade pip
  29. pip install .[dev]
  30. - name: Test
  31. run: |
  32. export MODEL_NAME=bigscience/bloom-560m
  33. export REF_NAME=bigscience/bloom-560m
  34. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 0:12 \
  35. --new_swarm --identity tests/test.id --host_maddrs /ip4/127.0.0.1/tcp/31337 --throughput 1 \
  36. --torch_dtype float32 --compression NONE --attn_cache_tokens 2048 &> server1.log &
  37. SERVER1_PID=$!
  38. sleep 5 # wait for the first server to initialize DHT
  39. export INITIAL_PEERS=/ip4/127.0.0.1/tcp/31337/p2p/QmS9KwZptnVdB9FFV7uGgaTq4sEKBwcYeKZDfSpyKDUd1g
  40. # ^-- server 1 multiaddr is determined by --identity and --host_maddrs
  41. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 12:22 \
  42. --initial_peers $INITIAL_PEERS --throughput 1 --torch_dtype float32 &> server2.log &
  43. SERVER2_PID=$!
  44. sleep 10 # wait for initial servers to declare blocks, then let server decide which blocks to serve
  45. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 0:5 \
  46. --initial_peers $INITIAL_PEERS --throughput 1 --torch_dtype float32 &> server3.log &
  47. SERVER3_PID=$!
  48. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --num_blocks 3 \
  49. --initial_peers $INITIAL_PEERS --throughput 1 --torch_dtype float32 --tensor_parallel_devices cpu cpu &> server4.log &
  50. SERVER4_PID=$!
  51. tail -n 100 -f server*.log &
  52. LOGGER_PID=$!
  53. sleep 30 # wait for servers to download layers
  54. kill -0 $SERVER1_PID $SERVER2_PID $SERVER3_PID $SERVER4_PID # ensure all servers survived init
  55. pytest tests --durations=0 --durations-min=1.0 -v
  56. kill -0 $SERVER1_PID $SERVER2_PID $SERVER3_PID $SERVER4_PID # ensure all servers survived tests
  57. kill -s SIGINT $SERVER1_PID $SERVER2_PID $SERVER3_PID $SERVER4_PID $LOGGER_PID
  58. echo "Done!"