config.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 exo --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 exo --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. # Special handling for dummy engine
  40. if [ "<<parameters.inference_engine>>" = "dummy" ]; then
  41. expected_content="This is a dummy response"
  42. else
  43. expected_content="Michael Jackson"
  44. fi
  45. echo "Sending request to first instance..."
  46. response_1=$(curl -s http://localhost:8000/v1/chat/completions \
  47. -H "Content-Type: application/json" \
  48. -d '{
  49. "model": "<<parameters.model_id>>",
  50. "messages": [{"role": "user", "content": "Keep responses concise. Who was the king of pop?"}],
  51. "temperature": 0.7
  52. }')
  53. echo "Response 1: $response_1"
  54. # Check processes after first response
  55. check_processes
  56. echo "Sending request to second instance..."
  57. response_2=$(curl -s http://localhost:8001/v1/chat/completions \
  58. -H "Content-Type: application/json" \
  59. -d '{
  60. "model": "<<parameters.model_id>>",
  61. "messages": [{"role": "user", "content": "Keep responses concise. Who was the king of pop?"}],
  62. "temperature": 0.7
  63. }')
  64. echo "Response 2: $response_2"
  65. # Check processes after second response
  66. check_processes
  67. # Stop both instances
  68. kill $PID1 $PID2
  69. echo ""
  70. if ! echo "$response_1" | grep -q "$expected_content" || ! echo "$response_2" | grep -q "$expected_content"; then
  71. echo "Test failed: Response does not contain '$expected_content'"
  72. echo "Response 1: $response_1"
  73. echo ""
  74. echo "Response 2: $response_2"
  75. echo "Output of first instance:"
  76. cat output1.log
  77. echo "Output of second instance:"
  78. cat output2.log
  79. exit 1
  80. else
  81. echo "Test passed: Response from both nodes contains '$expected_content'"
  82. fi
  83. jobs:
  84. unit_test:
  85. macos:
  86. xcode: "16.0.0"
  87. resource_class: m2pro.large
  88. steps:
  89. - checkout
  90. - run:
  91. name: Set up Python
  92. command: |
  93. brew install python@3.12
  94. python3.12 -m venv env
  95. source env/bin/activate
  96. - run:
  97. name: Install dependencies
  98. command: |
  99. source env/bin/activate
  100. pip install --upgrade pip
  101. pip install .
  102. - run:
  103. name: Run tests
  104. command: |
  105. source env/bin/activate
  106. # set TEMPERATURE to 0 for deterministic sampling
  107. echo "Running inference engine tests..."
  108. METAL_DEVICE_WRAPPER_TYPE=1 METAL_DEBUG_ERROR_MODE=0 METAL_XCODE=1 TEMPERATURE=0 python3 -m exo.inference.test_inference_engine
  109. echo "Running tokenizer tests..."
  110. python3 ./test/test_tokenizers.py
  111. discovery_integration_test:
  112. macos:
  113. xcode: "16.0.0"
  114. steps:
  115. - checkout
  116. - run:
  117. name: Set up Python
  118. command: |
  119. brew install python@3.12
  120. python3.12 -m venv env
  121. source env/bin/activate
  122. - run:
  123. name: Install dependencies
  124. command: |
  125. source env/bin/activate
  126. pip install --upgrade pip
  127. pip install .
  128. - run:
  129. name: Run discovery integration test
  130. command: |
  131. source env/bin/activate
  132. DEBUG_DISCOVERY=7 DEBUG=7 exo --node-id "node1" --listen-port 5678 --broadcast-port 5679 --chatgpt-api-port 8000 > output1.log 2>&1 &
  133. PID1=$!
  134. DEBUG_DISCOVERY=7 DEBUG=7 exo --node-id "node2" --listen-port 5679 --broadcast-port 5678 --chatgpt-api-port 8001 > output2.log 2>&1 &
  135. PID2=$!
  136. sleep 10
  137. kill $PID1 $PID2
  138. 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
  139. echo "Test passed: Both instances discovered each other"
  140. exit 0
  141. else
  142. echo "Test failed: Devices did not discover each other"
  143. echo "Output of first instance:"
  144. cat output1.log
  145. echo "Output of second instance:"
  146. cat output2.log
  147. exit 1
  148. fi
  149. chatgpt_api_integration_test_mlx:
  150. macos:
  151. xcode: "16.0.0"
  152. resource_class: m2pro.large
  153. steps:
  154. - checkout
  155. - run:
  156. name: Set up Python
  157. command: |
  158. brew install python@3.12
  159. python3.12 -m venv env
  160. source env/bin/activate
  161. - run:
  162. name: Install dependencies
  163. command: |
  164. source env/bin/activate
  165. pip install --upgrade pip
  166. pip install .
  167. - run_chatgpt_api_test:
  168. inference_engine: mlx
  169. model_id: llama-3.2-1b
  170. chatgpt_api_integration_test_dummy:
  171. macos:
  172. xcode: "16.0.0"
  173. resource_class: m2pro.large
  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: dummy
  190. model_id: dummy-model
  191. test_macos_m1:
  192. macos:
  193. xcode: "16.0.0"
  194. resource_class: m2pro.large
  195. steps:
  196. - checkout
  197. - run: system_profiler SPHardwareDataType
  198. # chatgpt_api_integration_test_tinygrad:
  199. # macos:
  200. # xcode: "16.0.0"
  201. # resource_class: m2pro.large
  202. # steps:
  203. # - checkout
  204. # - run:
  205. # name: Set up Python
  206. # command: |
  207. # brew install python@3.12
  208. # python3.12 -m venv env
  209. # source env/bin/activate
  210. # - run:
  211. # name: Install dependencies
  212. # command: |
  213. # source env/bin/activate
  214. # pip install --upgrade pip
  215. # pip install .
  216. # - run_chatgpt_api_test:
  217. # inference_engine: tinygrad
  218. # model_id: llama-3-8b
  219. workflows:
  220. version: 2
  221. build_and_test:
  222. jobs:
  223. - unit_test
  224. - discovery_integration_test
  225. - chatgpt_api_integration_test_mlx
  226. - chatgpt_api_integration_test_dummy
  227. - test_macos_m1
  228. # - chatgpt_api_integration_test_tinygrad