run-tests.yaml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. export ADAPTER_NAME=artek0chumak/bloom-560m-safe-peft
  35. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 0:12 \
  36. --new_swarm --identity tests/test.id --host_maddrs /ip4/127.0.0.1/tcp/31337 --throughput 1 \
  37. --torch_dtype float32 --compression NONE --attn_cache_tokens 2048 --adapters $ADAPTER_NAME &> server1.log &
  38. SERVER1_PID=$!
  39. sleep 5 # wait for the first server to initialize DHT
  40. export INITIAL_PEERS=/ip4/127.0.0.1/tcp/31337/p2p/QmS9KwZptnVdB9FFV7uGgaTq4sEKBwcYeKZDfSpyKDUd1g
  41. # ^-- server 1 multiaddr is determined by --identity and --host_maddrs
  42. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 12:22 \
  43. --initial_peers $INITIAL_PEERS --throughput 1 --torch_dtype float32 --adapters $ADAPTER_NAME &> server2.log &
  44. SERVER2_PID=$!
  45. sleep 10 # wait for initial servers to declare blocks, then let server decide which blocks to serve
  46. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --block_indices 12:15 \
  47. --initial_peers $INITIAL_PEERS --throughput 1 --torch_dtype float32 --tensor_parallel_devices cpu cpu &> server3.log &
  48. SERVER3_PID=$!
  49. python -m petals.cli.run_server --converted_model_name_or_path $MODEL_NAME --num_blocks 3 \
  50. --initial_peers $INITIAL_PEERS --throughput 1 --torch_dtype float32 --adapters $ADAPTER_NAME &> server4.log &
  51. SERVER4_PID=$!
  52. tail -n 100 -f server*.log &
  53. LOGGER_PID=$!
  54. sleep 30 # wait for servers to download layers
  55. kill -0 $SERVER1_PID $SERVER2_PID $SERVER3_PID $SERVER4_PID # ensure all servers survived init
  56. pytest tests --durations=0 --durations-min=1.0 -v
  57. kill -0 $SERVER1_PID $SERVER2_PID $SERVER3_PID $SERVER4_PID # ensure all servers survived tests
  58. kill -s SIGINT $SERVER1_PID $SERVER2_PID $SERVER3_PID $SERVER4_PID $LOGGER_PID
  59. echo "Done!"