5
0

run-tests.yaml 2.9 KB

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