metalscope 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. metalscope-0.1.0/.gitignore +15 -0
  2. metalscope-0.1.0/LICENSE +21 -0
  3. metalscope-0.1.0/PKG-INFO +205 -0
  4. metalscope-0.1.0/README.md +169 -0
  5. metalscope-0.1.0/docs/commands.md +117 -0
  6. metalscope-0.1.0/pyproject.toml +71 -0
  7. metalscope-0.1.0/src/metalscope/__init__.py +1 -0
  8. metalscope-0.1.0/src/metalscope/adapters/__init__.py +141 -0
  9. metalscope-0.1.0/src/metalscope/adapters/generic.py +183 -0
  10. metalscope-0.1.0/src/metalscope/adapters/inkling2.py +467 -0
  11. metalscope-0.1.0/src/metalscope/adapters/qwen4_exp.py +111 -0
  12. metalscope-0.1.0/src/metalscope/backends.py +718 -0
  13. metalscope-0.1.0/src/metalscope/bench.py +347 -0
  14. metalscope-0.1.0/src/metalscope/capture.py +445 -0
  15. metalscope-0.1.0/src/metalscope/cli.py +1086 -0
  16. metalscope-0.1.0/src/metalscope/client.py +280 -0
  17. metalscope-0.1.0/src/metalscope/concepts/__init__.py +32 -0
  18. metalscope-0.1.0/src/metalscope/concepts/corpus.py +231 -0
  19. metalscope-0.1.0/src/metalscope/concepts/measure.py +338 -0
  20. metalscope-0.1.0/src/metalscope/concepts/run.py +164 -0
  21. metalscope-0.1.0/src/metalscope/concepts/stats.py +190 -0
  22. metalscope-0.1.0/src/metalscope/concepts/summary.py +256 -0
  23. metalscope-0.1.0/src/metalscope/config.py +205 -0
  24. metalscope-0.1.0/src/metalscope/data/concepts/angry/concept.json +24 -0
  25. metalscope-0.1.0/src/metalscope/data/concepts/angry/neg.txt +16 -0
  26. metalscope-0.1.0/src/metalscope/data/concepts/angry/pos.txt +16 -0
  27. metalscope-0.1.0/src/metalscope/data/concepts/angry/task.json +133 -0
  28. metalscope-0.1.0/src/metalscope/data/concepts/anime-nerd/concept.json +30 -0
  29. metalscope-0.1.0/src/metalscope/data/concepts/anime-nerd/neg.txt +16 -0
  30. metalscope-0.1.0/src/metalscope/data/concepts/anime-nerd/pos.txt +16 -0
  31. metalscope-0.1.0/src/metalscope/data/concepts/anime-nerd/task.json +485 -0
  32. metalscope-0.1.0/src/metalscope/data/concepts/anxious/concept.json +28 -0
  33. metalscope-0.1.0/src/metalscope/data/concepts/anxious/neg.txt +16 -0
  34. metalscope-0.1.0/src/metalscope/data/concepts/anxious/pos.txt +16 -0
  35. metalscope-0.1.0/src/metalscope/data/concepts/anxious/task.json +133 -0
  36. metalscope-0.1.0/src/metalscope/data/concepts/ask-first/concept.json +28 -0
  37. metalscope-0.1.0/src/metalscope/data/concepts/ask-first/neg.txt +48 -0
  38. metalscope-0.1.0/src/metalscope/data/concepts/ask-first/pos.txt +48 -0
  39. metalscope-0.1.0/src/metalscope/data/concepts/ask-first/task.json +133 -0
  40. metalscope-0.1.0/src/metalscope/data/concepts/blunt/concept.json +30 -0
  41. metalscope-0.1.0/src/metalscope/data/concepts/blunt/neg.txt +16 -0
  42. metalscope-0.1.0/src/metalscope/data/concepts/blunt/pos.txt +16 -0
  43. metalscope-0.1.0/src/metalscope/data/concepts/blunt/task.json +485 -0
  44. metalscope-0.1.0/src/metalscope/data/concepts/calm/concept.json +28 -0
  45. metalscope-0.1.0/src/metalscope/data/concepts/calm/neg.txt +16 -0
  46. metalscope-0.1.0/src/metalscope/data/concepts/calm/pos.txt +16 -0
  47. metalscope-0.1.0/src/metalscope/data/concepts/calm/task.json +133 -0
  48. metalscope-0.1.0/src/metalscope/data/concepts/cautious/concept.json +29 -0
  49. metalscope-0.1.0/src/metalscope/data/concepts/cautious/neg.txt +48 -0
  50. metalscope-0.1.0/src/metalscope/data/concepts/cautious/pos.txt +48 -0
  51. metalscope-0.1.0/src/metalscope/data/concepts/cautious/task.json +133 -0
  52. metalscope-0.1.0/src/metalscope/data/concepts/cooperative/concept.json +28 -0
  53. metalscope-0.1.0/src/metalscope/data/concepts/cooperative/neg.txt +16 -0
  54. metalscope-0.1.0/src/metalscope/data/concepts/cooperative/pos.txt +16 -0
  55. metalscope-0.1.0/src/metalscope/data/concepts/cooperative/task.json +133 -0
  56. metalscope-0.1.0/src/metalscope/data/concepts/crunchy/concept.json +28 -0
  57. metalscope-0.1.0/src/metalscope/data/concepts/crunchy/neg.txt +16 -0
  58. metalscope-0.1.0/src/metalscope/data/concepts/crunchy/pos.txt +16 -0
  59. metalscope-0.1.0/src/metalscope/data/concepts/crunchy/task.json +133 -0
  60. metalscope-0.1.0/src/metalscope/data/concepts/crunchy/writing.json +125 -0
  61. metalscope-0.1.0/src/metalscope/data/concepts/doubt/concept.json +8 -0
  62. metalscope-0.1.0/src/metalscope/data/concepts/doubt/neg.txt +16 -0
  63. metalscope-0.1.0/src/metalscope/data/concepts/doubt/pos.txt +16 -0
  64. metalscope-0.1.0/src/metalscope/data/concepts/doubt/task.json +149 -0
  65. metalscope-0.1.0/src/metalscope/data/concepts/duty/concept.json +8 -0
  66. metalscope-0.1.0/src/metalscope/data/concepts/duty/neg.txt +16 -0
  67. metalscope-0.1.0/src/metalscope/data/concepts/duty/pos.txt +16 -0
  68. metalscope-0.1.0/src/metalscope/data/concepts/duty/task.json +133 -0
  69. metalscope-0.1.0/src/metalscope/data/concepts/energized/concept.json +28 -0
  70. metalscope-0.1.0/src/metalscope/data/concepts/energized/neg.txt +16 -0
  71. metalscope-0.1.0/src/metalscope/data/concepts/energized/pos.txt +16 -0
  72. metalscope-0.1.0/src/metalscope/data/concepts/energized/task.json +133 -0
  73. metalscope-0.1.0/src/metalscope/data/concepts/explain-reasoning/concept.json +24 -0
  74. metalscope-0.1.0/src/metalscope/data/concepts/explain-reasoning/neg.txt +48 -0
  75. metalscope-0.1.0/src/metalscope/data/concepts/explain-reasoning/pos.txt +48 -0
  76. metalscope-0.1.0/src/metalscope/data/concepts/explain-reasoning/task.json +133 -0
  77. metalscope-0.1.0/src/metalscope/data/concepts/fluffy/concept.json +8 -0
  78. metalscope-0.1.0/src/metalscope/data/concepts/fluffy/neg.txt +16 -0
  79. metalscope-0.1.0/src/metalscope/data/concepts/fluffy/pos.txt +16 -0
  80. metalscope-0.1.0/src/metalscope/data/concepts/fluffy/task.json +25 -0
  81. metalscope-0.1.0/src/metalscope/data/concepts/flux/concept.json +8 -0
  82. metalscope-0.1.0/src/metalscope/data/concepts/flux/neg.txt +16 -0
  83. metalscope-0.1.0/src/metalscope/data/concepts/flux/pos.txt +16 -0
  84. metalscope-0.1.0/src/metalscope/data/concepts/flux/task.json +133 -0
  85. metalscope-0.1.0/src/metalscope/data/concepts/humorous/concept.json +30 -0
  86. metalscope-0.1.0/src/metalscope/data/concepts/humorous/neg.txt +16 -0
  87. metalscope-0.1.0/src/metalscope/data/concepts/humorous/pos.txt +16 -0
  88. metalscope-0.1.0/src/metalscope/data/concepts/humorous/task.json +517 -0
  89. metalscope-0.1.0/src/metalscope/data/concepts/humorous/writing.json +13 -0
  90. metalscope-0.1.0/src/metalscope/data/concepts/joyful/concept.json +28 -0
  91. metalscope-0.1.0/src/metalscope/data/concepts/joyful/neg.txt +16 -0
  92. metalscope-0.1.0/src/metalscope/data/concepts/joyful/pos.txt +16 -0
  93. metalscope-0.1.0/src/metalscope/data/concepts/joyful/task.json +133 -0
  94. metalscope-0.1.0/src/metalscope/data/concepts/melancholic/concept.json +28 -0
  95. metalscope-0.1.0/src/metalscope/data/concepts/melancholic/neg.txt +16 -0
  96. metalscope-0.1.0/src/metalscope/data/concepts/melancholic/pos.txt +16 -0
  97. metalscope-0.1.0/src/metalscope/data/concepts/melancholic/task.json +133 -0
  98. metalscope-0.1.0/src/metalscope/data/concepts/nostalgic/concept.json +28 -0
  99. metalscope-0.1.0/src/metalscope/data/concepts/nostalgic/neg.txt +16 -0
  100. metalscope-0.1.0/src/metalscope/data/concepts/nostalgic/pos.txt +16 -0
  101. metalscope-0.1.0/src/metalscope/data/concepts/nostalgic/task.json +133 -0
  102. metalscope-0.1.0/src/metalscope/data/concepts/nostalgic/writing.json +151 -0
  103. metalscope-0.1.0/src/metalscope/data/concepts/oceans/concept.json +30 -0
  104. metalscope-0.1.0/src/metalscope/data/concepts/oceans/neg.txt +16 -0
  105. metalscope-0.1.0/src/metalscope/data/concepts/oceans/pos.txt +16 -0
  106. metalscope-0.1.0/src/metalscope/data/concepts/oceans/task.json +485 -0
  107. metalscope-0.1.0/src/metalscope/data/concepts/oceans/writing.json +12 -0
  108. metalscope-0.1.0/src/metalscope/data/concepts/pirate/concept.json +30 -0
  109. metalscope-0.1.0/src/metalscope/data/concepts/pirate/neg.txt +16 -0
  110. metalscope-0.1.0/src/metalscope/data/concepts/pirate/pos.txt +16 -0
  111. metalscope-0.1.0/src/metalscope/data/concepts/pirate/task.json +493 -0
  112. metalscope-0.1.0/src/metalscope/data/concepts/pirate/writing.json +11 -0
  113. metalscope-0.1.0/src/metalscope/data/concepts/righteous/concept.json +30 -0
  114. metalscope-0.1.0/src/metalscope/data/concepts/righteous/neg.txt +16 -0
  115. metalscope-0.1.0/src/metalscope/data/concepts/righteous/pos.txt +16 -0
  116. metalscope-0.1.0/src/metalscope/data/concepts/righteous/task.json +485 -0
  117. metalscope-0.1.0/src/metalscope/data/concepts/robotic/concept.json +24 -0
  118. metalscope-0.1.0/src/metalscope/data/concepts/robotic/neg.txt +16 -0
  119. metalscope-0.1.0/src/metalscope/data/concepts/robotic/pos.txt +16 -0
  120. metalscope-0.1.0/src/metalscope/data/concepts/robotic/task.json +133 -0
  121. metalscope-0.1.0/src/metalscope/data/concepts/sad/concept.json +28 -0
  122. metalscope-0.1.0/src/metalscope/data/concepts/sad/neg.txt +16 -0
  123. metalscope-0.1.0/src/metalscope/data/concepts/sad/pos.txt +16 -0
  124. metalscope-0.1.0/src/metalscope/data/concepts/sad/task.json +133 -0
  125. metalscope-0.1.0/src/metalscope/data/concepts/sarcastic/concept.json +28 -0
  126. metalscope-0.1.0/src/metalscope/data/concepts/sarcastic/neg.txt +16 -0
  127. metalscope-0.1.0/src/metalscope/data/concepts/sarcastic/pos.txt +16 -0
  128. metalscope-0.1.0/src/metalscope/data/concepts/sarcastic/task.json +133 -0
  129. metalscope-0.1.0/src/metalscope/data/concepts/sarcastic/writing.json +106 -0
  130. metalscope-0.1.0/src/metalscope/data/concepts/shouting/concept.json +30 -0
  131. metalscope-0.1.0/src/metalscope/data/concepts/shouting/neg.txt +16 -0
  132. metalscope-0.1.0/src/metalscope/data/concepts/shouting/pos.txt +16 -0
  133. metalscope-0.1.0/src/metalscope/data/concepts/shouting/task.json +485 -0
  134. metalscope-0.1.0/src/metalscope/data/concepts/shouting/writing.json +11 -0
  135. metalscope-0.1.0/src/metalscope/data/concepts/stoic/concept.json +8 -0
  136. metalscope-0.1.0/src/metalscope/data/concepts/stoic/neg.txt +48 -0
  137. metalscope-0.1.0/src/metalscope/data/concepts/stoic/pos.txt +48 -0
  138. metalscope-0.1.0/src/metalscope/data/concepts/stoic/task.json +133 -0
  139. metalscope-0.1.0/src/metalscope/data/concepts/sycophantic/concept.json +30 -0
  140. metalscope-0.1.0/src/metalscope/data/concepts/sycophantic/neg.txt +16 -0
  141. metalscope-0.1.0/src/metalscope/data/concepts/sycophantic/pos.txt +16 -0
  142. metalscope-0.1.0/src/metalscope/data/concepts/sycophantic/task.json +485 -0
  143. metalscope-0.1.0/src/metalscope/data/concepts/sycophantic/writing.json +12 -0
  144. metalscope-0.1.0/src/metalscope/data/concepts/tender/concept.json +28 -0
  145. metalscope-0.1.0/src/metalscope/data/concepts/tender/neg.txt +16 -0
  146. metalscope-0.1.0/src/metalscope/data/concepts/tender/pos.txt +16 -0
  147. metalscope-0.1.0/src/metalscope/data/concepts/tender/task.json +133 -0
  148. metalscope-0.1.0/src/metalscope/data/concepts/terse/concept.json +28 -0
  149. metalscope-0.1.0/src/metalscope/data/concepts/terse/neg.txt +48 -0
  150. metalscope-0.1.0/src/metalscope/data/concepts/terse/pos.txt +48 -0
  151. metalscope-0.1.0/src/metalscope/data/concepts/terse/task.json +133 -0
  152. metalscope-0.1.0/src/metalscope/data/concepts/theatrical/concept.json +30 -0
  153. metalscope-0.1.0/src/metalscope/data/concepts/theatrical/neg.txt +16 -0
  154. metalscope-0.1.0/src/metalscope/data/concepts/theatrical/pos.txt +16 -0
  155. metalscope-0.1.0/src/metalscope/data/concepts/theatrical/task.json +485 -0
  156. metalscope-0.1.0/src/metalscope/data/concepts/theatrical/writing.json +11 -0
  157. metalscope-0.1.0/src/metalscope/data/concepts/uncooperative/concept.json +28 -0
  158. metalscope-0.1.0/src/metalscope/data/concepts/uncooperative/neg.txt +16 -0
  159. metalscope-0.1.0/src/metalscope/data/concepts/uncooperative/pos.txt +16 -0
  160. metalscope-0.1.0/src/metalscope/data/concepts/uncooperative/task.json +133 -0
  161. metalscope-0.1.0/src/metalscope/data/concepts/witty/concept.json +30 -0
  162. metalscope-0.1.0/src/metalscope/data/concepts/witty/neg.txt +11 -0
  163. metalscope-0.1.0/src/metalscope/data/concepts/witty/pos.txt +11 -0
  164. metalscope-0.1.0/src/metalscope/data/concepts/witty/task.json +477 -0
  165. metalscope-0.1.0/src/metalscope/data/concepts/witty/writing.json +13 -0
  166. metalscope-0.1.0/src/metalscope/doctor.py +128 -0
  167. metalscope-0.1.0/src/metalscope/ds4/LICENSE.ds4 +23 -0
  168. metalscope-0.1.0/src/metalscope/ds4/__init__.py +29 -0
  169. metalscope-0.1.0/src/metalscope/ds4/backend.py +358 -0
  170. metalscope-0.1.0/src/metalscope/ds4/build.py +161 -0
  171. metalscope-0.1.0/src/metalscope/ds4/frames.py +250 -0
  172. metalscope-0.1.0/src/metalscope/ds4/metalscope.patch +4000 -0
  173. metalscope-0.1.0/src/metalscope/ds4/proxy.py +460 -0
  174. metalscope-0.1.0/src/metalscope/ds4/vocab.py +217 -0
  175. metalscope-0.1.0/src/metalscope/edit.py +378 -0
  176. metalscope-0.1.0/src/metalscope/engines/__init__.py +142 -0
  177. metalscope-0.1.0/src/metalscope/engines/ds4.py +281 -0
  178. metalscope-0.1.0/src/metalscope/engines/mlx.py +326 -0
  179. metalscope-0.1.0/src/metalscope/experts.py +199 -0
  180. metalscope-0.1.0/src/metalscope/frontends/pi/args.ts +50 -0
  181. metalscope-0.1.0/src/metalscope/frontends/pi/backends.ts +279 -0
  182. metalscope-0.1.0/src/metalscope/frontends/pi/board.ts +1168 -0
  183. metalscope-0.1.0/src/metalscope/frontends/pi/commands.ts +275 -0
  184. metalscope-0.1.0/src/metalscope/frontends/pi/concept.ts +513 -0
  185. metalscope-0.1.0/src/metalscope/frontends/pi/dock.ts +1550 -0
  186. metalscope-0.1.0/src/metalscope/frontends/pi/draw.ts +417 -0
  187. metalscope-0.1.0/src/metalscope/frontends/pi/entries.ts +103 -0
  188. metalscope-0.1.0/src/metalscope/frontends/pi/expert.ts +546 -0
  189. metalscope-0.1.0/src/metalscope/frontends/pi/help.ts +239 -0
  190. metalscope-0.1.0/src/metalscope/frontends/pi/idle.ts +210 -0
  191. metalscope-0.1.0/src/metalscope/frontends/pi/index.ts +181 -0
  192. metalscope-0.1.0/src/metalscope/frontends/pi/jlens.ts +247 -0
  193. metalscope-0.1.0/src/metalscope/frontends/pi/job-runner.ts +267 -0
  194. metalscope-0.1.0/src/metalscope/frontends/pi/jobs.ts +414 -0
  195. metalscope-0.1.0/src/metalscope/frontends/pi/lights.ts +241 -0
  196. metalscope-0.1.0/src/metalscope/frontends/pi/lookup.ts +567 -0
  197. metalscope-0.1.0/src/metalscope/frontends/pi/package-lock.json +2537 -0
  198. metalscope-0.1.0/src/metalscope/frontends/pi/package.json +29 -0
  199. metalscope-0.1.0/src/metalscope/frontends/pi/provider.ts +439 -0
  200. metalscope-0.1.0/src/metalscope/frontends/pi/replay.ts +141 -0
  201. metalscope-0.1.0/src/metalscope/frontends/pi/scope.ts +73 -0
  202. metalscope-0.1.0/src/metalscope/frontends/pi/state.ts +690 -0
  203. metalscope-0.1.0/src/metalscope/frontends/pi/steer.ts +281 -0
  204. metalscope-0.1.0/src/metalscope/frontends/pi/steerdock.ts +391 -0
  205. metalscope-0.1.0/src/metalscope/frontends/pi/steerpage.ts +282 -0
  206. metalscope-0.1.0/src/metalscope/frontends/pi/telescope.ts +284 -0
  207. metalscope-0.1.0/src/metalscope/frontends/pi/test/backends.test.ts +256 -0
  208. metalscope-0.1.0/src/metalscope/frontends/pi/test/board-sizes.test.ts +632 -0
  209. metalscope-0.1.0/src/metalscope/frontends/pi/test/board.test.ts +3131 -0
  210. metalscope-0.1.0/src/metalscope/frontends/pi/test/commands.test.ts +561 -0
  211. metalscope-0.1.0/src/metalscope/frontends/pi/test/concept.test.ts +350 -0
  212. metalscope-0.1.0/src/metalscope/frontends/pi/test/cost.test.ts +252 -0
  213. metalscope-0.1.0/src/metalscope/frontends/pi/test/dense.test.ts +159 -0
  214. metalscope-0.1.0/src/metalscope/frontends/pi/test/dock.test.ts +108 -0
  215. metalscope-0.1.0/src/metalscope/frontends/pi/test/entries.test.ts +60 -0
  216. metalscope-0.1.0/src/metalscope/frontends/pi/test/expert.test.ts +636 -0
  217. metalscope-0.1.0/src/metalscope/frontends/pi/test/fixtures/concepts.ts +40 -0
  218. metalscope-0.1.0/src/metalscope/frontends/pi/test/fixtures/idle-seq.json +1 -0
  219. metalscope-0.1.0/src/metalscope/frontends/pi/test/headers.test.ts +143 -0
  220. metalscope-0.1.0/src/metalscope/frontends/pi/test/help.test.ts +148 -0
  221. metalscope-0.1.0/src/metalscope/frontends/pi/test/idle.test.ts +165 -0
  222. metalscope-0.1.0/src/metalscope/frontends/pi/test/jlens.test.ts +141 -0
  223. metalscope-0.1.0/src/metalscope/frontends/pi/test/job-runner.test.ts +419 -0
  224. metalscope-0.1.0/src/metalscope/frontends/pi/test/jobs.test.ts +503 -0
  225. metalscope-0.1.0/src/metalscope/frontends/pi/test/lens-off.test.ts +406 -0
  226. metalscope-0.1.0/src/metalscope/frontends/pi/test/lights.test.ts +206 -0
  227. metalscope-0.1.0/src/metalscope/frontends/pi/test/link.test.ts +621 -0
  228. metalscope-0.1.0/src/metalscope/frontends/pi/test/lookup.test.ts +1148 -0
  229. metalscope-0.1.0/src/metalscope/frontends/pi/test/provider.test.ts +285 -0
  230. metalscope-0.1.0/src/metalscope/frontends/pi/test/replay.test.ts +119 -0
  231. metalscope-0.1.0/src/metalscope/frontends/pi/test/scope.test.ts +47 -0
  232. metalscope-0.1.0/src/metalscope/frontends/pi/test/state.test.ts +637 -0
  233. metalscope-0.1.0/src/metalscope/frontends/pi/test/steer-page.test.ts +1012 -0
  234. metalscope-0.1.0/src/metalscope/frontends/pi/test/steer.test.ts +251 -0
  235. metalscope-0.1.0/src/metalscope/frontends/pi/test/stream.test.ts +1128 -0
  236. metalscope-0.1.0/src/metalscope/frontends/pi/test/telescope.test.ts +839 -0
  237. metalscope-0.1.0/src/metalscope/frontends/pi/test/widget.test.ts +383 -0
  238. metalscope-0.1.0/src/metalscope/frontends/pi/test.sh +45 -0
  239. metalscope-0.1.0/src/metalscope/frontends/pi/tsconfig.json +22 -0
  240. metalscope-0.1.0/src/metalscope/frontends/pi/widget.ts +688 -0
  241. metalscope-0.1.0/src/metalscope/gpulock.py +396 -0
  242. metalscope-0.1.0/src/metalscope/hooks.py +97 -0
  243. metalscope-0.1.0/src/metalscope/jlens/__init__.py +313 -0
  244. metalscope-0.1.0/src/metalscope/jlens/corpus.py +404 -0
  245. metalscope-0.1.0/src/metalscope/jlens/fit.py +344 -0
  246. metalscope-0.1.0/src/metalscope/layout.py +197 -0
  247. metalscope-0.1.0/src/metalscope/learn/__init__.py +13 -0
  248. metalscope-0.1.0/src/metalscope/learn/calibrate.py +918 -0
  249. metalscope-0.1.0/src/metalscope/learn/command.py +117 -0
  250. metalscope-0.1.0/src/metalscope/learn/decide.py +172 -0
  251. metalscope-0.1.0/src/metalscope/learn/gpu.py +270 -0
  252. metalscope-0.1.0/src/metalscope/learn/grade.py +106 -0
  253. metalscope-0.1.0/src/metalscope/learn/job.py +607 -0
  254. metalscope-0.1.0/src/metalscope/learn/lens_fit_gpu.py +488 -0
  255. metalscope-0.1.0/src/metalscope/learn/lens_job.py +95 -0
  256. metalscope-0.1.0/src/metalscope/learn/plan.py +159 -0
  257. metalscope-0.1.0/src/metalscope/learn/spawn.py +177 -0
  258. metalscope-0.1.0/src/metalscope/learn/state.py +191 -0
  259. metalscope-0.1.0/src/metalscope/learn/window.py +239 -0
  260. metalscope-0.1.0/src/metalscope/learn/writer.py +354 -0
  261. metalscope-0.1.0/src/metalscope/live.py +890 -0
  262. metalscope-0.1.0/src/metalscope/livecheck.py +382 -0
  263. metalscope-0.1.0/src/metalscope/livestream.py +366 -0
  264. metalscope-0.1.0/src/metalscope/lookup.py +322 -0
  265. metalscope-0.1.0/src/metalscope/middleware.py +267 -0
  266. metalscope-0.1.0/src/metalscope/models.py +503 -0
  267. metalscope-0.1.0/src/metalscope/mtp.py +128 -0
  268. metalscope-0.1.0/src/metalscope/omlx/__init__.py +4 -0
  269. metalscope-0.1.0/src/metalscope/omlx/admin.py +374 -0
  270. metalscope-0.1.0/src/metalscope/omlx/backend.py +172 -0
  271. metalscope-0.1.0/src/metalscope/omlx/boot.py +108 -0
  272. metalscope-0.1.0/src/metalscope/omlx/edit.py +176 -0
  273. metalscope-0.1.0/src/metalscope/omlx/install.py +244 -0
  274. metalscope-0.1.0/src/metalscope/omlx/load.py +24 -0
  275. metalscope-0.1.0/src/metalscope/omlx/patches.py +665 -0
  276. metalscope-0.1.0/src/metalscope/omlx/patches_mtp.py +125 -0
  277. metalscope-0.1.0/src/metalscope/retention.py +417 -0
  278. metalscope-0.1.0/src/metalscope/routing.py +317 -0
  279. metalscope-0.1.0/src/metalscope/share.py +615 -0
  280. metalscope-0.1.0/src/metalscope/steer.py +727 -0
  281. metalscope-0.1.0/src/metalscope/store.py +231 -0
  282. metalscope-0.1.0/src/metalscope/tally.py +713 -0
  283. metalscope-0.1.0/src/metalscope/tracer.py +277 -0
  284. metalscope-0.1.0/src/metalscope/vectors.py +198 -0
  285. metalscope-0.1.0/src/metalscope/web.py +999 -0
  286. metalscope-0.1.0/tests/__init__.py +9 -0
  287. metalscope-0.1.0/tests/conftest.py +98 -0
  288. metalscope-0.1.0/tests/helpers.py +333 -0
  289. metalscope-0.1.0/tests/test_backends.py +1135 -0
  290. metalscope-0.1.0/tests/test_bench.py +323 -0
  291. metalscope-0.1.0/tests/test_capture.py +459 -0
  292. metalscope-0.1.0/tests/test_cli.py +858 -0
  293. metalscope-0.1.0/tests/test_client.py +205 -0
  294. metalscope-0.1.0/tests/test_concepts.py +517 -0
  295. metalscope-0.1.0/tests/test_dock_constants.py +83 -0
  296. metalscope-0.1.0/tests/test_ds4.py +2211 -0
  297. metalscope-0.1.0/tests/test_ds4_build.py +198 -0
  298. metalscope-0.1.0/tests/test_ds4_engine.py +407 -0
  299. metalscope-0.1.0/tests/test_ds4_patch.py +174 -0
  300. metalscope-0.1.0/tests/test_engine_patch.py +160 -0
  301. metalscope-0.1.0/tests/test_engines.py +634 -0
  302. metalscope-0.1.0/tests/test_experts.py +46 -0
  303. metalscope-0.1.0/tests/test_gpu_release.py +201 -0
  304. metalscope-0.1.0/tests/test_grade.py +66 -0
  305. metalscope-0.1.0/tests/test_inkling2.py +1010 -0
  306. metalscope-0.1.0/tests/test_inkling2_omlx.py +226 -0
  307. metalscope-0.1.0/tests/test_jfit.py +184 -0
  308. metalscope-0.1.0/tests/test_layout.py +311 -0
  309. metalscope-0.1.0/tests/test_learn.py +3056 -0
  310. metalscope-0.1.0/tests/test_lens.py +191 -0
  311. metalscope-0.1.0/tests/test_lens_learn.py +685 -0
  312. metalscope-0.1.0/tests/test_live.py +1727 -0
  313. metalscope-0.1.0/tests/test_livecheck.py +284 -0
  314. metalscope-0.1.0/tests/test_lookup.py +818 -0
  315. metalscope-0.1.0/tests/test_models.py +583 -0
  316. metalscope-0.1.0/tests/test_omlx_admin.py +373 -0
  317. metalscope-0.1.0/tests/test_omlx_contract.py +423 -0
  318. metalscope-0.1.0/tests/test_omlx_hook.py +218 -0
  319. metalscope-0.1.0/tests/test_omlx_patches.py +1322 -0
  320. metalscope-0.1.0/tests/test_plain_install.py +113 -0
  321. metalscope-0.1.0/tests/test_retention.py +542 -0
  322. metalscope-0.1.0/tests/test_routing.py +285 -0
  323. metalscope-0.1.0/tests/test_routing_omlx.py +494 -0
  324. metalscope-0.1.0/tests/test_share.py +748 -0
  325. metalscope-0.1.0/tests/test_steer.py +760 -0
  326. metalscope-0.1.0/tests/test_steer_modes.py +217 -0
  327. metalscope-0.1.0/tests/test_steer_remove.py +212 -0
  328. metalscope-0.1.0/tests/test_tally.py +420 -0
  329. metalscope-0.1.0/tests/test_web.py +406 -0
  330. metalscope-0.1.0/tests/test_web_concepts.py +779 -0
  331. metalscope-0.1.0/uv.lock +984 -0
@@ -0,0 +1,15 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ traces/
5
+ reports/
6
+ blog/
7
+ .pytest_cache/
8
+ .DS_Store
9
+ .claude/
10
+ src/metalscope/frontends/pi/node_modules
11
+ src/metalscope/frontends/pi/.pi-modules
12
+ *.egg-info/
13
+ dist/
14
+ build/
15
+ node_modules/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nicolas Anastassacos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.5
2
+ Name: metalscope
3
+ Version: 0.1.0
4
+ Summary: Look inside local LLMs as they are served on Apple Silicon: traces, lenses, experts, steering (oMLX and ds4 backends, a Pi front end)
5
+ Project-URL: Homepage, https://github.com/nanastassacos/metalscope
6
+ Project-URL: Repository, https://github.com/nanastassacos/metalscope
7
+ Project-URL: Issues, https://github.com/nanastassacos/metalscope/issues
8
+ Author: Nicolas Anastassacos
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: activation-steering,apple-silicon,interpretability,llm,logit-lens,mixture-of-experts,mlx,steering-vectors
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Operating System :: MacOS :: MacOS X
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: mlx>=0.32; sys_platform == 'darwin' and platform_machine == 'arm64'
20
+ Requires-Dist: numpy>=2.4
21
+ Provides-Extra: dev
22
+ Requires-Dist: fastapi; extra == 'dev'
23
+ Requires-Dist: httpx; extra == 'dev'
24
+ Requires-Dist: mlx-lm; (sys_platform == 'darwin') and extra == 'dev'
25
+ Requires-Dist: pytest; extra == 'dev'
26
+ Requires-Dist: tokenizers; extra == 'dev'
27
+ Requires-Dist: uvicorn; extra == 'dev'
28
+ Provides-Extra: ds4
29
+ Requires-Dist: fastapi; extra == 'ds4'
30
+ Requires-Dist: httpx; extra == 'ds4'
31
+ Requires-Dist: tokenizers; extra == 'ds4'
32
+ Requires-Dist: uvicorn; extra == 'ds4'
33
+ Provides-Extra: share
34
+ Requires-Dist: huggingface-hub; extra == 'share'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # metalscope
38
+
39
+ metalscope lets you look inside the language models you run on your own Mac, while they answer you. It hooks into
40
+ the local model server itself and records every reply: which experts each token went to, what the model was about to
41
+ say at each layer, how sure it was. It can also steer a reply, adding a style such as "joyful" to the model's
42
+ inner state on every token, learned from a few dozen example texts and checked in real conversations. You watch it
43
+ in the [Pi](https://github.com/earendil-works/pi) coding agent or from the command line.
44
+
45
+ ## What it looks like
46
+
47
+ ![Pi on the left with a pancake recipe; metalscope's dock on the right, paused on one token](https://raw.githubusercontent.com/nanastassacos/metalscope/main/docs/dock.png)
48
+
49
+ **The dock.** Pi with the dock beside it, paused on one token of a pancake recipe. The model wrote "whip" as its
50
+ third choice (17%; "beat" 48%, "fold" 18%), and the J-lens at layer 46 still read "beat". MAP colours each token by
51
+ confidence, LENS shows the word forming layer by layer, TOKENS the ten likeliest, EXPERTS which experts fired and
52
+ RESIDUAL STREAM where a layer changed the model's state far more than usual.
53
+
54
+ ## Requirements
55
+
56
+ - A Mac with Apple Silicon and macOS.
57
+ - Memory for the model: Qwen3.6 35B at 4 bits is about 20 GB on disk, so a Mac with 32 GB or more. The largest
58
+ models here (Qwen3.8 Flash Next, DeepSeek V4.1 Flash) need 128 GB.
59
+ - [uv](https://docs.astral.sh/uv/) to install metalscope (`brew install uv`).
60
+ - Python 3.11 or newer (`uv tool install` fetches one; macOS's own `python3` is older).
61
+ - A server for the model, one of:
62
+ - [oMLX](https://github.com/jundot/omlx) 0.8.0, 0.8.2 or 0.8.3 (the versions metalscope is tested with: on another,
63
+ oMLX runs untraced; Inkling 2 needs 0.8.3). Open oMLX.app once and set an **API key** on its admin page, http://127.0.0.1:8008/admin.
64
+ It serves MLX models, Qwen3.6 among them.
65
+ - [ds4](https://github.com/antirez/ds4) at commit 5379c1c, for Qwen3.8 Flash Next and DeepSeek V4.1 Flash from
66
+ GGUF files. `metalscope ds4 install` fetches that commit and builds it with metalscope's patch (it needs Xcode's
67
+ command line tools: `xcode-select --install`).
68
+ Disk for its models: Qwen3.8 Flash Next Q4 is 165 GiB (about 177 GB), DeepSeek V4.1 Flash Q2 341 GiB (Q4 483 GiB).
69
+ ds4's `download_model.sh` fetches them with Hugging Face's `hf` CLI (`uv tool install huggingface_hub`).
70
+ - [Pi](https://github.com/earendil-works/pi), optional but recommended: a live dock beside the chat and
71
+ the `/scope`, `/steer`, `/concept` and `/jlens` commands. It needs [Node.js](https://nodejs.org) (`brew install node`).
72
+
73
+ ## Features
74
+
75
+ What each one shows, and roughly how. Which model each runs on: [What works on each model](https://github.com/nanastassacos/metalscope/blob/main/docs/backends.md#what-works-on-each-model).
76
+
77
+ - **Replies and probabilities.** The reply with every token coloured by the probability the model gave it, the ten
78
+ likeliest tokens at each step, and a map of the whole reply to jump to the unsure ones. Read from the model's own
79
+ output at each step.
80
+ - **Logit lens.** The word the model would say if it stopped at each layer: that layer's state put through the
81
+ model's own final norm and output head. Needs no setup.
82
+ - **Jacobian lens.** The same question answered with a matrix fitted per layer, which reads the middle layers better
83
+ and shows words the model holds but never says. One per model, fitted overnight (`/jlens learn`) or converted from
84
+ a published one.
85
+ - **Experts.** On a mixture-of-experts model, which experts each token went to at each layer, recorded from the
86
+ router as it chooses.
87
+ - **Residual stream.** How much each layer changed the model's running state at each token, with the spikes marked:
88
+ the places a layer changed it far more than it usually does.
89
+ - **Engram inspection.** On a model with an n-gram lookup, a second pass over a finished reply with the lookup
90
+ switched off, to see which tokens it helped.
91
+ - **Word swap (experimental).** Change one word of a reply and let the model carry on from there: the new word's
92
+ Jacobian lens direction is pushed into the model's state at that one token.
93
+ - **Steering.** A concept such as "pirate" or "calm" added to the model's state at one layer on every token,
94
+ thinking included. A concept is a direction learned on your model from pairs of example sentences, then tried at
95
+ several doses in short chats the model grades itself; the best dose becomes its default. 33 concepts ship, and
96
+ `/concept learn NAME` makes a new one.
97
+ - **Sharing.** `concept pack` writes a model's concepts to a folder to upload, like a LoRA adapter; `concept pull`
98
+ places one on a model you serve.
99
+
100
+ Everything shows live in Pi's dock; the same data is on the command line and over HTTP.
101
+
102
+ ## Quickstart: Qwen3.6 35B on oMLX
103
+
104
+ In oMLX's admin page, download `lmstudio-community/Qwen3.6-35B-A3B-MLX-4bit`; oMLX serves it as
105
+ `Qwen3.6-35B-A3B-MLX-4bit`. Then install metalscope and hook it into oMLX:
106
+
107
+ ```bash
108
+ uv tool install git+https://github.com/nanastassacos/metalscope
109
+ metalscope omlx install # the hook oMLX loads when it starts
110
+ metalscope omlx restart
111
+ metalscope doctor # checks every piece
112
+ ```
113
+
114
+ The example steers with `joyful`, a concept that ships with its texts. On our Mac its best dose on Qwen3.6 was
115
+ 0.5: 15 of 18 replies in test conversations were joyful and still made sense.
116
+
117
+ **With Pi** (`npm install -g @earendil-works/pi-coding-agent` and `metalscope pi install`, then start `pi`):
118
+
119
+ 1. `/model`, pick Qwen3.6-35B-A3B-MLX-4bit (picking it loads it).
120
+ 2. Chat a few messages. Pi's replies are traced, and steering sizes its doses from those traces (about 2,000
121
+ tokens of replies is enough).
122
+ 3. Look inside: `ctrl+\` opens the dock beside the chat. Send another message: each token's confidence, lens and
123
+ experts show as the reply is written.
124
+ 4. `/concept learn joyful`. It learns the vector from the shipped texts in a GPU job (oMLX unloads the model
125
+ meanwhile), then calibrates it in conversation (chat works meanwhile): about half an hour in all on Qwen3.6. The
126
+ widget above the editor shows the steps.
127
+ 5. `/steer joyful`: every reply from now on is steered at the calibrated dose. After a reply, `/steer replay` shows
128
+ it beside the same message answered unsteered. `/steer off` stops it.
129
+
130
+ **Without Pi**, the same from the command line:
131
+
132
+ ```bash
133
+ metalscope omlx Qwen3.6-35B-A3B-MLX-4bit # start oMLX with the model loaded
134
+ metalscope on # trace every request
135
+ # chat a few messages with any client: doses are sized from those traces
136
+ metalscope concept learn joyful Qwen3.6-35B-A3B-MLX-4bit # learn, then calibrate: about half an hour
137
+ metalscope steering on # let requests steer
138
+ ```
139
+
140
+ Then any client steers a request with one header (the key is the one you set in oMLX):
141
+
142
+ ```bash
143
+ curl http://127.0.0.1:8008/v1/chat/completions -H "Content-Type: application/json" \
144
+ -H "Authorization: Bearer YOUR_OMLX_API_KEY" \
145
+ -H "X-Scope-Steer: joyful" \
146
+ -d '{"model": "Qwen3.6-35B-A3B-MLX-4bit",
147
+ "messages": [{"role": "user", "content": "How was your weekend?"}]}'
148
+ ```
149
+
150
+ `concept learn` ends with the chat result and the next command:
151
+
152
+ ```
153
+ learned joyful on Qwen3.6-35B-A3B-MLX-4bit: steer layer L12
154
+ in chat: 15/18 good @0.5
155
+ next: metalscope steering on, then send the header X-Scope-Steer: joyful (in Pi: /steer joyful)
156
+ details: metalscope concept show joyful Qwen3.6-35B-A3B-MLX-4bit
157
+ ```
158
+
159
+ ## How it works
160
+
161
+ On oMLX, metalscope loads into oMLX's own Python through a small hook file and records
162
+ inside the real server, with its batching, prefix cache, speculative decoding and quantisation as they are. On ds4, a
163
+ patch to ds4's C and Metal code takes the same readings inside each step, and a proxy in front of it saves them. One
164
+ backend serves a model at a time: starting one's model frees the other's. `metalscope on` traces every request, the
165
+ `X-Scope-Trace: on` header one request; traces are saved under `~/.metalscope/traces/`.
166
+
167
+ ## Backends
168
+
169
+ Models metalscope has been run on, per backend (`TESTED` in `models.py`; a test keeps this table the same). A model
170
+ counts by its family: on oMLX the checkpoint's config.json `model_type` (as oMLX reads it), on ds4 its GGUF's
171
+ architecture (ds4 serves only these). Nothing gates on this list: Pi offers every chat model oMLX reports; one outside
172
+ it is marked `untested` in the dock's header (`no` in `metalscope doctor`'s table, `tested: false` in
173
+ `/scope/api/status`) and may trace, steer or edit
174
+ less well.
175
+
176
+ | backend | run on |
177
+ |---|---|
178
+ | oMLX | Qwen3.5 2B, Qwen3.8 27B (MTP), Qwen3.6 35B, Qwen3.8 Flash Next (MTP), Inkling 2 Mini (MTP) |
179
+ | ds4 | Qwen3.8 Flash Next, DeepSeek V4.1 Flash |
180
+
181
+ ## Documentation
182
+
183
+ - [Backends](https://github.com/nanastassacos/metalscope/blob/main/docs/backends.md): install in detail, upgrade and uninstall, who can reach it, oMLX, MTP models, ds4, checkpoints, updating the engines.
184
+ - [Front ends](https://github.com/nanastassacos/metalscope/blob/main/docs/dock.md): the live stream, the Jacobian lens, Pi and its dock, traces and their size budget.
185
+ - [Steering and concepts](https://github.com/nanastassacos/metalscope/blob/main/docs/steering.md): Pi's `/steer` and `/concept`, the `X-Scope-Steer` header, concept profiles, sharing.
186
+ - [Command reference](https://github.com/nanastassacos/metalscope/blob/main/docs/commands.md): the command line, Pi and the dock's keys.
187
+ - [Measurements](https://github.com/nanastassacos/metalscope/blob/main/docs/measurements.md): Inkling 2, what tracing costs, the jobs' times, lens fits.
188
+ - [Design and development](https://github.com/nanastassacos/metalscope/blob/main/docs/development.md): design rules, layout, development.
189
+
190
+ ## Acknowledgements
191
+
192
+ - [ds4](https://github.com/antirez/ds4) by antirez (MIT): metalscope's patch modifies it and carries its code.
193
+ - [oMLX](https://github.com/jundot/omlx) (Apache-2.0): the server metalscope hooks into.
194
+ - Anthropic's Jacobian lens ("Verbalizable Representations Form a Global Workspace in Language Models", 2026, and
195
+ [anthropics/jacobian-lens](https://github.com/anthropics/jacobian-lens)): `jlens/fit.py` reimplements its estimator.
196
+ - [Pi](https://github.com/earendil-works/pi) by earendil-works: the coding agent the front end extends.
197
+
198
+ ## Licence
199
+
200
+ - metalscope is MIT ([LICENSE](https://github.com/nanastassacos/metalscope/blob/main/LICENSE)).
201
+ - The ds4 patch applies to antirez's ds4, which is MIT. The patch carries ds4's code, so ds4's licence is copied
202
+ beside it: `src/metalscope/ds4/LICENSE.ds4`. metalscope's own changes in the patch are MIT.
203
+ - The concept texts in `src/metalscope/data/concepts` were written by models: Claude (Fable 5.1, Opus 5.5), Qwen3.6
204
+ 35B-A3B, Qwen3.8 Flash Next and DeepSeek V4.1 Flash. Each concept's `concept.json` (and `writing.json`, when it
205
+ has one) names its writer. They ship under metalscope's MIT licence.
@@ -0,0 +1,169 @@
1
+ # metalscope
2
+
3
+ metalscope lets you look inside the language models you run on your own Mac, while they answer you. It hooks into
4
+ the local model server itself and records every reply: which experts each token went to, what the model was about to
5
+ say at each layer, how sure it was. It can also steer a reply, adding a style such as "joyful" to the model's
6
+ inner state on every token, learned from a few dozen example texts and checked in real conversations. You watch it
7
+ in the [Pi](https://github.com/earendil-works/pi) coding agent or from the command line.
8
+
9
+ ## What it looks like
10
+
11
+ ![Pi on the left with a pancake recipe; metalscope's dock on the right, paused on one token](https://raw.githubusercontent.com/nanastassacos/metalscope/main/docs/dock.png)
12
+
13
+ **The dock.** Pi with the dock beside it, paused on one token of a pancake recipe. The model wrote "whip" as its
14
+ third choice (17%; "beat" 48%, "fold" 18%), and the J-lens at layer 46 still read "beat". MAP colours each token by
15
+ confidence, LENS shows the word forming layer by layer, TOKENS the ten likeliest, EXPERTS which experts fired and
16
+ RESIDUAL STREAM where a layer changed the model's state far more than usual.
17
+
18
+ ## Requirements
19
+
20
+ - A Mac with Apple Silicon and macOS.
21
+ - Memory for the model: Qwen3.6 35B at 4 bits is about 20 GB on disk, so a Mac with 32 GB or more. The largest
22
+ models here (Qwen3.8 Flash Next, DeepSeek V4.1 Flash) need 128 GB.
23
+ - [uv](https://docs.astral.sh/uv/) to install metalscope (`brew install uv`).
24
+ - Python 3.11 or newer (`uv tool install` fetches one; macOS's own `python3` is older).
25
+ - A server for the model, one of:
26
+ - [oMLX](https://github.com/jundot/omlx) 0.8.0, 0.8.2 or 0.8.3 (the versions metalscope is tested with: on another,
27
+ oMLX runs untraced; Inkling 2 needs 0.8.3). Open oMLX.app once and set an **API key** on its admin page, http://127.0.0.1:8008/admin.
28
+ It serves MLX models, Qwen3.6 among them.
29
+ - [ds4](https://github.com/antirez/ds4) at commit 5379c1c, for Qwen3.8 Flash Next and DeepSeek V4.1 Flash from
30
+ GGUF files. `metalscope ds4 install` fetches that commit and builds it with metalscope's patch (it needs Xcode's
31
+ command line tools: `xcode-select --install`).
32
+ Disk for its models: Qwen3.8 Flash Next Q4 is 165 GiB (about 177 GB), DeepSeek V4.1 Flash Q2 341 GiB (Q4 483 GiB).
33
+ ds4's `download_model.sh` fetches them with Hugging Face's `hf` CLI (`uv tool install huggingface_hub`).
34
+ - [Pi](https://github.com/earendil-works/pi), optional but recommended: a live dock beside the chat and
35
+ the `/scope`, `/steer`, `/concept` and `/jlens` commands. It needs [Node.js](https://nodejs.org) (`brew install node`).
36
+
37
+ ## Features
38
+
39
+ What each one shows, and roughly how. Which model each runs on: [What works on each model](https://github.com/nanastassacos/metalscope/blob/main/docs/backends.md#what-works-on-each-model).
40
+
41
+ - **Replies and probabilities.** The reply with every token coloured by the probability the model gave it, the ten
42
+ likeliest tokens at each step, and a map of the whole reply to jump to the unsure ones. Read from the model's own
43
+ output at each step.
44
+ - **Logit lens.** The word the model would say if it stopped at each layer: that layer's state put through the
45
+ model's own final norm and output head. Needs no setup.
46
+ - **Jacobian lens.** The same question answered with a matrix fitted per layer, which reads the middle layers better
47
+ and shows words the model holds but never says. One per model, fitted overnight (`/jlens learn`) or converted from
48
+ a published one.
49
+ - **Experts.** On a mixture-of-experts model, which experts each token went to at each layer, recorded from the
50
+ router as it chooses.
51
+ - **Residual stream.** How much each layer changed the model's running state at each token, with the spikes marked:
52
+ the places a layer changed it far more than it usually does.
53
+ - **Engram inspection.** On a model with an n-gram lookup, a second pass over a finished reply with the lookup
54
+ switched off, to see which tokens it helped.
55
+ - **Word swap (experimental).** Change one word of a reply and let the model carry on from there: the new word's
56
+ Jacobian lens direction is pushed into the model's state at that one token.
57
+ - **Steering.** A concept such as "pirate" or "calm" added to the model's state at one layer on every token,
58
+ thinking included. A concept is a direction learned on your model from pairs of example sentences, then tried at
59
+ several doses in short chats the model grades itself; the best dose becomes its default. 33 concepts ship, and
60
+ `/concept learn NAME` makes a new one.
61
+ - **Sharing.** `concept pack` writes a model's concepts to a folder to upload, like a LoRA adapter; `concept pull`
62
+ places one on a model you serve.
63
+
64
+ Everything shows live in Pi's dock; the same data is on the command line and over HTTP.
65
+
66
+ ## Quickstart: Qwen3.6 35B on oMLX
67
+
68
+ In oMLX's admin page, download `lmstudio-community/Qwen3.6-35B-A3B-MLX-4bit`; oMLX serves it as
69
+ `Qwen3.6-35B-A3B-MLX-4bit`. Then install metalscope and hook it into oMLX:
70
+
71
+ ```bash
72
+ uv tool install git+https://github.com/nanastassacos/metalscope
73
+ metalscope omlx install # the hook oMLX loads when it starts
74
+ metalscope omlx restart
75
+ metalscope doctor # checks every piece
76
+ ```
77
+
78
+ The example steers with `joyful`, a concept that ships with its texts. On our Mac its best dose on Qwen3.6 was
79
+ 0.5: 15 of 18 replies in test conversations were joyful and still made sense.
80
+
81
+ **With Pi** (`npm install -g @earendil-works/pi-coding-agent` and `metalscope pi install`, then start `pi`):
82
+
83
+ 1. `/model`, pick Qwen3.6-35B-A3B-MLX-4bit (picking it loads it).
84
+ 2. Chat a few messages. Pi's replies are traced, and steering sizes its doses from those traces (about 2,000
85
+ tokens of replies is enough).
86
+ 3. Look inside: `ctrl+\` opens the dock beside the chat. Send another message: each token's confidence, lens and
87
+ experts show as the reply is written.
88
+ 4. `/concept learn joyful`. It learns the vector from the shipped texts in a GPU job (oMLX unloads the model
89
+ meanwhile), then calibrates it in conversation (chat works meanwhile): about half an hour in all on Qwen3.6. The
90
+ widget above the editor shows the steps.
91
+ 5. `/steer joyful`: every reply from now on is steered at the calibrated dose. After a reply, `/steer replay` shows
92
+ it beside the same message answered unsteered. `/steer off` stops it.
93
+
94
+ **Without Pi**, the same from the command line:
95
+
96
+ ```bash
97
+ metalscope omlx Qwen3.6-35B-A3B-MLX-4bit # start oMLX with the model loaded
98
+ metalscope on # trace every request
99
+ # chat a few messages with any client: doses are sized from those traces
100
+ metalscope concept learn joyful Qwen3.6-35B-A3B-MLX-4bit # learn, then calibrate: about half an hour
101
+ metalscope steering on # let requests steer
102
+ ```
103
+
104
+ Then any client steers a request with one header (the key is the one you set in oMLX):
105
+
106
+ ```bash
107
+ curl http://127.0.0.1:8008/v1/chat/completions -H "Content-Type: application/json" \
108
+ -H "Authorization: Bearer YOUR_OMLX_API_KEY" \
109
+ -H "X-Scope-Steer: joyful" \
110
+ -d '{"model": "Qwen3.6-35B-A3B-MLX-4bit",
111
+ "messages": [{"role": "user", "content": "How was your weekend?"}]}'
112
+ ```
113
+
114
+ `concept learn` ends with the chat result and the next command:
115
+
116
+ ```
117
+ learned joyful on Qwen3.6-35B-A3B-MLX-4bit: steer layer L12
118
+ in chat: 15/18 good @0.5
119
+ next: metalscope steering on, then send the header X-Scope-Steer: joyful (in Pi: /steer joyful)
120
+ details: metalscope concept show joyful Qwen3.6-35B-A3B-MLX-4bit
121
+ ```
122
+
123
+ ## How it works
124
+
125
+ On oMLX, metalscope loads into oMLX's own Python through a small hook file and records
126
+ inside the real server, with its batching, prefix cache, speculative decoding and quantisation as they are. On ds4, a
127
+ patch to ds4's C and Metal code takes the same readings inside each step, and a proxy in front of it saves them. One
128
+ backend serves a model at a time: starting one's model frees the other's. `metalscope on` traces every request, the
129
+ `X-Scope-Trace: on` header one request; traces are saved under `~/.metalscope/traces/`.
130
+
131
+ ## Backends
132
+
133
+ Models metalscope has been run on, per backend (`TESTED` in `models.py`; a test keeps this table the same). A model
134
+ counts by its family: on oMLX the checkpoint's config.json `model_type` (as oMLX reads it), on ds4 its GGUF's
135
+ architecture (ds4 serves only these). Nothing gates on this list: Pi offers every chat model oMLX reports; one outside
136
+ it is marked `untested` in the dock's header (`no` in `metalscope doctor`'s table, `tested: false` in
137
+ `/scope/api/status`) and may trace, steer or edit
138
+ less well.
139
+
140
+ | backend | run on |
141
+ |---|---|
142
+ | oMLX | Qwen3.5 2B, Qwen3.8 27B (MTP), Qwen3.6 35B, Qwen3.8 Flash Next (MTP), Inkling 2 Mini (MTP) |
143
+ | ds4 | Qwen3.8 Flash Next, DeepSeek V4.1 Flash |
144
+
145
+ ## Documentation
146
+
147
+ - [Backends](https://github.com/nanastassacos/metalscope/blob/main/docs/backends.md): install in detail, upgrade and uninstall, who can reach it, oMLX, MTP models, ds4, checkpoints, updating the engines.
148
+ - [Front ends](https://github.com/nanastassacos/metalscope/blob/main/docs/dock.md): the live stream, the Jacobian lens, Pi and its dock, traces and their size budget.
149
+ - [Steering and concepts](https://github.com/nanastassacos/metalscope/blob/main/docs/steering.md): Pi's `/steer` and `/concept`, the `X-Scope-Steer` header, concept profiles, sharing.
150
+ - [Command reference](https://github.com/nanastassacos/metalscope/blob/main/docs/commands.md): the command line, Pi and the dock's keys.
151
+ - [Measurements](https://github.com/nanastassacos/metalscope/blob/main/docs/measurements.md): Inkling 2, what tracing costs, the jobs' times, lens fits.
152
+ - [Design and development](https://github.com/nanastassacos/metalscope/blob/main/docs/development.md): design rules, layout, development.
153
+
154
+ ## Acknowledgements
155
+
156
+ - [ds4](https://github.com/antirez/ds4) by antirez (MIT): metalscope's patch modifies it and carries its code.
157
+ - [oMLX](https://github.com/jundot/omlx) (Apache-2.0): the server metalscope hooks into.
158
+ - Anthropic's Jacobian lens ("Verbalizable Representations Form a Global Workspace in Language Models", 2026, and
159
+ [anthropics/jacobian-lens](https://github.com/anthropics/jacobian-lens)): `jlens/fit.py` reimplements its estimator.
160
+ - [Pi](https://github.com/earendil-works/pi) by earendil-works: the coding agent the front end extends.
161
+
162
+ ## Licence
163
+
164
+ - metalscope is MIT ([LICENSE](https://github.com/nanastassacos/metalscope/blob/main/LICENSE)).
165
+ - The ds4 patch applies to antirez's ds4, which is MIT. The patch carries ds4's code, so ds4's licence is copied
166
+ beside it: `src/metalscope/ds4/LICENSE.ds4`. metalscope's own changes in the patch are MIT.
167
+ - The concept texts in `src/metalscope/data/concepts` were written by models: Claude (Fable 5.1, Opus 5.5), Qwen3.6
168
+ 35B-A3B, Qwen3.8 Flash Next and DeepSeek V4.1 Flash. Each concept's `concept.json` (and `writing.json`, when it
169
+ has one) names its writer. They ship under metalscope's MIT licence.
@@ -0,0 +1,117 @@
1
+ # Command reference
2
+
3
+ The CLI (`metalscope --help` prints a shorter list; `scripts/omlx-python -m
4
+ metalscope.cli ...` runs the model-loading commands under oMLX's Python):
5
+
6
+ ```
7
+ # backends: oMLX, ds4 (one serves a model at a time; starting one's model frees the other's)
8
+ metalscope status [--json] # each backend: running or not, its models and their context, what is loaded,
9
+ # then how to switch, stop and get help (metalscope alone: the same)
10
+ metalscope help [COMMAND ...] # this list (--help), or one command's options: metalscope help ds4 start
11
+ metalscope --version # the installed version
12
+ metalscope omlx [MODEL] | omlx start [MODEL] | omlx stop # MODEL: ds4 stopped first, MODEL loaded
13
+ metalscope ds4 [MODEL|GGUF] | ds4 start [MODEL|GGUF] [--name ID] [--ctx N] [--no-wait] [-- DS4-SERVER OPTIONS] | ds4 stop
14
+ # in the background, at the model's full context; oMLX's model unloaded first
15
+ metalscope omlx install [--app PATH] | uninstall [--app PATH]
16
+ metalscope uninstall # back to stock: ds4 stopped, the oMLX hook and Pi package removed; data kept
17
+ metalscope omlx status | restart [--model ID] | load ID | unload ID | settings ID key=value ... [--url URL]
18
+ metalscope ds4 install [--dir DIR] [--source URL|PATH] [--force]
19
+ metalscope ds4 serve GGUF [--name ID] [--port 8009] [--ds4-dir DIR] [--ds4-port 8010] [-- DS4-SERVER OPTIONS]
20
+
21
+ # front ends: this command line, Pi
22
+ metalscope pi install | remove
23
+
24
+ # every day
25
+ metalscope on | off
26
+ metalscope doctor [--app PATH] [--live] # every piece; a table of the models: tested, J-lens, concepts, edit (info only)
27
+ # --live: a traced and a steered completion on each backend; exits 1 when a check fails
28
+ metalscope bench [--backend omlx|ds4] [--model ID] [--quick] [--rest 60] [--repeats 3] [--max-tokens 300] [--contexts 1000,4000,16000] [--json FILE]
29
+ metalscope steering on | off
30
+ metalscope traces | traces status # saved traces: total, count, size budget (Traces and their size budget)
31
+ metalscope traces keep SIZE # the budget, e.g. 20GB (default 10GB)
32
+ metalscope traces auto [on|off] # automatic cleanup past the budget (on by default); off: only prune removes
33
+ metalscope traces prune [--dry-run] [--older-than AGE | --all] # down to the budget now; or every trace older than
34
+ # AGE (7d, 2w, 12h), or all unprotected; --dry-run: say what would go
35
+ metalscope traces pin | unpin ID # never prune this trace, or let it go again
36
+ metalscope jobs [cancel [JOB]]
37
+ metalscope model list | show NAME | link SERVED CHECKPOINT
38
+ metalscope experts tally [NAME] [--rebuild|--clear] # the expert pages' tally from your chats: its size, count it afresh, delete it
39
+ metalscope experts layout [NAME] [--rebuild] # the expert map the dock's grids are laid out by: build it, or again
40
+ metalscope jlens status [NAME]
41
+ metalscope jlens learn NAME [PATH] --until HH:MM | --windows N [--fresh] [--model PATH] [--loader auto|mlx_lm|omlx] [--need-gb GB]
42
+ [--job ID] [--origin cli|pi]
43
+ metalscope jlens use NAME LENS
44
+ metalscope jlens on | off NAME
45
+ metalscope concept list [NAME]
46
+ metalscope concept show CONCEPT NAME
47
+ metalscope concept learn CONCEPT NAME [--description TEXT] [--corpus DIR] [--engine auto|mlx|ds4] [--url URL] [--model PATH]
48
+ [--loader auto|mlx_lm|omlx] [--writer MODEL] [--need-gb GB] [--sweep-layers ..] [--strengths 0.1,..] [--seed 0]
49
+ [--job ID] [--origin cli|pi]
50
+ metalscope concept calibrate CONCEPT NAME [--max-tokens 4000] [--url URL] [--job ID] [--origin cli|pi]
51
+ metalscope concept delete CONCEPT NAME [--yes] # its folder on NAME's checkpoint, texts included, to the trash
52
+ metalscope concept pack CKPT OUT_DIR [CONCEPT ... | --all] --base-model ID --license ID # a package to share (Sharing concepts)
53
+ [--license-name NAME] [--license-file PATH]
54
+ metalscope concept pull DIR|OWNER/REPO[@REV] SERVED # a package's concepts for SERVED
55
+
56
+ # research (measuring vectors and concepts by hand; Pi does not need these)
57
+ metalscope vector list NAME
58
+ metalscope vector norms NAME [--refresh]
59
+ ```
60
+
61
+ `metalscope bench` times the model a backend serves now: writing speed with tracing off and at each lens step, the
62
+ dock's one-word edit, and engram inspection after conversations of each `--contexts` length (`""`: none). It is best
63
+ effort: other requests to the server skew the numbers. Each measurement starts after a `--rest` (60 s; the Mac slows
64
+ itself under sustained load) and tracing off is measured again after the lens steps to show any drift. It marks a
65
+ part the model or server cannot do as n/a with the reason; `--json` keeps every repeat.
66
+
67
+ In Pi:
68
+
69
+ ```
70
+ /scope on | off | dock [mini | full] | jobs [cancel] | help [topic] | status
71
+ (alone: status; dock: open, step in, close, as ctrl+\ does;
72
+ mini: lights, MAP, SETTLING, m in the dock; jobs: the running or
73
+ last job, then the last ten; help scope: these forms)
74
+ /concept list | NAME | learn NAME [<what it means> | --corpus DIR]
75
+ | calibrate NAME | help [SUB] (alone: list; SUB help: one subcommand; learn asks first: on oMLX it
76
+ unloads the model (Qwen3.6: 26 min with calibration), on ds4 refuses chat while measuring
77
+ (V4.1: 1-1.5 h, then 3-6 h calibrating);
78
+ learn NAME alone: a library concept, or one with a saved description)
79
+ /steer <concept>[@dose] [dose] [+ <concept> …] | again | off | status | replay [<steer>] [temp:T] | help (alone: what is on)
80
+ a bare number or dose:D is the dose (/steer fluffy 0.5 = /steer fluffy@0.5 = /steer fluffy dose:0.5);
81
+ replay: your reply beside the same message unsteered, or under the steer given (at most 2,048 tokens)
82
+ /jlens | status | on | off | learn [PATH] until HH:MM [fresh] | learn [PATH] windows N [fresh] | use NAME | help
83
+ (alone: status; learn unloads the model until the deadline
84
+ and asks first)
85
+ ```
86
+
87
+ One word, one job: `/scope` looks at what the model does and at the GPU jobs, `/concept` is the
88
+ library of concepts and the jobs that make and calibrate them, `/steer`
89
+ changes the model, `/jlens` is the J-lens the readouts go through.
90
+ A new `/steer` replaces the one on; `/steer off` stops all of it.
91
+
92
+ The dock's keys (`?` in the dock explains the panel in focus):
93
+
94
+ | Where | Keys |
95
+ |---|---|
96
+ | Anywhere in Pi | `ctrl+\` opens the dock, again steps in, again closes it; `alt+i` steps straight in (where the terminal sends Option as Alt); `option+x` (`alt+x`) stops the running job, asked first |
97
+ | Stepped in | ←/→ or `h`/`l` a token, shift ←/→ ten, alt or cmd ←/→ or `H`/`L` a sentence, page up/down 25, home the first, `f` (or `end`) the newest, followed; `u`/`U` the next or previous unsure token |
98
+ | | `tab` the next panel, `?` what it shows, `s` the other lens (RESIDUAL STREAM: its view), `m` the mini dock, `6` the Steer page, `g` engram inspection, esc back, `q` out at once; the key line names the numbers that do something as one, `1-6 panel` |
99
+ | The board | `1` MAP, `2` LENS, `3` TOKENS, `4` EXPERTS, `5` RESIDUAL STREAM open that panel over the board; the same number again, the board |
100
+ | The one-panel board | `tab` cycles the panels; a number picks one |
101
+ | LENS | ↑/↓ a layer, `-` `+` fewer or more layers read, enter edits a word (experimental), `x` steering off |
102
+ | EXPERTS | `[`/`]` its layers; `4`, then enter a layer's page, then an expert's; `a` all chats or this session |
103
+ | RESIDUAL STREAM | `s` the next view (spikes, largest, reads: what the model records) |
104
+ | TOKENS | ↑/↓ the next or previous unsure token |
105
+ | Steer page | ↑/↓ a concept, ←/→ a dose, enter steers, `x` off, `d` then `y` deletes it (to the trash), `n`/`N` a turn of its test chats, `6` the board; with nothing learned, `l` links a same-shape model |
106
+ | Mini dock | `[`/`]` more layers, `s` the next RESIDUAL STREAM view, `m` the whole dock |
107
+
108
+ Editing a word on LENS (experimental): enter puts the cursor on the word the model wrote; ⌫ removes it, letters or
109
+ ↑/↓ type another over it, enter answers the reply again from that token with the edit at that one position, and
110
+ the new reply replaces the old in Pi's transcript. The newest reply only, and not one that ran tools; it needs the
111
+ server's `edit_at` (oMLX and ds4 have it) and a model the server takes the edit for.
112
+
113
+ `g` on a finished reply, where the model has an engram (Flash Next; V4.1 with disk streaming), reads the reply
114
+ again with and without it and marks in blue the tokens it helped; TOKENS shows each token's top choices without and
115
+ with it. `g` while it reads stops it; `g` again closes it. The reading holds the GPU, and on ds4 chat is refused
116
+ meanwhile. On V4.1 ds4 reads the reply a token at a time (about 0.07 s a token each reading, on top of the
117
+ conversation's read), and an inspection expected to take over 10 minutes is refused.
@@ -0,0 +1,71 @@
1
+ [project]
2
+ name = "metalscope"
3
+ version = "0.1.0"
4
+ description = "Look inside local LLMs as they are served on Apple Silicon: traces, lenses, experts, steering (oMLX and ds4 backends, a Pi front end)"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "Nicolas Anastassacos" }]
10
+ # Apple Silicon only: MLX runs on Metal.
11
+ classifiers = [
12
+ "Development Status :: 3 - Alpha",
13
+ "Operating System :: MacOS :: MacOS X",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.11",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
18
+ ]
19
+ keywords = ["interpretability", "steering-vectors", "activation-steering", "logit-lens", "mixture-of-experts", "mlx",
20
+ "apple-silicon", "llm"]
21
+ dependencies = ["numpy>=2.4", "mlx>=0.32; sys_platform == 'darwin' and platform_machine == 'arm64'"]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/nanastassacos/metalscope"
25
+ Repository = "https://github.com/nanastassacos/metalscope"
26
+ Issues = "https://github.com/nanastassacos/metalscope/issues"
27
+
28
+ [project.scripts]
29
+ metalscope = "metalscope.cli:main"
30
+
31
+ [project.optional-dependencies]
32
+ # The ds4 backend's proxy (metalscope ds4 serve): its web server and client, a GGUF's tokenizer.
33
+ ds4 = ["fastapi", "uvicorn", "httpx", "tokenizers"]
34
+ # concept pull OWNER/REPO: downloading a package from Hugging Face.
35
+ share = ["huggingface_hub"]
36
+ dev = ["mlx-lm; sys_platform == 'darwin'", "pytest", "fastapi", "httpx", "uvicorn", "tokenizers"]
37
+
38
+ [build-system]
39
+ requires = ["hatchling"]
40
+ build-backend = "hatchling.build"
41
+
42
+ [tool.hatch.build.targets.wheel]
43
+ # The package carries its front end (frontends/pi, TypeScript Pi loads as is) and the ds4 patch (ds4/metalscope.patch,
44
+ # with ds4's licence beside it, ds4/LICENSE.ds4).
45
+ packages = ["src/metalscope"]
46
+ exclude = ["**/node_modules", "**/.pi-modules", "src/metalscope/frontends/pi/test", "src/metalscope/frontends/pi/package-lock.json", "**/__pycache__"]
47
+
48
+ [tool.hatch.build.targets.sdist]
49
+ # A source release: the package, its tests, the readme, the command reference (a test reads it), licence and
50
+ # lockfile; none of the repository's working files.
51
+ only-include = ["src/metalscope", "tests", "pyproject.toml", "README.md", "docs/commands.md", "LICENSE", "uv.lock"]
52
+ exclude = ["**/node_modules", "**/.pi-modules", "**/__pycache__", "tests/test_make_public_tree.py"]
53
+
54
+ [tool.ruff]
55
+ target-version = "py311"
56
+ line-length = 120
57
+ extend-exclude = ["experiments"]
58
+
59
+ [tool.ruff.lint]
60
+ # Errors and likely bugs only; the ignored rules are the code's deliberate style (one-line ifs and lambdas, l as a
61
+ # layer index, raise without from, zip without strict, loop variables a closure reads on purpose).
62
+ select = ["E4", "E7", "E9", "F", "B"]
63
+ ignore = ["E701", "E702", "E731", "E741", "B023", "B904", "B905"]
64
+
65
+ [tool.ruff.lint.per-file-ignores]
66
+ "src/metalscope/concepts/__init__.py" = ["F401"] # the package's names, re-exported
67
+
68
+ [tool.pytest.ini_options]
69
+ testpaths = ["tests"]
70
+ pythonpath = ["."]
71
+ addopts = "-rs" # each skip and its reason: a test that never runs shows
@@ -0,0 +1 @@
1
+ """metalscope: trace, steer and read the models a local backend (oMLX, ds4) serves on Apple Silicon."""