123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- version: 2.1
- orbs:
- python: circleci/python@2
- commands:
- run_chatgpt_api_test:
- parameters:
- inference_engine:
- type: string
- model_id:
- type: string
- steps:
- - run:
- name: Run chatgpt api integration test (<<parameters.inference_engine>>, <<parameters.model_id>>)
- command: |
- source env/bin/activate
- # Start first instance
- HF_HOME="$(pwd)/.hf_cache_node1" DEBUG_DISCOVERY=7 DEBUG=7 python3 main.py --inference-engine <<parameters.inference_engine>> --node-id "node1" --listen-port 5678 --broadcast-port 5679 --chatgpt-api-port 8000 --chatgpt-api-response-timeout 900 2>&1 | tee output1.log &
- PID1=$!
- # Start second instance
- HF_HOME="$(pwd)/.hf_cache_node2" DEBUG_DISCOVERY=7 DEBUG=7 python3 main.py --inference-engine <<parameters.inference_engine>> --node-id "node2" --listen-port 5679 --broadcast-port 5678 --chatgpt-api-port 8001 --chatgpt-api-response-timeout 900 2>&1 | tee output2.log &
- PID2=$!
- # Wait for discovery
- sleep 10
- # Function to check if processes are still running
- check_processes() {
- if ! kill -0 $PID1 2>/dev/null; then
- echo "First instance (PID $PID1) died unexpectedly. Log output:"
- cat output1.log
- exit 1
- fi
- if ! kill -0 $PID2 2>/dev/null; then
- echo "Second instance (PID $PID2) died unexpectedly. Log output:"
- cat output2.log
- exit 1
- fi
- }
- # Check processes before proceeding
- check_processes
- echo "Sending request to first instance..."
- response_1=$(curl -s http://localhost:8000/v1/chat/completions \
- -H "Content-Type: application/json" \
- -d '{
- "model": "<<parameters.model_id>>",
- "messages": [{"role": "user", "content": "Keep responses concise. Who was the king of pop?"}],
- "temperature": 0.7
- }')
- echo "Response 1: $response_1"
- # Check processes after first response
- check_processes
- echo "Sending request to second instance..."
- response_2=$(curl -s http://localhost:8001/v1/chat/completions \
- -H "Content-Type: application/json" \
- -d '{
- "model": "<<parameters.model_id>>",
- "messages": [{"role": "user", "content": "Keep responses concise. Who was the king of pop?"}],
- "temperature": 0.7
- }')
- echo "Response 2: $response_2"
- # Check processes after second response
- check_processes
- # Stop both instances
- kill $PID1 $PID2
- echo ""
- if ! echo "$response_1" | grep -q "Michael Jackson" || ! echo "$response_2" | grep -q "Michael Jackson"; then
- echo "Test failed: Response does not contain 'Michael Jackson'"
- echo "Response 1: $response_1"
- echo ""
- echo "Response 2: $response_2"
- echo "Output of first instance:"
- cat output1.log
- echo "Output of second instance:"
- cat output2.log
- exit 1
- else
- echo "Test passed: Response from both nodes contains 'Michael Jackson'"
- fi
- jobs:
- unit_test:
- macos:
- xcode: "16.0.0"
- resource_class: macos.m1.medium.gen1
- steps:
- - checkout
- - run:
- name: Set up Python
- command: |
- brew install python@3.12
- python3.12 -m venv env
- source env/bin/activate
- - run:
- name: Install dependencies
- command: |
- source env/bin/activate
- pip install --upgrade pip
- pip install .
- - run:
- name: Run tests
- command: |
- source env/bin/activate
- # set TEMPERATURE to 0 for deterministic sampling
- echo "Running inference engine tests..."
- LOW_MEMORY=1 DEVICE=gpu METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 METAL_XCODE=1 TEMPERATURE=0 python3 -m exo.inference.test_inference_engine
- echo "Running tokenizer tests..."
- python3 ./test/test_tokenizers.py
- discovery_integration_test:
- macos:
- xcode: "15.4.0"
- steps:
- - checkout
- - run:
- name: Set up Python
- command: |
- brew install python@3.12
- python3.12 -m venv env
- source env/bin/activate
- - run:
- name: Install dependencies
- command: |
- source env/bin/activate
- pip install --upgrade pip
- pip install .
- - run:
- name: Run discovery integration test
- command: |
- source env/bin/activate
- DEBUG_DISCOVERY=7 DEBUG=7 python3 main.py --node-id "node1" --listen-port 5678 --broadcast-port 5679 --chatgpt-api-port 8000 > output1.log 2>&1 &
- PID1=$!
- DEBUG_DISCOVERY=7 DEBUG=7 python3 main.py --node-id "node2" --listen-port 5679 --broadcast-port 5678 --chatgpt-api-port 8001 > output2.log 2>&1 &
- PID2=$!
- sleep 10
- kill $PID1 $PID2
- if grep -q "Peer statuses: {\\'node2\\': \\'is_connected=True, health_check=True" output1.log && ! grep -q "Failed to connect peers:" output1.log && grep -q "Peer statuses: {\\'node1\\': \\'is_connected=True, health_check=True" output2.log && ! grep -q "Failed to connect peers:" output2.log; then
- echo "Test passed: Both instances discovered each other"
- exit 0
- else
- echo "Test failed: Devices did not discover each other"
- echo "Output of first instance:"
- cat output1.log
- echo "Output of second instance:"
- cat output2.log
- exit 1
- fi
- chatgpt_api_integration_test_mlx:
- macos:
- xcode: "15.4.0"
- steps:
- - checkout
- - run:
- name: Set up Python
- command: |
- brew install python@3.12
- python3.12 -m venv env
- source env/bin/activate
- - run:
- name: Install dependencies
- command: |
- source env/bin/activate
- pip install --upgrade pip
- pip install .
- - run_chatgpt_api_test:
- inference_engine: mlx
- model_id: llama-3.1-8b
- test_macos_m1:
- macos:
- xcode: "15.4.0"
- resource_class: macos.m1.large.gen1
- steps:
- - checkout
- - run: system_profiler SPHardwareDataType
- # chatgpt_api_integration_test_tinygrad:
- # macos:
- # xcode: "15.4.0"
- # resource_class: macos.m1.large.gen1
- # steps:
- # - checkout
- # - run:
- # name: Set up Python
- # command: |
- # brew install python@3.12
- # python3.12 -m venv env
- # source env/bin/activate
- # - run:
- # name: Install dependencies
- # command: |
- # source env/bin/activate
- # pip install --upgrade pip
- # pip install .
- # - run_chatgpt_api_test:
- # inference_engine: tinygrad
- # model_id: llama-3-8b
- workflows:
- version: 2
- build_and_test:
- jobs:
- - unit_test
- - discovery_integration_test
- - chatgpt_api_integration_test_mlx
- - test_macos_m1
- # - chatgpt_api_integration_test_tinygrad
|