yunshu 0.1.1__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 (688) hide show
  1. yunshu-0.1.1/.gitignore +73 -0
  2. yunshu-0.1.1/CHANGELOG.md +210 -0
  3. yunshu-0.1.1/LICENSE +202 -0
  4. yunshu-0.1.1/PKG-INFO +401 -0
  5. yunshu-0.1.1/README.md +305 -0
  6. yunshu-0.1.1/README.zh-CN.md +268 -0
  7. yunshu-0.1.1/README.zh-TW.md +268 -0
  8. yunshu-0.1.1/THIRD_PARTY_NOTICES.md +74 -0
  9. yunshu-0.1.1/docs/README.md +41 -0
  10. yunshu-0.1.1/docs/archive/legacy_vlm_loop/README.md +180 -0
  11. yunshu-0.1.1/examples/README.md +66 -0
  12. yunshu-0.1.1/examples/multimodal_embeddings.py +117 -0
  13. yunshu-0.1.1/examples/quickstart.py +87 -0
  14. yunshu-0.1.1/examples/talk.py +171 -0
  15. yunshu-0.1.1/examples/video.py +106 -0
  16. yunshu-0.1.1/examples/ws_stream.py +38 -0
  17. yunshu-0.1.1/packaging/homebrew/README.md +45 -0
  18. yunshu-0.1.1/pyproject.toml +248 -0
  19. yunshu-0.1.1/python/py.typed +0 -0
  20. yunshu-0.1.1/python/yunshu_cli/__init__.py +155 -0
  21. yunshu-0.1.1/python/yunshu_cli/__main__.py +5 -0
  22. yunshu-0.1.1/python/yunshu_cli/_output.py +80 -0
  23. yunshu-0.1.1/python/yunshu_cli/benchmark.py +586 -0
  24. yunshu-0.1.1/python/yunshu_cli/chat.py +308 -0
  25. yunshu-0.1.1/python/yunshu_cli/config.py +124 -0
  26. yunshu-0.1.1/python/yunshu_cli/diagnose.py +140 -0
  27. yunshu-0.1.1/python/yunshu_cli/doctor.py +459 -0
  28. yunshu-0.1.1/python/yunshu_cli/eval.py +684 -0
  29. yunshu-0.1.1/python/yunshu_cli/eval_data/gsm8k.jsonl +10 -0
  30. yunshu-0.1.1/python/yunshu_cli/eval_data/hellaswag.jsonl +5 -0
  31. yunshu-0.1.1/python/yunshu_cli/eval_data/humaneval.jsonl +5 -0
  32. yunshu-0.1.1/python/yunshu_cli/eval_data/mmlu.jsonl +20 -0
  33. yunshu-0.1.1/python/yunshu_cli/eval_data/truthfulqa.jsonl +5 -0
  34. yunshu-0.1.1/python/yunshu_cli/infer.py +508 -0
  35. yunshu-0.1.1/python/yunshu_cli/integrations/__init__.py +390 -0
  36. yunshu-0.1.1/python/yunshu_cli/model.py +526 -0
  37. yunshu-0.1.1/python/yunshu_cli/serve.py +392 -0
  38. yunshu-0.1.1/python/yunshu_cli/service.py +310 -0
  39. yunshu-0.1.1/python/yunshu_cli/status.py +145 -0
  40. yunshu-0.1.1/python/yunshu_client/__init__.py +145 -0
  41. yunshu-0.1.1/python/yunshu_control/__init__.py +20 -0
  42. yunshu-0.1.1/python/yunshu_control/audit_log.py +145 -0
  43. yunshu-0.1.1/python/yunshu_control/token_counter.py +140 -0
  44. yunshu-0.1.1/python/yunshu_engine/__init__.py +123 -0
  45. yunshu-0.1.1/python/yunshu_engine/active_tracking.py +93 -0
  46. yunshu-0.1.1/python/yunshu_engine/adaptive_batch.py +290 -0
  47. yunshu-0.1.1/python/yunshu_engine/adaptive_spec.py +213 -0
  48. yunshu-0.1.1/python/yunshu_engine/ane_embedding.py +1199 -0
  49. yunshu-0.1.1/python/yunshu_engine/audio_engine.py +1570 -0
  50. yunshu-0.1.1/python/yunshu_engine/auto_tuner.py +977 -0
  51. yunshu-0.1.1/python/yunshu_engine/batch_sampler.py +1060 -0
  52. yunshu-0.1.1/python/yunshu_engine/batched_engine.py +12035 -0
  53. yunshu-0.1.1/python/yunshu_engine/benchmark.py +490 -0
  54. yunshu-0.1.1/python/yunshu_engine/bfcl_eval.py +1342 -0
  55. yunshu-0.1.1/python/yunshu_engine/context_window.py +758 -0
  56. yunshu-0.1.1/python/yunshu_engine/cpu_gpu_overlap.py +419 -0
  57. yunshu-0.1.1/python/yunshu_engine/deltanet_inversion.py +316 -0
  58. yunshu-0.1.1/python/yunshu_engine/dflash_context.py +203 -0
  59. yunshu-0.1.1/python/yunshu_engine/dflash_tree.py +299 -0
  60. yunshu-0.1.1/python/yunshu_engine/diffusion_features.py +226 -0
  61. yunshu-0.1.1/python/yunshu_engine/diffusion_infra.py +567 -0
  62. yunshu-0.1.1/python/yunshu_engine/draft_vocab.py +193 -0
  63. yunshu-0.1.1/python/yunshu_engine/encoder_cache.py +297 -0
  64. yunshu-0.1.1/python/yunshu_engine/engine_core.py +3664 -0
  65. yunshu-0.1.1/python/yunshu_engine/exceptions.py +195 -0
  66. yunshu-0.1.1/python/yunshu_engine/forward_batch.py +527 -0
  67. yunshu-0.1.1/python/yunshu_engine/gateway_optimizer.py +682 -0
  68. yunshu-0.1.1/python/yunshu_engine/gemma4_assistant.py +779 -0
  69. yunshu-0.1.1/python/yunshu_engine/gpu_ngram.py +382 -0
  70. yunshu-0.1.1/python/yunshu_engine/grammar_bitmask.py +582 -0
  71. yunshu-0.1.1/python/yunshu_engine/grammar_constraint.py +1502 -0
  72. yunshu-0.1.1/python/yunshu_engine/hybrid_ssd_snapshot.py +247 -0
  73. yunshu-0.1.1/python/yunshu_engine/image_engine.py +3200 -0
  74. yunshu-0.1.1/python/yunshu_engine/image_pipeline.py +304 -0
  75. yunshu-0.1.1/python/yunshu_engine/inference_budget.py +303 -0
  76. yunshu-0.1.1/python/yunshu_engine/inflight_prefix_sharing.py +292 -0
  77. yunshu-0.1.1/python/yunshu_engine/json_schema.py +2495 -0
  78. yunshu-0.1.1/python/yunshu_engine/kernels/__init__.py +1 -0
  79. yunshu-0.1.1/python/yunshu_engine/kernels/batch_invariant.py +257 -0
  80. yunshu-0.1.1/python/yunshu_engine/kernels/gdn_rows.py +162 -0
  81. yunshu-0.1.1/python/yunshu_engine/kernels/int_code_linear.py +105 -0
  82. yunshu-0.1.1/python/yunshu_engine/kernels/lane_layers.py +112 -0
  83. yunshu-0.1.1/python/yunshu_engine/kernels/lane_linear.py +174 -0
  84. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/__init__.py +160 -0
  85. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/module_cache.py +71 -0
  86. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/moe_verify_gather.py +370 -0
  87. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/qwen35_gdn_prework.py +2069 -0
  88. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/qwen35_gdn_verify_fused.py +488 -0
  89. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/qwen35_packed_linear.py +831 -0
  90. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/qwen35_verify_linear.py +74 -0
  91. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/qwen35_verify_qmm.py +1579 -0
  92. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/qwen35_verify_sdpa_split.py +973 -0
  93. yunshu-0.1.1/python/yunshu_engine/kernels/omlx/row_exact_qmv.py +623 -0
  94. yunshu-0.1.1/python/yunshu_engine/kernels/ragged_attention.py +832 -0
  95. yunshu-0.1.1/python/yunshu_engine/kernels/ragged_kv.py +627 -0
  96. yunshu-0.1.1/python/yunshu_engine/kernels/tensorfold/__init__.py +7 -0
  97. yunshu-0.1.1/python/yunshu_engine/kernels/tensorfold/inputs.py +33 -0
  98. yunshu-0.1.1/python/yunshu_engine/kernels/tensorfold/lane_qmm.py +487 -0
  99. yunshu-0.1.1/python/yunshu_engine/kernels/tensorfold/lane_widen.py +145 -0
  100. yunshu-0.1.1/python/yunshu_engine/kernels/verify_select.py +324 -0
  101. yunshu-0.1.1/python/yunshu_engine/kv_lifecycle.py +443 -0
  102. yunshu-0.1.1/python/yunshu_engine/kv_optimizations.py +1323 -0
  103. yunshu-0.1.1/python/yunshu_engine/kv_prefix_cache.py +1710 -0
  104. yunshu-0.1.1/python/yunshu_engine/kv_prefix_compression.py +868 -0
  105. yunshu-0.1.1/python/yunshu_engine/kv_quantization.py +461 -0
  106. yunshu-0.1.1/python/yunshu_engine/lora_manager.py +1122 -0
  107. yunshu-0.1.1/python/yunshu_engine/mamba_cache.py +1210 -0
  108. yunshu-0.1.1/python/yunshu_engine/mcp_client.py +483 -0
  109. yunshu-0.1.1/python/yunshu_engine/memory_aware_scheduler.py +449 -0
  110. yunshu-0.1.1/python/yunshu_engine/memory_guard.py +273 -0
  111. yunshu-0.1.1/python/yunshu_engine/memory_monitor.py +282 -0
  112. yunshu-0.1.1/python/yunshu_engine/message_adapter.py +624 -0
  113. yunshu-0.1.1/python/yunshu_engine/mlx_executor.py +139 -0
  114. yunshu-0.1.1/python/yunshu_engine/mlx_vlm_patches.py +112 -0
  115. yunshu-0.1.1/python/yunshu_engine/mlxvlm_mtp.py +407 -0
  116. yunshu-0.1.1/python/yunshu_engine/model_backend.py +160 -0
  117. yunshu-0.1.1/python/yunshu_engine/model_card.py +862 -0
  118. yunshu-0.1.1/python/yunshu_engine/model_discovery.py +283 -0
  119. yunshu-0.1.1/python/yunshu_engine/model_manager.py +1355 -0
  120. yunshu-0.1.1/python/yunshu_engine/model_optimizations.py +1355 -0
  121. yunshu-0.1.1/python/yunshu_engine/model_patches.py +210 -0
  122. yunshu-0.1.1/python/yunshu_engine/model_preprocessor.py +887 -0
  123. yunshu-0.1.1/python/yunshu_engine/model_registry.py +135 -0
  124. yunshu-0.1.1/python/yunshu_engine/model_settings.py +196 -0
  125. yunshu-0.1.1/python/yunshu_engine/moe_optimization.py +148 -0
  126. yunshu-0.1.1/python/yunshu_engine/mrope.py +243 -0
  127. yunshu-0.1.1/python/yunshu_engine/mtp_decoder.py +503 -0
  128. yunshu-0.1.1/python/yunshu_engine/mtp_lane.py +267 -0
  129. yunshu-0.1.1/python/yunshu_engine/mtp_patch.py +290 -0
  130. yunshu-0.1.1/python/yunshu_engine/mtp_tree.py +347 -0
  131. yunshu-0.1.1/python/yunshu_engine/n_confirmed_patch.py +348 -0
  132. yunshu-0.1.1/python/yunshu_engine/ngram_proposer.py +462 -0
  133. yunshu-0.1.1/python/yunshu_engine/ocr_engine.py +262 -0
  134. yunshu-0.1.1/python/yunshu_engine/omni_engine.py +503 -0
  135. yunshu-0.1.1/python/yunshu_engine/output_collector.py +156 -0
  136. yunshu-0.1.1/python/yunshu_engine/output_parser.py +356 -0
  137. yunshu-0.1.1/python/yunshu_engine/paged_scheduler.py +448 -0
  138. yunshu-0.1.1/python/yunshu_engine/paths.py +55 -0
  139. yunshu-0.1.1/python/yunshu_engine/prefill_progress.py +132 -0
  140. yunshu-0.1.1/python/yunshu_engine/priority_queue.py +194 -0
  141. yunshu-0.1.1/python/yunshu_engine/process_memory_enforcer.py +195 -0
  142. yunshu-0.1.1/python/yunshu_engine/prompt_cache.py +406 -0
  143. yunshu-0.1.1/python/yunshu_engine/reasoning_parser.py +288 -0
  144. yunshu-0.1.1/python/yunshu_engine/request.py +322 -0
  145. yunshu-0.1.1/python/yunshu_engine/request_lifecycle.py +548 -0
  146. yunshu-0.1.1/python/yunshu_engine/request_tracker.py +200 -0
  147. yunshu-0.1.1/python/yunshu_engine/roofline.py +857 -0
  148. yunshu-0.1.1/python/yunshu_engine/round_driver/__init__.py +0 -0
  149. yunshu-0.1.1/python/yunshu_engine/round_driver/allocate.py +118 -0
  150. yunshu-0.1.1/python/yunshu_engine/round_driver/batch.py +367 -0
  151. yunshu-0.1.1/python/yunshu_engine/round_driver/driver.py +509 -0
  152. yunshu-0.1.1/python/yunshu_engine/round_driver/forward.py +147 -0
  153. yunshu-0.1.1/python/yunshu_engine/round_driver/mtp.py +206 -0
  154. yunshu-0.1.1/python/yunshu_engine/scheduler.py +5167 -0
  155. yunshu-0.1.1/python/yunshu_engine/scheduler_mixins.py +532 -0
  156. yunshu-0.1.1/python/yunshu_engine/server_metrics.py +432 -0
  157. yunshu-0.1.1/python/yunshu_engine/settings.py +498 -0
  158. yunshu-0.1.1/python/yunshu_engine/spec_draft_verifier.py +733 -0
  159. yunshu-0.1.1/python/yunshu_engine/spec_interface.py +897 -0
  160. yunshu-0.1.1/python/yunshu_engine/spec_prefill.py +512 -0
  161. yunshu-0.1.1/python/yunshu_engine/spec_prefill_engine.py +297 -0
  162. yunshu-0.1.1/python/yunshu_engine/spec_proposer.py +163 -0
  163. yunshu-0.1.1/python/yunshu_engine/spec_schedule.py +174 -0
  164. yunshu-0.1.1/python/yunshu_engine/spec_select.py +109 -0
  165. yunshu-0.1.1/python/yunshu_engine/speculative_decoder.py +1402 -0
  166. yunshu-0.1.1/python/yunshu_engine/ssd_kv_cache.py +980 -0
  167. yunshu-0.1.1/python/yunshu_engine/staged_pipeline.py +607 -0
  168. yunshu-0.1.1/python/yunshu_engine/streaming_optimizer.py +998 -0
  169. yunshu-0.1.1/python/yunshu_engine/suffix_proposer.py +498 -0
  170. yunshu-0.1.1/python/yunshu_engine/teacache.py +247 -0
  171. yunshu-0.1.1/python/yunshu_engine/telemetry.py +198 -0
  172. yunshu-0.1.1/python/yunshu_engine/text_utils.py +448 -0
  173. yunshu-0.1.1/python/yunshu_engine/thinking_budget.py +342 -0
  174. yunshu-0.1.1/python/yunshu_engine/token_scheduler.py +1160 -0
  175. yunshu-0.1.1/python/yunshu_engine/tool_arguments.py +145 -0
  176. yunshu-0.1.1/python/yunshu_engine/tool_call_streamer.py +181 -0
  177. yunshu-0.1.1/python/yunshu_engine/tool_format.py +458 -0
  178. yunshu-0.1.1/python/yunshu_engine/tracing.py +971 -0
  179. yunshu-0.1.1/python/yunshu_engine/tree_verify.py +809 -0
  180. yunshu-0.1.1/python/yunshu_engine/turbo_quant.py +209 -0
  181. yunshu-0.1.1/python/yunshu_engine/two_batch_overlap.py +571 -0
  182. yunshu-0.1.1/python/yunshu_engine/types.py +33 -0
  183. yunshu-0.1.1/python/yunshu_engine/utils/__init__.py +37 -0
  184. yunshu-0.1.1/python/yunshu_engine/utils/hardware.py +503 -0
  185. yunshu-0.1.1/python/yunshu_engine/vad.py +184 -0
  186. yunshu-0.1.1/python/yunshu_engine/version.py +34 -0
  187. yunshu-0.1.1/python/yunshu_engine/vl_embedding_engine.py +173 -0
  188. yunshu-0.1.1/python/yunshu_engine/vlm_batch_runner.py +1015 -0
  189. yunshu-0.1.1/python/yunshu_engine/vlm_engine.py +3118 -0
  190. yunshu-0.1.1/python/yunshu_engine/voice_pipeline.py +285 -0
  191. yunshu-0.1.1/python/yunshu_engine/zimage_controlnet.py +151 -0
  192. yunshu-0.1.1/python/yunshu_gateway/__init__.py +0 -0
  193. yunshu-0.1.1/python/yunshu_gateway/engine/__init__.py +247 -0
  194. yunshu-0.1.1/python/yunshu_gateway/engine/engine.py +10 -0
  195. yunshu-0.1.1/python/yunshu_gateway/error_envelope.py +103 -0
  196. yunshu-0.1.1/python/yunshu_gateway/error_hints.py +98 -0
  197. yunshu-0.1.1/python/yunshu_gateway/main.py +1123 -0
  198. yunshu-0.1.1/python/yunshu_gateway/middleware/__init__.py +18 -0
  199. yunshu-0.1.1/python/yunshu_gateway/middleware/auth.py +184 -0
  200. yunshu-0.1.1/python/yunshu_gateway/middleware/disconnect.py +60 -0
  201. yunshu-0.1.1/python/yunshu_gateway/middleware/gateway_optimizer.py +157 -0
  202. yunshu-0.1.1/python/yunshu_gateway/middleware/metrics.py +568 -0
  203. yunshu-0.1.1/python/yunshu_gateway/middleware/metrics_aggregator.py +366 -0
  204. yunshu-0.1.1/python/yunshu_gateway/middleware/prometheus_exporter.py +824 -0
  205. yunshu-0.1.1/python/yunshu_gateway/middleware/rate_limit.py +219 -0
  206. yunshu-0.1.1/python/yunshu_gateway/middleware/request_logging.py +147 -0
  207. yunshu-0.1.1/python/yunshu_gateway/model_card_formats.py +281 -0
  208. yunshu-0.1.1/python/yunshu_gateway/model_cards.py +91 -0
  209. yunshu-0.1.1/python/yunshu_gateway/model_guards.py +79 -0
  210. yunshu-0.1.1/python/yunshu_gateway/realtime_ga.py +220 -0
  211. yunshu-0.1.1/python/yunshu_gateway/routers/__init__.py +0 -0
  212. yunshu-0.1.1/python/yunshu_gateway/routers/anthropic.py +2918 -0
  213. yunshu-0.1.1/python/yunshu_gateway/routers/audio.py +1169 -0
  214. yunshu-0.1.1/python/yunshu_gateway/routers/cancel.py +214 -0
  215. yunshu-0.1.1/python/yunshu_gateway/routers/chat.py +4434 -0
  216. yunshu-0.1.1/python/yunshu_gateway/routers/completions.py +1693 -0
  217. yunshu-0.1.1/python/yunshu_gateway/routers/embeddings.py +725 -0
  218. yunshu-0.1.1/python/yunshu_gateway/routers/images.py +731 -0
  219. yunshu-0.1.1/python/yunshu_gateway/routers/mcp.py +1044 -0
  220. yunshu-0.1.1/python/yunshu_gateway/routers/models.py +397 -0
  221. yunshu-0.1.1/python/yunshu_gateway/routers/monitoring.py +1092 -0
  222. yunshu-0.1.1/python/yunshu_gateway/routers/ocr.py +340 -0
  223. yunshu-0.1.1/python/yunshu_gateway/routers/ollama.py +546 -0
  224. yunshu-0.1.1/python/yunshu_gateway/routers/omni.py +292 -0
  225. yunshu-0.1.1/python/yunshu_gateway/routers/realtime.py +3348 -0
  226. yunshu-0.1.1/python/yunshu_gateway/routers/responses.py +2925 -0
  227. yunshu-0.1.1/python/yunshu_gateway/routers/scoring.py +922 -0
  228. yunshu-0.1.1/python/yunshu_gateway/routers/stream_ws.py +57 -0
  229. yunshu-0.1.1/python/yunshu_gateway/routers/tokenize.py +292 -0
  230. yunshu-0.1.1/python/yunshu_gateway/routers/yunshu.py +310 -0
  231. yunshu-0.1.1/python/yunshu_gateway/schemas/__init__.py +0 -0
  232. yunshu-0.1.1/python/yunshu_gateway/streaming.py +1210 -0
  233. yunshu-0.1.1/python/yunshu_gateway/usage_context.py +47 -0
  234. yunshu-0.1.1/python/yunshu_gateway/ws_transport.py +600 -0
  235. yunshu-0.1.1/python/yunshu_gateway/x_yunshu.py +647 -0
  236. yunshu-0.1.1/python/yunshu_kv/__init__.py +38 -0
  237. yunshu-0.1.1/python/yunshu_kv/block.py +536 -0
  238. yunshu-0.1.1/python/yunshu_kv/block_table.py +170 -0
  239. yunshu-0.1.1/python/yunshu_kv/boundary_snapshot.py +354 -0
  240. yunshu-0.1.1/python/yunshu_kv/cache_events.py +125 -0
  241. yunshu-0.1.1/python/yunshu_kv/compression.py +188 -0
  242. yunshu-0.1.1/python/yunshu_kv/hash.py +71 -0
  243. yunshu-0.1.1/python/yunshu_kv/manager.py +1073 -0
  244. yunshu-0.1.1/python/yunshu_kv/mlx_cache.py +251 -0
  245. yunshu-0.1.1/python/yunshu_kv/model_cache_config.py +144 -0
  246. yunshu-0.1.1/python/yunshu_kv/radix_attention.py +719 -0
  247. yunshu-0.1.1/python/yunshu_kv/serialization.py +510 -0
  248. yunshu-0.1.1/python/yunshu_kv/ssd_sqlite_store.py +551 -0
  249. yunshu-0.1.1/python/yunshu_kv/thinking_segment.py +637 -0
  250. yunshu-0.1.1/python/yunshu_kv/tiered.py +1259 -0
  251. yunshu-0.1.1/python/yunshu_kv/warm_tier.py +325 -0
  252. yunshu-0.1.1/scripts/README.md +38 -0
  253. yunshu-0.1.1/tests/__init__.py +0 -0
  254. yunshu-0.1.1/tests/e2e/conftest.py +28 -0
  255. yunshu-0.1.1/tests/e2e/test_e2e_full.py +643 -0
  256. yunshu-0.1.1/tests/integration/__init__.py +0 -0
  257. yunshu-0.1.1/tests/integration/test_dflash_spec_parity.py +235 -0
  258. yunshu-0.1.1/tests/integration/test_fair_scheduler_stress.py +224 -0
  259. yunshu-0.1.1/tests/integration/test_mtp.py +308 -0
  260. yunshu-0.1.1/tests/integration/test_mtp_tree_spec_parity.py +167 -0
  261. yunshu-0.1.1/tests/integration/test_ragged_spec_parity.py +211 -0
  262. yunshu-0.1.1/tests/integration/test_tree_spec_parity.py +289 -0
  263. yunshu-0.1.1/tests/unit/__init__.py +0 -0
  264. yunshu-0.1.1/tests/unit/conftest.py +96 -0
  265. yunshu-0.1.1/tests/unit/test_active_tracking.py +108 -0
  266. yunshu-0.1.1/tests/unit/test_adaptive_batch.py +386 -0
  267. yunshu-0.1.1/tests/unit/test_adaptive_defaults.py +156 -0
  268. yunshu-0.1.1/tests/unit/test_adaptive_spec.py +462 -0
  269. yunshu-0.1.1/tests/unit/test_admin_monitoring.py +28 -0
  270. yunshu-0.1.1/tests/unit/test_ane.py +34 -0
  271. yunshu-0.1.1/tests/unit/test_ane_drafter.py +257 -0
  272. yunshu-0.1.1/tests/unit/test_ane_embedding.py +301 -0
  273. yunshu-0.1.1/tests/unit/test_ane_hf_id_pooling.py +71 -0
  274. yunshu-0.1.1/tests/unit/test_anthropic.py +1060 -0
  275. yunshu-0.1.1/tests/unit/test_anthropic_budget_lt_maxtokens.py +42 -0
  276. yunshu-0.1.1/tests/unit/test_anthropic_cache_creation_revived.py +60 -0
  277. yunshu-0.1.1/tests/unit/test_anthropic_cache_usage.py +84 -0
  278. yunshu-0.1.1/tests/unit/test_anthropic_enhanced.py +366 -0
  279. yunshu-0.1.1/tests/unit/test_anthropic_multi_toolcall.py +43 -0
  280. yunshu-0.1.1/tests/unit/test_anthropic_stream_batched_flush.py +47 -0
  281. yunshu-0.1.1/tests/unit/test_anthropic_stream_multitool.py +48 -0
  282. yunshu-0.1.1/tests/unit/test_anthropic_thinking_unconditional.py +46 -0
  283. yunshu-0.1.1/tests/unit/test_anthropic_tool_call.py +85 -0
  284. yunshu-0.1.1/tests/unit/test_anthropic_tool_result.py +101 -0
  285. yunshu-0.1.1/tests/unit/test_anthropic_tool_result_image.py +80 -0
  286. yunshu-0.1.1/tests/unit/test_api_conformance.py +134 -0
  287. yunshu-0.1.1/tests/unit/test_api_extensions.py +442 -0
  288. yunshu-0.1.1/tests/unit/test_array_trailing_comma.py +58 -0
  289. yunshu-0.1.1/tests/unit/test_asr_temperature_gating.py +28 -0
  290. yunshu-0.1.1/tests/unit/test_assistant_prefill.py +108 -0
  291. yunshu-0.1.1/tests/unit/test_audio_24bit_vad.py +52 -0
  292. yunshu-0.1.1/tests/unit/test_audio_dsp_robustness.py +68 -0
  293. yunshu-0.1.1/tests/unit/test_audio_engine.py +453 -0
  294. yunshu-0.1.1/tests/unit/test_audio_model_select.py +89 -0
  295. yunshu-0.1.1/tests/unit/test_audio_speech_opus_mime.py +26 -0
  296. yunshu-0.1.1/tests/unit/test_audio_verbose_segments.py +51 -0
  297. yunshu-0.1.1/tests/unit/test_audit.py +100 -0
  298. yunshu-0.1.1/tests/unit/test_auth_inference_open.py +51 -0
  299. yunshu-0.1.1/tests/unit/test_auto_tuner.py +605 -0
  300. yunshu-0.1.1/tests/unit/test_bare_string_image_url.py +56 -0
  301. yunshu-0.1.1/tests/unit/test_batch_chat_toolcall_image_lora_rounding.py +59 -0
  302. yunshu-0.1.1/tests/unit/test_batch_legacy_tenant_cancel_nullable_schema.py +103 -0
  303. yunshu-0.1.1/tests/unit/test_batch_realtime_audio_out_ane_refusal_image_url.py +95 -0
  304. yunshu-0.1.1/tests/unit/test_batch_realtime_history_completions_suffix_anthropic_toolchoice.py +77 -0
  305. yunshu-0.1.1/tests/unit/test_batch_realtime_protocol_middleware_admin.py +95 -0
  306. yunshu-0.1.1/tests/unit/test_batch_responses_cancel_gemma4_cache_eviction.py +46 -0
  307. yunshu-0.1.1/tests/unit/test_batch_sampler.py +968 -0
  308. yunshu-0.1.1/tests/unit/test_batch_spec_integration.py +842 -0
  309. yunshu-0.1.1/tests/unit/test_batch_thinking_budget_engine_loop_ocr_sts.py +61 -0
  310. yunshu-0.1.1/tests/unit/test_batch_video_placeholder_kv_eviction_responses_fn.py +92 -0
  311. yunshu-0.1.1/tests/unit/test_batch_window.py +36 -0
  312. yunshu-0.1.1/tests/unit/test_batched_engine_spec_paths.py +550 -0
  313. yunshu-0.1.1/tests/unit/test_benchmark.py +550 -0
  314. yunshu-0.1.1/tests/unit/test_best_of_echo_ranking.py +64 -0
  315. yunshu-0.1.1/tests/unit/test_bfcl_eval.py +454 -0
  316. yunshu-0.1.1/tests/unit/test_bfcl_real.py +345 -0
  317. yunshu-0.1.1/tests/unit/test_boundary_snapshot.py +134 -0
  318. yunshu-0.1.1/tests/unit/test_call_contracts.py +76 -0
  319. yunshu-0.1.1/tests/unit/test_cancel_and_prefill_progress.py +599 -0
  320. yunshu-0.1.1/tests/unit/test_chat.py +555 -0
  321. yunshu-0.1.1/tests/unit/test_chat_no_dead_streambuf.py +18 -0
  322. yunshu-0.1.1/tests/unit/test_chat_reasoning_tokens.py +140 -0
  323. yunshu-0.1.1/tests/unit/test_chat_single_model_name.py +91 -0
  324. yunshu-0.1.1/tests/unit/test_chat_template_null_content.py +92 -0
  325. yunshu-0.1.1/tests/unit/test_chunked_prefill_hardening.py +707 -0
  326. yunshu-0.1.1/tests/unit/test_cli.py +200 -0
  327. yunshu-0.1.1/tests/unit/test_cli_setup.py +351 -0
  328. yunshu-0.1.1/tests/unit/test_client_disconnect_watch.py +95 -0
  329. yunshu-0.1.1/tests/unit/test_completion_batch_size_sync.py +79 -0
  330. yunshu-0.1.1/tests/unit/test_completions.py +231 -0
  331. yunshu-0.1.1/tests/unit/test_completions_echo_bos_logprobs.py +111 -0
  332. yunshu-0.1.1/tests/unit/test_completions_echo_logprobs.py +89 -0
  333. yunshu-0.1.1/tests/unit/test_completions_prompt_tokens_tenant_settle.py +43 -0
  334. yunshu-0.1.1/tests/unit/test_completions_streaming_echo_logprobs.py +89 -0
  335. yunshu-0.1.1/tests/unit/test_completions_suffix_billing.py +28 -0
  336. yunshu-0.1.1/tests/unit/test_compression.py +51 -0
  337. yunshu-0.1.1/tests/unit/test_context_window.py +412 -0
  338. yunshu-0.1.1/tests/unit/test_control_image_bad_b64.py +75 -0
  339. yunshu-0.1.1/tests/unit/test_count_tokens_and_models.py +35 -0
  340. yunshu-0.1.1/tests/unit/test_count_tokens_system_lift.py +57 -0
  341. yunshu-0.1.1/tests/unit/test_coverage.py +815 -0
  342. yunshu-0.1.1/tests/unit/test_cpu_gpu_overlap.py +307 -0
  343. yunshu-0.1.1/tests/unit/test_custom_logits_processors.py +403 -0
  344. yunshu-0.1.1/tests/unit/test_deltanet_inversion.py +363 -0
  345. yunshu-0.1.1/tests/unit/test_dflash_context.py +130 -0
  346. yunshu-0.1.1/tests/unit/test_dflash_tree.py +87 -0
  347. yunshu-0.1.1/tests/unit/test_diffusion_infra.py +309 -0
  348. yunshu-0.1.1/tests/unit/test_diffusion_scheduler_flowmatch.py +59 -0
  349. yunshu-0.1.1/tests/unit/test_disconnect_guard.py +54 -0
  350. yunshu-0.1.1/tests/unit/test_draft_vocab.py +124 -0
  351. yunshu-0.1.1/tests/unit/test_e2e_gateway.py +238 -0
  352. yunshu-0.1.1/tests/unit/test_embed_pooling.py +69 -0
  353. yunshu-0.1.1/tests/unit/test_embedding_zero_dim.py +59 -0
  354. yunshu-0.1.1/tests/unit/test_embeddings.py +434 -0
  355. yunshu-0.1.1/tests/unit/test_embeddings_nan_and_status.py +104 -0
  356. yunshu-0.1.1/tests/unit/test_encoder_cache.py +69 -0
  357. yunshu-0.1.1/tests/unit/test_engine_core.py +566 -0
  358. yunshu-0.1.1/tests/unit/test_engine_core_wiring.py +202 -0
  359. yunshu-0.1.1/tests/unit/test_engine_embed_pool.py +168 -0
  360. yunshu-0.1.1/tests/unit/test_engine_loop_routing_stable.py +29 -0
  361. yunshu-0.1.1/tests/unit/test_engine_loop_sampling.py +102 -0
  362. yunshu-0.1.1/tests/unit/test_engine_mesh_batched_wiring.py +242 -0
  363. yunshu-0.1.1/tests/unit/test_error_contract.py +37 -0
  364. yunshu-0.1.1/tests/unit/test_eviction_exclude.py +64 -0
  365. yunshu-0.1.1/tests/unit/test_exceptions.py +133 -0
  366. yunshu-0.1.1/tests/unit/test_fast_path_params.py +227 -0
  367. yunshu-0.1.1/tests/unit/test_fixes.py +345 -0
  368. yunshu-0.1.1/tests/unit/test_forward_batch.py +411 -0
  369. yunshu-0.1.1/tests/unit/test_gateway.py +49 -0
  370. yunshu-0.1.1/tests/unit/test_gateway_endpoints.py +284 -0
  371. yunshu-0.1.1/tests/unit/test_gateway_error_handling.py +911 -0
  372. yunshu-0.1.1/tests/unit/test_gateway_logging.py +35 -0
  373. yunshu-0.1.1/tests/unit/test_gateway_optimizer.py +683 -0
  374. yunshu-0.1.1/tests/unit/test_gdn_rows.py +50 -0
  375. yunshu-0.1.1/tests/unit/test_gemma4_assistant.py +566 -0
  376. yunshu-0.1.1/tests/unit/test_gemma4_spec_serving.py +79 -0
  377. yunshu-0.1.1/tests/unit/test_gemma_channel_batched.py +107 -0
  378. yunshu-0.1.1/tests/unit/test_glm_stream_gateway.py +51 -0
  379. yunshu-0.1.1/tests/unit/test_gpu_ngram.py +382 -0
  380. yunshu-0.1.1/tests/unit/test_gpu_sampler.py +63 -0
  381. yunshu-0.1.1/tests/unit/test_gpu_sampler_xtc_order.py +80 -0
  382. yunshu-0.1.1/tests/unit/test_grammar_bitmask.py +459 -0
  383. yunshu-0.1.1/tests/unit/test_grammar_constraint.py +352 -0
  384. yunshu-0.1.1/tests/unit/test_health_shutdown.py +146 -0
  385. yunshu-0.1.1/tests/unit/test_hybrid_ssd_snapshot.py +122 -0
  386. yunshu-0.1.1/tests/unit/test_hybrid_ssd_unaligned_key.py +91 -0
  387. yunshu-0.1.1/tests/unit/test_image_cancel.py +37 -0
  388. yunshu-0.1.1/tests/unit/test_image_cancel_sweep.py +61 -0
  389. yunshu-0.1.1/tests/unit/test_image_cancel_wiring.py +73 -0
  390. yunshu-0.1.1/tests/unit/test_image_engine.py +172 -0
  391. yunshu-0.1.1/tests/unit/test_image_lora.py +206 -0
  392. yunshu-0.1.1/tests/unit/test_image_model_select.py +95 -0
  393. yunshu-0.1.1/tests/unit/test_image_pipeline.py +183 -0
  394. yunshu-0.1.1/tests/unit/test_image_preview.py +130 -0
  395. yunshu-0.1.1/tests/unit/test_image_stream_cancel_done.py +20 -0
  396. yunshu-0.1.1/tests/unit/test_image_variants.py +103 -0
  397. yunshu-0.1.1/tests/unit/test_image_video_params.py +27 -0
  398. yunshu-0.1.1/tests/unit/test_images.py +403 -0
  399. yunshu-0.1.1/tests/unit/test_img2img.py +149 -0
  400. yunshu-0.1.1/tests/unit/test_img2img_strength_zero.py +69 -0
  401. yunshu-0.1.1/tests/unit/test_inference_budget.py +211 -0
  402. yunshu-0.1.1/tests/unit/test_inflight_prefix_sharing.py +148 -0
  403. yunshu-0.1.1/tests/unit/test_inpaint_init.py +49 -0
  404. yunshu-0.1.1/tests/unit/test_inpaint_paste_back.py +76 -0
  405. yunshu-0.1.1/tests/unit/test_int_code_linear.py +128 -0
  406. yunshu-0.1.1/tests/unit/test_json_schema.py +1526 -0
  407. yunshu-0.1.1/tests/unit/test_json_schema_merged_ws.py +81 -0
  408. yunshu-0.1.1/tests/unit/test_json_schema_scalar_term.py +90 -0
  409. yunshu-0.1.1/tests/unit/test_json_schema_vocab_cache.py +84 -0
  410. yunshu-0.1.1/tests/unit/test_jump_forward.py +82 -0
  411. yunshu-0.1.1/tests/unit/test_jump_forward_stop.py +152 -0
  412. yunshu-0.1.1/tests/unit/test_kv_api.py +152 -0
  413. yunshu-0.1.1/tests/unit/test_kv_block.py +271 -0
  414. yunshu-0.1.1/tests/unit/test_kv_block_table.py +207 -0
  415. yunshu-0.1.1/tests/unit/test_kv_cache.py +297 -0
  416. yunshu-0.1.1/tests/unit/test_kv_cache_lora_key.py +30 -0
  417. yunshu-0.1.1/tests/unit/test_kv_engine_prefix.py +332 -0
  418. yunshu-0.1.1/tests/unit/test_kv_hash.py +95 -0
  419. yunshu-0.1.1/tests/unit/test_kv_lifecycle.py +258 -0
  420. yunshu-0.1.1/tests/unit/test_kv_manager.py +132 -0
  421. yunshu-0.1.1/tests/unit/test_kv_optimizations.py +820 -0
  422. yunshu-0.1.1/tests/unit/test_kv_prefix_cache.py +1103 -0
  423. yunshu-0.1.1/tests/unit/test_kv_prefix_compression.py +540 -0
  424. yunshu-0.1.1/tests/unit/test_kv_prefix_ssd_cold_cache.py +78 -0
  425. yunshu-0.1.1/tests/unit/test_kv_quant_autogate.py +61 -0
  426. yunshu-0.1.1/tests/unit/test_kv_quant_bits_validation.py +62 -0
  427. yunshu-0.1.1/tests/unit/test_kv_quantization.py +415 -0
  428. yunshu-0.1.1/tests/unit/test_kv_serialization.py +456 -0
  429. yunshu-0.1.1/tests/unit/test_kv_tier_promote_failclosed.py +32 -0
  430. yunshu-0.1.1/tests/unit/test_lane_linear.py +52 -0
  431. yunshu-0.1.1/tests/unit/test_lifespan_load_failure.py +34 -0
  432. yunshu-0.1.1/tests/unit/test_load_failure_reason.py +36 -0
  433. yunshu-0.1.1/tests/unit/test_logprob_bytes.py +91 -0
  434. yunshu-0.1.1/tests/unit/test_lora_engineloop_no_acquire.py +25 -0
  435. yunshu-0.1.1/tests/unit/test_lora_manager.py +826 -0
  436. yunshu-0.1.1/tests/unit/test_lora_path_traversal.py +52 -0
  437. yunshu-0.1.1/tests/unit/test_lossless_defaults.py +40 -0
  438. yunshu-0.1.1/tests/unit/test_mamba_cache.py +757 -0
  439. yunshu-0.1.1/tests/unit/test_mcp.py +98 -0
  440. yunshu-0.1.1/tests/unit/test_mcp_client.py +104 -0
  441. yunshu-0.1.1/tests/unit/test_mcp_client_stdio_concurrency_initialize.py +110 -0
  442. yunshu-0.1.1/tests/unit/test_mcp_envelope.py +86 -0
  443. yunshu-0.1.1/tests/unit/test_mcp_error_envelope.py +90 -0
  444. yunshu-0.1.1/tests/unit/test_mcp_generate_image_dims.py +69 -0
  445. yunshu-0.1.1/tests/unit/test_mcp_middleware_envelope.py +77 -0
  446. yunshu-0.1.1/tests/unit/test_mcp_model_isolation.py +67 -0
  447. yunshu-0.1.1/tests/unit/test_mcp_prometheus.py +315 -0
  448. yunshu-0.1.1/tests/unit/test_mcp_session.py +119 -0
  449. yunshu-0.1.1/tests/unit/test_memory_aware_scheduler.py +447 -0
  450. yunshu-0.1.1/tests/unit/test_memory_guard.py +435 -0
  451. yunshu-0.1.1/tests/unit/test_memory_monitor.py +48 -0
  452. yunshu-0.1.1/tests/unit/test_message_adapter.py +551 -0
  453. yunshu-0.1.1/tests/unit/test_metrics_aggregator.py +307 -0
  454. yunshu-0.1.1/tests/unit/test_metrics_cardinality.py +33 -0
  455. yunshu-0.1.1/tests/unit/test_metrics_endpoint_overflow.py +42 -0
  456. yunshu-0.1.1/tests/unit/test_metrics_window.py +56 -0
  457. yunshu-0.1.1/tests/unit/test_middleware.py +88 -0
  458. yunshu-0.1.1/tests/unit/test_mlx_cache.py +271 -0
  459. yunshu-0.1.1/tests/unit/test_mlx_executor.py +149 -0
  460. yunshu-0.1.1/tests/unit/test_mlx_vlm_patches.py +66 -0
  461. yunshu-0.1.1/tests/unit/test_model_backend.py +116 -0
  462. yunshu-0.1.1/tests/unit/test_model_cache_config.py +99 -0
  463. yunshu-0.1.1/tests/unit/test_model_card.py +316 -0
  464. yunshu-0.1.1/tests/unit/test_model_card_gateway.py +69 -0
  465. yunshu-0.1.1/tests/unit/test_model_discovery.py +211 -0
  466. yunshu-0.1.1/tests/unit/test_model_guards.py +143 -0
  467. yunshu-0.1.1/tests/unit/test_model_locations.py +187 -0
  468. yunshu-0.1.1/tests/unit/test_model_optimizations.py +1251 -0
  469. yunshu-0.1.1/tests/unit/test_model_patches.py +148 -0
  470. yunshu-0.1.1/tests/unit/test_model_preprocessor.py +439 -0
  471. yunshu-0.1.1/tests/unit/test_model_settings.py +95 -0
  472. yunshu-0.1.1/tests/unit/test_model_settings_adaptive.py +21 -0
  473. yunshu-0.1.1/tests/unit/test_model_settings_integration.py +69 -0
  474. yunshu-0.1.1/tests/unit/test_model_unload_guard.py +157 -0
  475. yunshu-0.1.1/tests/unit/test_model_unload_report.py +66 -0
  476. yunshu-0.1.1/tests/unit/test_moe_optimization.py +131 -0
  477. yunshu-0.1.1/tests/unit/test_monitoring.py +120 -0
  478. yunshu-0.1.1/tests/unit/test_mrope.py +186 -0
  479. yunshu-0.1.1/tests/unit/test_mtp_checkpoint_detection.py +76 -0
  480. yunshu-0.1.1/tests/unit/test_mtp_decoder.py +102 -0
  481. yunshu-0.1.1/tests/unit/test_mtp_patch.py +132 -0
  482. yunshu-0.1.1/tests/unit/test_mtp_pipeline.py +494 -0
  483. yunshu-0.1.1/tests/unit/test_mtp_served_stream.py +114 -0
  484. yunshu-0.1.1/tests/unit/test_multi_turn_conversation.py +753 -0
  485. yunshu-0.1.1/tests/unit/test_multimodal_failloud.py +79 -0
  486. yunshu-0.1.1/tests/unit/test_mxfp4_quant.py +56 -0
  487. yunshu-0.1.1/tests/unit/test_n_confirmed_patch.py +103 -0
  488. yunshu-0.1.1/tests/unit/test_n_plus_one_streaming.py +89 -0
  489. yunshu-0.1.1/tests/unit/test_new_features.py +212 -0
  490. yunshu-0.1.1/tests/unit/test_ngram_default_routing.py +78 -0
  491. yunshu-0.1.1/tests/unit/test_ngram_proposer.py +237 -0
  492. yunshu-0.1.1/tests/unit/test_ngram_spec_lora_bypass.py +28 -0
  493. yunshu-0.1.1/tests/unit/test_ngram_spec_lossless.py +128 -0
  494. yunshu-0.1.1/tests/unit/test_ocr.py +110 -0
  495. yunshu-0.1.1/tests/unit/test_ocr_cancel_wiring.py +104 -0
  496. yunshu-0.1.1/tests/unit/test_ocr_engine.py +92 -0
  497. yunshu-0.1.1/tests/unit/test_ocr_model_select.py +89 -0
  498. yunshu-0.1.1/tests/unit/test_ollama_api.py +287 -0
  499. yunshu-0.1.1/tests/unit/test_omlx_patterns.py +388 -0
  500. yunshu-0.1.1/tests/unit/test_omlx_row_exact.py +88 -0
  501. yunshu-0.1.1/tests/unit/test_omlx_verify_kernels.py +67 -0
  502. yunshu-0.1.1/tests/unit/test_omni_engine.py +76 -0
  503. yunshu-0.1.1/tests/unit/test_omni_media_resolve.py +74 -0
  504. yunshu-0.1.1/tests/unit/test_omni_multiturn_prompt.py +103 -0
  505. yunshu-0.1.1/tests/unit/test_omni_reuse.py +132 -0
  506. yunshu-0.1.1/tests/unit/test_omni_router.py +112 -0
  507. yunshu-0.1.1/tests/unit/test_openai_params.py +386 -0
  508. yunshu-0.1.1/tests/unit/test_output_collector.py +130 -0
  509. yunshu-0.1.1/tests/unit/test_output_parser.py +313 -0
  510. yunshu-0.1.1/tests/unit/test_packed_linear.py +67 -0
  511. yunshu-0.1.1/tests/unit/test_paged_attention_integration.py +451 -0
  512. yunshu-0.1.1/tests/unit/test_paged_scheduler.py +364 -0
  513. yunshu-0.1.1/tests/unit/test_phase0_ane.py +582 -0
  514. yunshu-0.1.1/tests/unit/test_phase1_gaps.py +214 -0
  515. yunshu-0.1.1/tests/unit/test_pooling_non_finite_sanitizer.py +45 -0
  516. yunshu-0.1.1/tests/unit/test_prefill_null_content_qwen_system.py +131 -0
  517. yunshu-0.1.1/tests/unit/test_prefill_progress.py +95 -0
  518. yunshu-0.1.1/tests/unit/test_prefill_progress_fast_path.py +100 -0
  519. yunshu-0.1.1/tests/unit/test_priority_queue.py +478 -0
  520. yunshu-0.1.1/tests/unit/test_priority_scheduling.py +49 -0
  521. yunshu-0.1.1/tests/unit/test_process_memory_enforcer.py +132 -0
  522. yunshu-0.1.1/tests/unit/test_production_hardening.py +1149 -0
  523. yunshu-0.1.1/tests/unit/test_prometheus_exporter.py +298 -0
  524. yunshu-0.1.1/tests/unit/test_prometheus_nan_inf.py +36 -0
  525. yunshu-0.1.1/tests/unit/test_prompt_cache.py +367 -0
  526. yunshu-0.1.1/tests/unit/test_prompt_cache_idle_ttl.py +71 -0
  527. yunshu-0.1.1/tests/unit/test_prompt_tokens_accuracy.py +408 -0
  528. yunshu-0.1.1/tests/unit/test_quant_config_load.py +54 -0
  529. yunshu-0.1.1/tests/unit/test_radix.py +147 -0
  530. yunshu-0.1.1/tests/unit/test_radix_attention.py +324 -0
  531. yunshu-0.1.1/tests/unit/test_radix_eviction.py +86 -0
  532. yunshu-0.1.1/tests/unit/test_radix_split.py +246 -0
  533. yunshu-0.1.1/tests/unit/test_ragged_kv.py +713 -0
  534. yunshu-0.1.1/tests/unit/test_rate_limit.py +241 -0
  535. yunshu-0.1.1/tests/unit/test_realtime.py +349 -0
  536. yunshu-0.1.1/tests/unit/test_realtime_audio.py +635 -0
  537. yunshu-0.1.1/tests/unit/test_realtime_audio_done_guarantee_history_bound.py +73 -0
  538. yunshu-0.1.1/tests/unit/test_realtime_audio_end_ms.py +87 -0
  539. yunshu-0.1.1/tests/unit/test_realtime_audio_transcript.py +27 -0
  540. yunshu-0.1.1/tests/unit/test_realtime_bargein.py +62 -0
  541. yunshu-0.1.1/tests/unit/test_realtime_buffer_cap.py +66 -0
  542. yunshu-0.1.1/tests/unit/test_realtime_conformance.py +131 -0
  543. yunshu-0.1.1/tests/unit/test_realtime_enhanced.py +853 -0
  544. yunshu-0.1.1/tests/unit/test_realtime_g711_itu.py +54 -0
  545. yunshu-0.1.1/tests/unit/test_realtime_ga.py +105 -0
  546. yunshu-0.1.1/tests/unit/test_realtime_max_tokens.py +60 -0
  547. yunshu-0.1.1/tests/unit/test_realtime_omni.py +369 -0
  548. yunshu-0.1.1/tests/unit/test_realtime_oob_conversation.py +51 -0
  549. yunshu-0.1.1/tests/unit/test_realtime_per_response_output_format.py +68 -0
  550. yunshu-0.1.1/tests/unit/test_realtime_response_done.py +59 -0
  551. yunshu-0.1.1/tests/unit/test_realtime_silero_vad.py +119 -0
  552. yunshu-0.1.1/tests/unit/test_realtime_tool_choice_none.py +57 -0
  553. yunshu-0.1.1/tests/unit/test_realtime_turn_detection.py +35 -0
  554. yunshu-0.1.1/tests/unit/test_reasoning_parser.py +345 -0
  555. yunshu-0.1.1/tests/unit/test_reasoning_stream_metrics.py +44 -0
  556. yunshu-0.1.1/tests/unit/test_regex_constraint_linear.py +99 -0
  557. yunshu-0.1.1/tests/unit/test_report_thermal_suspect.py +62 -0
  558. yunshu-0.1.1/tests/unit/test_request.py +156 -0
  559. yunshu-0.1.1/tests/unit/test_request_lifecycle.py +344 -0
  560. yunshu-0.1.1/tests/unit/test_request_size_limit_embeddings_cap.py +44 -0
  561. yunshu-0.1.1/tests/unit/test_request_tracker.py +230 -0
  562. yunshu-0.1.1/tests/unit/test_rerank_honesty.py +28 -0
  563. yunshu-0.1.1/tests/unit/test_rerank_nan.py +42 -0
  564. yunshu-0.1.1/tests/unit/test_response_cache_key.py +49 -0
  565. yunshu-0.1.1/tests/unit/test_responses.py +200 -0
  566. yunshu-0.1.1/tests/unit/test_responses_background.py +135 -0
  567. yunshu-0.1.1/tests/unit/test_responses_cancel_clobber.py +81 -0
  568. yunshu-0.1.1/tests/unit/test_responses_chain_toolcall.py +82 -0
  569. yunshu-0.1.1/tests/unit/test_responses_delete.py +84 -0
  570. yunshu-0.1.1/tests/unit/test_responses_fc_status.py +30 -0
  571. yunshu-0.1.1/tests/unit/test_responses_metadata_echo.py +45 -0
  572. yunshu-0.1.1/tests/unit/test_responses_n_choice_isolation.py +51 -0
  573. yunshu-0.1.1/tests/unit/test_responses_nonbatched_template.py +37 -0
  574. yunshu-0.1.1/tests/unit/test_responses_nonstream_cancel_status.py +37 -0
  575. yunshu-0.1.1/tests/unit/test_responses_per_choice_seed.py +32 -0
  576. yunshu-0.1.1/tests/unit/test_responses_reasoning_item.py +116 -0
  577. yunshu-0.1.1/tests/unit/test_responses_stream_toolmarkup.py +66 -0
  578. yunshu-0.1.1/tests/unit/test_responses_vlm_shape.py +134 -0
  579. yunshu-0.1.1/tests/unit/test_roofline.py +359 -0
  580. yunshu-0.1.1/tests/unit/test_round_driver.py +277 -0
  581. yunshu-0.1.1/tests/unit/test_sampler_temp_parity.py +70 -0
  582. yunshu-0.1.1/tests/unit/test_sampling_param_bounds.py +59 -0
  583. yunshu-0.1.1/tests/unit/test_sampling_parity.py +62 -0
  584. yunshu-0.1.1/tests/unit/test_save_prefix_external_reuse_gate.py +74 -0
  585. yunshu-0.1.1/tests/unit/test_scheduler.py +910 -0
  586. yunshu-0.1.1/tests/unit/test_scheduler_effective_cap.py +65 -0
  587. yunshu-0.1.1/tests/unit/test_scheduler_mixins.py +421 -0
  588. yunshu-0.1.1/tests/unit/test_scheduler_orphan.py +48 -0
  589. yunshu-0.1.1/tests/unit/test_scheduler_sampler_prng.py +52 -0
  590. yunshu-0.1.1/tests/unit/test_scheduler_spec_decode.py +845 -0
  591. yunshu-0.1.1/tests/unit/test_scheduler_thinking_segment.py +269 -0
  592. yunshu-0.1.1/tests/unit/test_scoring.py +304 -0
  593. yunshu-0.1.1/tests/unit/test_scoring_backbone.py +88 -0
  594. yunshu-0.1.1/tests/unit/test_scoring_per_text_length_cap.py +65 -0
  595. yunshu-0.1.1/tests/unit/test_security.py +122 -0
  596. yunshu-0.1.1/tests/unit/test_security_responses.py +155 -0
  597. yunshu-0.1.1/tests/unit/test_serve_uds.py +48 -0
  598. yunshu-0.1.1/tests/unit/test_server_metrics.py +181 -0
  599. yunshu-0.1.1/tests/unit/test_settings.py +258 -0
  600. yunshu-0.1.1/tests/unit/test_shutdown_drain_asr_vad_short_clip.py +49 -0
  601. yunshu-0.1.1/tests/unit/test_spec_decode_integration.py +325 -0
  602. yunshu-0.1.1/tests/unit/test_spec_double_bos.py +43 -0
  603. yunshu-0.1.1/tests/unit/test_spec_draft_verifier.py +967 -0
  604. yunshu-0.1.1/tests/unit/test_spec_grammar_constraint.py +97 -0
  605. yunshu-0.1.1/tests/unit/test_spec_head_detection.py +636 -0
  606. yunshu-0.1.1/tests/unit/test_spec_interface.py +719 -0
  607. yunshu-0.1.1/tests/unit/test_spec_prefill.py +194 -0
  608. yunshu-0.1.1/tests/unit/test_spec_prefill_engine.py +308 -0
  609. yunshu-0.1.1/tests/unit/test_spec_proposer.py +92 -0
  610. yunshu-0.1.1/tests/unit/test_spec_schedule.py +97 -0
  611. yunshu-0.1.1/tests/unit/test_spec_select.py +52 -0
  612. yunshu-0.1.1/tests/unit/test_spec_stream_unreachable.py +83 -0
  613. yunshu-0.1.1/tests/unit/test_speculative_decoder.py +422 -0
  614. yunshu-0.1.1/tests/unit/test_srt_vtt_timestamp_null_safe.py +32 -0
  615. yunshu-0.1.1/tests/unit/test_srt_vtt_timestamp_whisper_parity.py +37 -0
  616. yunshu-0.1.1/tests/unit/test_ssd_kv_budget_dequant.py +87 -0
  617. yunshu-0.1.1/tests/unit/test_ssd_kv_cache.py +257 -0
  618. yunshu-0.1.1/tests/unit/test_ssd_sqlite_store.py +473 -0
  619. yunshu-0.1.1/tests/unit/test_ssd_store_scope.py +69 -0
  620. yunshu-0.1.1/tests/unit/test_sse_cancel_on_disconnect.py +86 -0
  621. yunshu-0.1.1/tests/unit/test_staged_pipeline.py +513 -0
  622. yunshu-0.1.1/tests/unit/test_stop_holdback.py +201 -0
  623. yunshu-0.1.1/tests/unit/test_stream_total_deadline.py +43 -0
  624. yunshu-0.1.1/tests/unit/test_streaming.py +598 -0
  625. yunshu-0.1.1/tests/unit/test_streaming_optimizer.py +591 -0
  626. yunshu-0.1.1/tests/unit/test_suffix_proposer.py +547 -0
  627. yunshu-0.1.1/tests/unit/test_sweep_round_driver_filler.py +27 -0
  628. yunshu-0.1.1/tests/unit/test_teacache.py +194 -0
  629. yunshu-0.1.1/tests/unit/test_telemetry.py +265 -0
  630. yunshu-0.1.1/tests/unit/test_text_utils.py +93 -0
  631. yunshu-0.1.1/tests/unit/test_think_token_resolve.py +72 -0
  632. yunshu-0.1.1/tests/unit/test_thinking_budget.py +216 -0
  633. yunshu-0.1.1/tests/unit/test_thinking_segment.py +554 -0
  634. yunshu-0.1.1/tests/unit/test_thinking_segment_fast_path.py +132 -0
  635. yunshu-0.1.1/tests/unit/test_thinking_segment_prod.py +453 -0
  636. yunshu-0.1.1/tests/unit/test_tiered.py +399 -0
  637. yunshu-0.1.1/tests/unit/test_tiered_bf16.py +42 -0
  638. yunshu-0.1.1/tests/unit/test_token_bytes_bytelevel.py +98 -0
  639. yunshu-0.1.1/tests/unit/test_token_counter.py +161 -0
  640. yunshu-0.1.1/tests/unit/test_token_scheduler.py +974 -0
  641. yunshu-0.1.1/tests/unit/test_tokenize.py +256 -0
  642. yunshu-0.1.1/tests/unit/test_tokenizer_vocab_cache.py +58 -0
  643. yunshu-0.1.1/tests/unit/test_tool_arguments_native.py +286 -0
  644. yunshu-0.1.1/tests/unit/test_tool_calling.py +272 -0
  645. yunshu-0.1.1/tests/unit/test_tool_choice_enforce.py +88 -0
  646. yunshu-0.1.1/tests/unit/test_tool_choice_prefill.py +192 -0
  647. yunshu-0.1.1/tests/unit/test_tool_format.py +303 -0
  648. yunshu-0.1.1/tests/unit/test_tool_format_doubled_braces.py +21 -0
  649. yunshu-0.1.1/tests/unit/test_tool_format_malformed_json.py +50 -0
  650. yunshu-0.1.1/tests/unit/test_tool_streamer_split_nontag.py +68 -0
  651. yunshu-0.1.1/tests/unit/test_tool_streamer_tool_choice.py +82 -0
  652. yunshu-0.1.1/tests/unit/test_top_n_sigma.py +54 -0
  653. yunshu-0.1.1/tests/unit/test_top_n_sigma_request.py +77 -0
  654. yunshu-0.1.1/tests/unit/test_tracing.py +655 -0
  655. yunshu-0.1.1/tests/unit/test_tree_shape.py +38 -0
  656. yunshu-0.1.1/tests/unit/test_tts_extended.py +55 -0
  657. yunshu-0.1.1/tests/unit/test_tts_segmentation.py +80 -0
  658. yunshu-0.1.1/tests/unit/test_tts_stream_error_terminal.py +47 -0
  659. yunshu-0.1.1/tests/unit/test_turbo_quant.py +130 -0
  660. yunshu-0.1.1/tests/unit/test_two_batch_overlap.py +600 -0
  661. yunshu-0.1.1/tests/unit/test_unregister_loading_guard.py +53 -0
  662. yunshu-0.1.1/tests/unit/test_vad.py +101 -0
  663. yunshu-0.1.1/tests/unit/test_vad_audio_time.py +37 -0
  664. yunshu-0.1.1/tests/unit/test_vae_tiling.py +131 -0
  665. yunshu-0.1.1/tests/unit/test_vendor_manifest.py +29 -0
  666. yunshu-0.1.1/tests/unit/test_video_understanding.py +337 -0
  667. yunshu-0.1.1/tests/unit/test_vl_embedding.py +235 -0
  668. yunshu-0.1.1/tests/unit/test_vlm_apc_gate.py +98 -0
  669. yunshu-0.1.1/tests/unit/test_vlm_audio_mime.py +55 -0
  670. yunshu-0.1.1/tests/unit/test_vlm_chat_template.py +118 -0
  671. yunshu-0.1.1/tests/unit/test_vlm_constrained_thinking.py +30 -0
  672. yunshu-0.1.1/tests/unit/test_vlm_data_url_subtype.py +40 -0
  673. yunshu-0.1.1/tests/unit/test_vlm_engine.py +644 -0
  674. yunshu-0.1.1/tests/unit/test_vlm_logprob_precision.py +38 -0
  675. yunshu-0.1.1/tests/unit/test_vlm_media.py +45 -0
  676. yunshu-0.1.1/tests/unit/test_vlm_nonstream_cancel.py +37 -0
  677. yunshu-0.1.1/tests/unit/test_vlm_quant_config.py +69 -0
  678. yunshu-0.1.1/tests/unit/test_vlm_reasoning_effort_template.py +32 -0
  679. yunshu-0.1.1/tests/unit/test_vlm_runner_all_families.py +174 -0
  680. yunshu-0.1.1/tests/unit/test_vlm_runner_batching.py +299 -0
  681. yunshu-0.1.1/tests/unit/test_vlm_runner_thinking.py +82 -0
  682. yunshu-0.1.1/tests/unit/test_vlm_stop_content_loss.py +24 -0
  683. yunshu-0.1.1/tests/unit/test_vlm_stream_no_spurious_cancel.py +82 -0
  684. yunshu-0.1.1/tests/unit/test_vlm_stream_timeout.py +47 -0
  685. yunshu-0.1.1/tests/unit/test_vlm_tools.py +63 -0
  686. yunshu-0.1.1/tests/unit/test_vlm_video_failloud.py +79 -0
  687. yunshu-0.1.1/tests/unit/test_ws_transport.py +473 -0
  688. yunshu-0.1.1/uv.lock +4213 -0
@@ -0,0 +1,73 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ dist/
7
+ build/
8
+ *.egg
9
+ .venv/
10
+
11
+ # uv
12
+ .python-version
13
+
14
+ # Node / Next.js
15
+ node_modules/
16
+ webui/.next/
17
+ webui/out/
18
+
19
+ # Metal
20
+ metal/build/
21
+
22
+ # IDE
23
+ .idea/
24
+ .vscode/
25
+ *.swp
26
+ *.swo
27
+ .DS_Store
28
+
29
+ # Testing
30
+ .coverage
31
+ htmlcov/
32
+ .pytest_cache/
33
+ .mypy_cache/
34
+ .ruff_cache/
35
+
36
+ # Benchmarks (local results only)
37
+ bench/**/results/
38
+ bench/**/*.json
39
+ bench/**/*.csv
40
+
41
+ # Environment
42
+ .env
43
+ .envrc
44
+
45
+ # Logs
46
+ *.log
47
+
48
+ # Models (too large for git) — root-anchored, NO trailing slash so it also matches the
49
+ # `models` symlink to an external drive (a trailing slash would match dirs only).
50
+ /models
51
+
52
+ # Internal / development
53
+ .claude/
54
+ reference/
55
+ # Local archive of the pre-refocus tree (never published)
56
+ /_archive_yunshu/
57
+ PROGRESS_GUIDE.md
58
+ CLAUDE.md
59
+ reports/
60
+
61
+ .build/
62
+ testresource/
63
+ # Auxiliary tool venvs (oMLX comparison env, etc.) — large, never committed
64
+ .venvs/
65
+
66
+ # The broad `reports/` rule above also catches docs/reports/, but that dir IS the
67
+ # deliverable (unified report + trend charts) — track it, except the unbounded
68
+ # local version-history snapshots.
69
+ !docs/reports/
70
+ !docs/reports/**
71
+ docs/reports/history/
72
+ docs/research/
73
+ scripts/research/local.env
@@ -0,0 +1,210 @@
1
+ # Changelog
2
+
3
+ All notable changes to Yunshu are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/). Versions go up in small steps: a patch
5
+ (0.1.1, 0.1.2, …) for fixes and improvements, a minor (0.2.0) only for a real capability jump.
6
+ Release steps: [RELEASING.md](RELEASING.md).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.1] - 2026-09-29
11
+
12
+ Yunshu is now positioned as a local LLM / VLM inference engine (decode speed, TTFT, prefix reuse,
13
+ API completeness), with Qwen3.8-27B as the first fully tuned model. Speech-to-speech and the other
14
+ modalities remain supported capabilities; the README, CLAUDE.md and AGENTS.md were restructured to
15
+ match.
16
+
17
+ ### Added
18
+
19
+ - First-run commands: `yunshu doctor` checks the Mac (Apple Silicon / Rosetta, macOS, Python, MLX
20
+ and Metal, memory, settings, models directory, the model and whether it fits, port) and prints a
21
+ fix for each problem; `yunshu pull <org/name>` downloads into the models directory, refuses to
22
+ download a model that is already on disk (models directory or Hugging Face cache) and resumes an
23
+ interrupted download; `yunshu model list` also lists the Hugging Face cache; `yunshu --version`.
24
+ - Models from the Hugging Face cache are usable in place: `yunshu serve -m org/name` (or a name under
25
+ the models directory) serves the local copy instead of downloading, and multi-model mode lists
26
+ cached models next to the models directory (`YUNSHU_HF_CACHE_MODELS`, on by default).
27
+ - `yunshu config set KEY VALUE` / `unset` / `path`: settings saved in `~/.yunshu/config.toml`, read
28
+ by every command and the service (e.g. `yunshu config set models_dir /Volumes/Models`).
29
+ - `yunshu service install|uninstall|start|stop|restart|status|logs`: a per-user launchd agent
30
+ that starts Yunshu at login, restarts it after a crash, and logs to `~/Library/Logs/Yunshu`.
31
+ - Docs: [connecting clients](docs/guides/CLIENTS.md), [service](docs/guides/SERVICE.md),
32
+ [troubleshooting](docs/guides/TROUBLESHOOTING.md), [benchmark sources](docs/BENCHMARKS.md),
33
+ [RELEASING.md](RELEASING.md); a tag-triggered release workflow (PyPI trusted publishing behind
34
+ an approval step) and a Homebrew formula for the `yuhuanstudio/tap` tap (`packaging/homebrew/`).
35
+ - One settings registry for every `YUNSHU_*` setting: a TOML config file (`--config`),
36
+ `yunshu serve --set KEY=VALUE`, `yunshu config` (effective value and source of each), generated
37
+ [docs/CONFIGURATION.md](docs/CONFIGURATION.md); a bad value stops startup, a misspelled name
38
+ warns.
39
+ - Qwen3.5-family VLM runner (Qwen3.5 / 3.6 / 3.8) on `mlx-vlm`'s generator: prefix cache with
40
+ exact hybrid checkpoints (text + image-pixel keys, optional SSD tier), MTP or DFlash speculative
41
+ decode, streaming reasoning split, tools, JSON schema, stop sequences, logprobs and cancel.
42
+ On Qwen3.8-27B (M5 Max) warm chat TTFT went from 2.5 s to 0.2 s, a repeated 8K prompt from 9 s to
43
+ 0.1 s, and decode from 30 to 57 tok/s.
44
+ - Exact verify kernels (GatedDeltaNet prework/replay, split SDPA, 5-bit streamed matmul) and
45
+ batch-invariant decode kernels, partly vendored from oMLX (Apache-2.0).
46
+ - Per-row-length (ragged) KV cache for models with Qwen3.5-family attention, now the default: rows
47
+ in the shared batch no longer read or copy the longest row's padding, and the single-request
48
+ speculative lane runs decode and verify attention on one per-row kernel. Qwen3.8-27B (M5 Max):
49
+ MMLU-Pro 300 at 8 in flight 249/300 in 28.3 min at 139 tok/s, peak 33.7 GiB (padded cache:
50
+ 250/300, 46.5 min, 88 tok/s, 45 GiB); single-request decode at 131K context 24.5 → 46.6 tok/s,
51
+ at 32K 39.6 → 59.1; short contexts unchanged within noise; spec on == off at 1K / 32K / 131K.
52
+ - `YUNSHU_KV_PRECISION=bf16|int8` (default bf16): int8 K/V with one fp16 scale per 32 dims for the
53
+ shared batch — about half the KV memory and bandwidth, lossy (MMLU-Pro 251/300, peak 28.1 GiB).
54
+ - Experimental own round driver for the Qwen3.5 family (`YUNSHU_ROUND_DRIVER`, off by default):
55
+ multi-row MTP drafting with a cost-aware draft depth (TensorFold's allocation rule, MIT) and
56
+ multi-prompt prefill; being measured.
57
+ - `YUNSHU_LOG_LEVEL`; `scripts/research/` benchmark matrix, realistic soak and MMLU-Pro soak.
58
+
59
+ - Automatic speculative path: a DFlash2 drafter that matches the served model (Qwen3.8-27B:
60
+ `incoai/Qwen3.8-27B-DFlash2`, in the models directory or the Hugging Face cache) is used without
61
+ a flag, with the cost-aware chain depth and 8-bit drafter weights. Qwen3.8-27B server, novel_en
62
+ 1K/8K/32K/131K 57.1 / 48.2 / 46.1 / 32.9 tok/s (MTP 47.5 at 1K), code corpus 82.0 / 89.1 / 70.5 /
63
+ 79.9, 34/34 checks, TTFT about 207 s at 131K; lossless (spec on == off). `YUNSHU_VLM_DRAFT=mtp`
64
+ forces the MTP head, `=off` disables drafting, a path picks a drafter; `yunshu doctor` prints the
65
+ path that will be used.
66
+ - `/health/ready` returns a `reason` when the model failed to load.
67
+ - `scripts/dev/robustness.py`: black-box probe (load failure, disconnect during prefill and
68
+ streaming, limits, mixed concurrent features, 500-request memory, SIGTERM / SIGINT with requests
69
+ in flight).
70
+
71
+ ### Fixed
72
+
73
+ - A non-streaming request whose client disconnected kept the GPU busy to the end of its prefill or
74
+ `max_tokens`: Starlette's `is_disconnected()` never fires behind `BaseHTTPMiddleware`. A
75
+ pure-ASGI watcher now records the disconnect and the request's row is dropped at the next chunk
76
+ (prefill of a 60K-token prompt: next request waited 4.0 s before, 0.8 s after, on a 0.8B model).
77
+ - JSON-schema, regex and grammar constraints no longer allow special tokens (`<|im_end|>`) inside
78
+ a string: a model that chose one ended the response mid-string (Qwen3.5-0.8B stopped at
79
+ `{"name": "Alice`).
80
+ - Ctrl-C / SIGTERM with streams in flight waited for them forever (a 27B stream takes minutes);
81
+ connections are now cut after `YUNSHU_DRAIN_TIMEOUT` (default 30 s) and the server exits.
82
+
83
+ ### Changed
84
+
85
+ - A model that fails to load (missing path, truncated weights, out of memory) no longer stops
86
+ `yunshu serve`: the server stays up, `/health/ready` answers 503 with the reason and chat requests
87
+ get a 503. `yunshu serve` still prints the problem and its fix first.
88
+ - Rate limiting is off by default (`YUNSHU_RATE_LIMIT_RPM=0`; the old 120 per minute rejected a
89
+ local client's 500 sequential requests with 429). Set it above 0 to enable it.
90
+ - `yunshu serve` binds `127.0.0.1` by default (was `0.0.0.0`) and warns when it serves the network
91
+ without `--auth-token`. It checks the model before loading and stops with a fix when the path
92
+ does not exist, a download is incomplete, or the weights exceed memory.
93
+ - The default models directory is `~/.yunshu/models` (was the source tree's `models/`, which
94
+ pointed inside the installed package for a wheel install). `YUNSHU_MODELS_DIR` still overrides.
95
+ - `/version`, the OpenAPI schema and the MCP `serverInfo` report the installed package version
96
+ (they said `0.1.0-dev`).
97
+ - With `--auth-token`, the token is also accepted as `x-api-key` (what Anthropic SDKs send).
98
+ - The wheel and sdist include `THIRD_PARTY_NOTICES.md`; the sdist no longer carries benchmark data.
99
+ - Default decode for MTP models is lossless batch-invariant decode at MTP block 6: decode and verify
100
+ matmuls of a drafting request share one row-invariant kernel (M5 tensor-unit packed where
101
+ available), so greedy output with speculation on equals speculation off. Qwen3.8-27B (M5 Max,
102
+ in-process) code / prose / JSON-like: 88.6 / 59.9 / 67.3 tok/s, vs 57–67 / 50–53 / 58–62 for the
103
+ previous exact kernels at block 3; server matrix decode 57 → 80 tok/s, 33/33 checks. Requests that
104
+ cannot draft (sampling, logits processors, logprobs) keep the stock kernels.
105
+ - Every `mlx-vlm` model is served by the VLM batch runner: concurrent requests share one
106
+ continuous batch with per-row sampling settings, and a request that is alone uses speculative
107
+ decoding (Qwen3.5 family). The older per-request VLM loop was deleted; how it worked is recorded
108
+ in `docs/archive/legacy_vlm_loop/`.
109
+ - 5/6/8-bit projections run on TensorFold's integer-code tensor-unit matmul when packed (M5).
110
+ - Lossy optimizations are options with a lossless default. Text engine: KV cache quantization
111
+ (`YUNSHU_KV_QUANT_BITS`, was `auto`) and the 4-bit warm prefix tier (`YUNSHU_PREFIX_HOT_LIMIT`)
112
+ are off by default, and the SSD prefix cache stores KV and recurrent state bit-exact
113
+ (`YUNSHU_SSD_CACHE_PRECISION=native`; `int8` stays available and old int8 files still load).
114
+ - `reasoning_effort` (top-level or in `chat_template_kwargs`) is passed to chat templates that
115
+ support it (Qwen3.8: low / medium / xhigh) instead of being mapped to a thinking-token cap.
116
+ - Dependencies: MLX 0.32.2, transformers 5.17, upstream `mlx-vlm` 0.7.3 (the fork is gone).
117
+ - JSON-schema constraint: cached vocab split (in-string step 144 ms → 3 ms); structural whitespace
118
+ limited to spaces and newlines.
119
+ - Research scripts and parity tests take model paths from arguments or the environment
120
+ (`M`/`D`/`TF` for the validation scripts, optionally from a gitignored
121
+ `scripts/research/local.env`; `YUNSHU_PARITY_MODEL` for the parity tests, which skip when unset).
122
+ - A model served from the Hugging Face cache is listed under its repo id (`org/name`) in
123
+ `/v1/models`, not the snapshot path.
124
+
125
+ ### Fixed
126
+
127
+ - Streaming thinking on Qwen3.8 was sent as content; it is now sent as reasoning.
128
+ - Gateway startup failure no longer crashes in shutdown on an unbound engine.
129
+ - VLM responses under concurrent load are returned as soon as each generation finishes; before, a
130
+ post-request cache clear queued behind every other request held all responses until the last
131
+ one finished. The non-streaming VLM path also no longer applies a 120 s default timeout that
132
+ counted time spent waiting in the queue (a client-set `timeout` still applies).
133
+ - Tool calls from non-Qwen families (Gemma-4, GLM-4.7, Mistral, pythonic, DeepSeek, Kimi,
134
+ MiniMax, …) were left in `content` with `tool_calls` empty. The tool-call format now comes from
135
+ the model's chat template (upstream mlx-vlm/mlx-lm registry) instead of guessing from the
136
+ request's model name, and every route (chat, Anthropic, Responses, Realtime; streaming and not)
137
+ parses with that format's upstream parser. Arguments are typed with the request's tool schemas.
138
+ Gemma-4 E4B capability checks: 7/34 → 33/34.
139
+ - DFlash2 speculative decode: the drafter's hidden-state capture covered the whole prompt instead
140
+ of the drafter's 2047-position window (about 48 TFLOP extra at 131K), the draft block was capped
141
+ at 4 (the drafter is trained for 8), and speculation on did not equal speculation off at longer
142
+ contexts; it now uses the per-row prefill path and batch-invariant kernels like MTP.
143
+ - The SSD prefix cache's native-precision bf16 writer reinterpreted values instead of bits (it was
144
+ never reached while every write went through int8).
145
+
146
+ ### Removed
147
+
148
+ - The deprecated `Engine` class, multi-node / multi-tenant leftovers (distributed diffusion,
149
+ connection pool, data-parallel endpoint, tenant auth naming), and unused modules
150
+ (`vlm_async_engine`, `wan_vae`, `lid`, `optimizations`, `vision_encoding`).
151
+ - The older VLM MTP / APC side paths, superseded by the runner.
152
+ - The runner's upstream quantized-KV option (slower than bf16 at every measured length) and other
153
+ measured-out flags (`YUNSHU_PACKED_5BIT`, `YUNSHU_VLM_KV_BITS`, `YUNSHU_VLM_INVARIANT`,
154
+ `YUNSHU_MTP_FAST_VERIFY`, `YUNSHU_RAGGED_KV` — ragged is now always on for qwen3_5 attention).
155
+ - Yunshu's own tool-call parsers (`tool_call_parser.py`, `tool_call_parsers.py`, about 4,500 lines
156
+ with their tests), superseded by the upstream parser registry; Yunshu keeps only the formats
157
+ upstream lacks (its prompt-injected JSON format, DeepSeek, whole-message JSON).
158
+
159
+ ## [0.1.0] - 2026-07-01
160
+
161
+ First public release — the full capability surface below, each endpoint smoke-verified
162
+ against a real model on Apple Silicon.
163
+
164
+ ### Added
165
+
166
+ - **Native streaming speech-to-speech** (the flagship): Qwen3-Omni Thinker→Talker
167
+ on Apple MLX via `mlx-vlm` — `POST /v1/omni/speech/stream` (SSE) and the
168
+ OpenAI-Realtime `WS /v1/realtime` socket. Speech-in (raw audio, no ASR) and
169
+ speech-out, ~1.2 s first-audio text-in / ~1.4 s speech-in (warm). Multi-turn
170
+ conversation context preserved (bounded to protect TTFT). Tool-calling works on the
171
+ voice path too — a tool turn emits `function_call` items and the spoken JSON is
172
+ suppressed (the voice doesn't read the call aloud).
173
+ - **OpenAI-compatible API**: chat/completions (tool-calling, JSON-schema/grammar,
174
+ streaming, logprobs), completions, responses, embeddings, audio
175
+ (transcriptions/translations/speech), images (generation + edits/variations/
176
+ inpaint/controlnet), tokenizer utilities, batch inference.
177
+ - **Tool-calling**: tools are rendered via the model's own chat template when it supports
178
+ them natively (better adherence), and a forced `tool_choice` (required / named) is
179
+ structurally enforced with an assistant prefill — consistently across
180
+ `/chat/completions`, `/v1/responses`, and Anthropic `/v1/messages`.
181
+ - **Trained image ControlNet**: the `/images/controlnet` + `/depth-guided` routes run the
182
+ real Z-Image Fun-Controlnet-Union when weights are present (canny/depth preprocessing),
183
+ and inline `<lora:name:weight>` applies on every image route.
184
+ - **Anthropic-compatible** `/v1/messages` (+ `count_tokens`).
185
+ - **Multimodal retrieval**: `Qwen3-VL-Embedding` (text / image / cross-modal in one
186
+ shared space) on `/v1/embeddings`, and `Qwen3-VL-Reranker` true cross-encoder on
187
+ `/v1/rerank` (bi-encoder cosine fallback otherwise).
188
+ - **Vision/VLM, OCR, ASR, TTS, image & video generation, MCP** server/client.
189
+ - **Single-node decoding/optimization**: single-request fast path (`mlx-lm
190
+ generate_step`), KV prefix + prompt caching, lossless n-gram speculative decode
191
+ on greedy (default-on), per-request top-nσ sampler, constrained decoding
192
+ (JSON-schema/regex/grammar), jump-forward, GPU sampler, in-memory MXFP4/NVFP4
193
+ weight quant, automatic KV quant. The situational ones are opt-in (see
194
+ [docs/CONFIGURATION.md](docs/CONFIGURATION.md)).
195
+ - Single-model mode serves the loaded model under any requested name
196
+ (Ollama/LM-Studio behavior); multi-model auto-discovery via `YUNSHU_MODELS_DIR`.
197
+ - Docs: [API reference](docs/API.md), [configuration reference](docs/CONFIGURATION.md),
198
+ runnable [examples/](examples/).
199
+
200
+ ### Changed
201
+
202
+ - **Refocused** from an over-scoped "distributed inference platform" to an honest
203
+ single-node omni engine. Removed: multi-node mesh / distributed paths
204
+ (sharded-load, disaggregated prefill/decode), the multi-tenant control plane,
205
+ and tiered-KV offload. All single-node decoding/optimization tech is kept.
206
+
207
+ ### Notes
208
+
209
+ - macOS + Apple Silicon only (wraps MLX; no custom Metal kernels). Python 3.13+, `uv`.
210
+ - Apache-2.0 licensed.
yunshu-0.1.1/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024-2026 Yuhuan
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.