config.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. version: 2.1
  2. orbs:
  3. python: circleci/python@2
  4. commands:
  5. run_chatgpt_api_test:
  6. parameters:
  7. inference_engine:
  8. type: string
  9. model_id:
  10. type: string
  11. steps:
  12. - run:
  13. name: Run chatgpt api integration test (<<parameters.inference_engine>>, <<parameters.model_id>>)
  14. command: |
  15. source env/bin/activate
  16. # Start first instance
  17. 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 &
  18. PID1=$!
  19. # Start second instance
  20. 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 &
  21. PID2=$!
  22. # Wait for discovery
  23. sleep 10
  24. # Function to check if processes are still running
  25. check_processes() {
  26. if ! kill -0 $PID1 2>/dev/null; then
  27. echo "First instance (PID $PID1) died unexpectedly. Log output:"
  28. cat output1.log
  29. exit 1
  30. fi
  31. if ! kill -0 $PID2 2>/dev/null; then
  32. echo "Second instance (PID $PID2) died unexpectedly. Log output:"
  33. cat output2.log
  34. exit 1
  35. fi
  36. }
  37. # Check processes before proceeding
  38. check_processes
  39. echo "Sending request to first instance..."
  40. response_1=$(curl -s http://localhost:8000/v1/chat/completions \
  41. -H "Content-Type: application/json" \
  42. -d '{
  43. "model": "<<parameters.model_id>>",
  44. "messages": [{"role": "user", "content": "Keep responses concise. Who was the king of pop?"}],
  45. "temperature": 0.7
  46. }')
  47. echo "Response 1: $response_1"
  48. # Check processes after first response
  49. check_processes
  50. echo "Sending request to second instance..."
  51. response_2=$(curl -s http://localhost:8001/v1/chat/completions \
  52. -H "Content-Type: application/json" \
  53. -d '{
  54. "model": "<<parameters.model_id>>",
  55. "messages": [{"role": "user", "content": "Keep responses concise. Who was the king of pop?"}],
  56. "temperature": 0.7
  57. }')
  58. echo "Response 2: $response_2"
  59. # Check processes after second response
  60. check_processes
  61. # Stop both instances
  62. kill $PID1 $PID2
  63. echo ""
  64. if ! echo "$response_1" | grep -q "Michael Jackson" || ! echo "$response_2" | grep -q "Michael Jackson"; then
  65. echo "Test failed: Response does not contain 'Michael Jackson'"
  66. echo "Response 1: $response_1"
  67. echo ""
  68. echo "Response 2: $response_2"
  69. echo "Output of first instance:"
  70. cat output1.log
  71. echo "Output of second instance:"
  72. cat output2.log
  73. exit 1
  74. else
  75. echo "Test passed: Response from both nodes contains 'Michael Jackson'"
  76. fi
  77. jobs:
  78. unit_test:
  79. macos:
  80. xcode: "16.0.0"
  81. resource_class: macos.m1.medium.gen1
  82. steps:
  83. - checkout
  84. - run:
  85. name: Set up Python
  86. command: |
  87. brew install python@3.12
  88. python3.12 -m venv env
  89. source env/bin/activate
  90. - run:
  91. name: Install dependencies
  92. command: |
  93. source env/bin/activate
  94. pip install --upgrade pip
  95. pip install .
  96. - run:
  97. name: Run tests
  98. command: |
  99. source env/bin/activate
  100. # set TEMPERATURE to 0 for deterministic sampling
  101. echo "Running inference engine tests..."
  102. 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
  103. echo "Running tokenizer tests..."
  104. python3 ./test/test_tokenizers.py
  105. discovery_integration_test:
  106. macos:
  107. xcode: "15.4.0"
  108. steps:
  109. - checkout
  110. - run:
  111. name: Set up Python
  112. command: |
  113. brew install python@3.12
  114. python3.12 -m venv env
  115. source env/bin/activate
  116. - run:
  117. name: Install dependencies
  118. command: |
  119. source env/bin/activate
  120. pip install --upgrade pip
  121. pip install .
  122. - run:
  123. name: Run discovery integration test
  124. command: |
  125. source env/bin/activate
  126. 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 &
  127. PID1=$!
  128. 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 &
  129. PID2=$!
  130. sleep 10
  131. kill $PID1 $PID2
  132. 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
  133. echo "Test passed: Both instances discovered each other"
  134. exit 0
  135. else
  136. echo "Test failed: Devices did not discover each other"
  137. echo "Output of first instance:"
  138. cat output1.log
  139. echo "Output of second instance:"
  140. cat output2.log
  141. exit 1
  142. fi
  143. chatgpt_api_integration_test_mlx:
  144. macos:
  145. xcode: "15.4.0"
  146. steps:
  147. - checkout
  148. - run:
  149. name: Set up Python
  150. command: |
  151. brew install python@3.12
  152. python3.12 -m venv env
  153. source env/bin/activate
  154. - run:
  155. name: Install dependencies
  156. command: |
  157. source env/bin/activate
  158. pip install --upgrade pip
  159. pip install .
  160. - run_chatgpt_api_test:
  161. inference_engine: mlx
  162. model_id: llama-3.1-8b
  163. test_macos_m1:
  164. macos:
  165. xcode: "15.4.0"
  166. resource_class: macos.m1.large.gen1
  167. steps:
  168. - checkout
  169. - run: system_profiler SPHardwareDataType
  170. # chatgpt_api_integration_test_tinygrad:
  171. # macos:
  172. # xcode: "15.4.0"
  173. # resource_class: macos.m1.large.gen1
  174. # steps:
  175. # - checkout
  176. # - run:
  177. # name: Set up Python
  178. # command: |
  179. # brew install python@3.12
  180. # python3.12 -m venv env
  181. # source env/bin/activate
  182. # - run:
  183. # name: Install dependencies
  184. # command: |
  185. # source env/bin/activate
  186. # pip install --upgrade pip
  187. # pip install .
  188. # - run_chatgpt_api_test:
  189. # inference_engine: tinygrad
  190. # model_id: llama-3-8b
  191. workflows:
  192. version: 2
  193. build_and_test:
  194. jobs:
  195. - unit_test
  196. - discovery_integration_test
  197. - chatgpt_api_integration_test_mlx
  198. - test_macos_m1
  199. # - chatgpt_api_integration_test_tinygrad