argus-cache 0.7.0__tar.gz → 0.8.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 (157) hide show
  1. {argus_cache-0.7.0 → argus_cache-0.8.1}/CHANGELOG.md +119 -1
  2. {argus_cache-0.7.0 → argus_cache-0.8.1}/MANIFEST.in +2 -0
  3. argus_cache-0.8.1/PKG-INFO +492 -0
  4. argus_cache-0.8.1/README.md +444 -0
  5. argus_cache-0.8.1/README_TR.md +475 -0
  6. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/adapters/__init__.py +0 -14
  7. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/adapters/base.py +1 -1
  8. argus_cache-0.8.1/argus_cache/adapters/llama_server.py +325 -0
  9. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/adapters/ollama.py +14 -108
  10. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/backend_pool.py +1 -1
  11. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/direct_attention.py +1 -1
  12. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/memory_manager.py +3 -17
  13. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/page_table.py +2 -2
  14. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/telemetry.py +2 -2
  15. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/tier_registry.py +1 -1
  16. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/zero_copy_pool.py +0 -1
  17. argus_cache-0.8.1/argus_cache/csrc/argus_config.h +275 -0
  18. argus_cache-0.8.1/argus_cache/csrc/argus_hetero.h +214 -0
  19. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_cuda_attention.cu +12 -43
  20. argus_cache-0.8.1/argus_cache/csrc/ggml_cuda_external.cu +88 -0
  21. argus_cache-0.8.1/argus_cache/csrc/ggml_cuda_external.h +35 -0
  22. argus_cache-0.8.1/argus_cache/csrc/ggml_decode_attention.cpp +968 -0
  23. argus_cache-0.8.1/argus_cache/csrc/ggml_decode_attention.h +86 -0
  24. argus_cache-0.8.1/argus_cache/csrc/ggml_decode_e1.h +251 -0
  25. argus_cache-0.8.1/argus_cache/csrc/ggml_decode_simd.h +223 -0
  26. argus_cache-0.8.1/argus_cache/csrc/ggml_kv_tiers.cpp +373 -0
  27. argus_cache-0.8.1/argus_cache/csrc/ggml_kv_tiers.h +77 -0
  28. argus_cache-0.8.1/argus_cache/csrc/ggml_layer_prefill.cpp +998 -0
  29. argus_cache-0.8.1/argus_cache/csrc/ggml_layer_prefill.h +109 -0
  30. argus_cache-0.8.1/argus_cache/csrc/ggml_split_attention.cu +919 -0
  31. argus_cache-0.8.1/argus_cache/csrc/ggml_split_attention.h +29 -0
  32. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/models/hybrid_cache.py +4 -4
  33. argus_cache-0.8.1/argus_cache/webui/__init__.py +4 -0
  34. argus_cache-0.8.1/argus_cache/webui/agent_loop.py +604 -0
  35. argus_cache-0.8.1/argus_cache/webui/compaction.py +213 -0
  36. argus_cache-0.8.1/argus_cache/webui/doc_markdown.py +622 -0
  37. argus_cache-0.8.1/argus_cache/webui/hermes_pc.py +568 -0
  38. argus_cache-0.8.1/argus_cache/webui/hermes_vision.py +788 -0
  39. argus_cache-0.8.1/argus_cache/webui/permissions.py +192 -0
  40. argus_cache-0.8.1/argus_cache/webui/research_tools.py +342 -0
  41. argus_cache-0.8.1/argus_cache/webui/server.py +591 -0
  42. argus_cache-0.8.1/argus_cache/webui/static/app.js +798 -0
  43. argus_cache-0.8.1/argus_cache/webui/static/chat.css +360 -0
  44. argus_cache-0.8.1/argus_cache/webui/static/index.html +208 -0
  45. argus_cache-0.8.1/argus_cache/webui/static/markdown.js +116 -0
  46. argus_cache-0.8.1/argus_cache/webui/static/studio_panels.js +565 -0
  47. argus_cache-0.8.1/argus_cache/webui/static/study_deck.js +571 -0
  48. argus_cache-0.8.1/argus_cache/webui/static/study_research.css +330 -0
  49. argus_cache-0.8.1/argus_cache/webui/static/styles.css +183 -0
  50. argus_cache-0.8.1/argus_cache/webui/store.py +406 -0
  51. argus_cache-0.8.1/argus_cache/webui/study_tools.py +132 -0
  52. argus_cache-0.8.1/argus_cache/webui/tools.py +561 -0
  53. argus_cache-0.8.1/argus_cache/webui/web_search.py +226 -0
  54. argus_cache-0.8.1/argus_cache.egg-info/PKG-INFO +492 -0
  55. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache.egg-info/SOURCES.txt +41 -2
  56. argus_cache-0.8.1/argus_cache.egg-info/entry_points.txt +2 -0
  57. argus_cache-0.8.1/argus_cache.egg-info/requires.txt +20 -0
  58. {argus_cache-0.7.0 → argus_cache-0.8.1}/integrations/llama.cpp/README.md +52 -5
  59. argus_cache-0.8.1/integrations/llama.cpp/argus.patch +1694 -0
  60. argus_cache-0.8.1/integrations/llama.cpp/v08-kv.patch +1412 -0
  61. {argus_cache-0.7.0 → argus_cache-0.8.1}/pyproject.toml +14 -9
  62. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_adapters.py +90 -2
  63. argus_cache-0.8.1/tests/test_argus_service.py +120 -0
  64. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_import_hygiene.py +43 -2
  65. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_native_llama_paged.py +29 -7
  66. argus_cache-0.8.1/tests/test_webui.py +806 -0
  67. argus_cache-0.8.1/tests/test_webui_agent_and_hermes.py +515 -0
  68. argus_cache-0.7.0/PKG-INFO +0 -534
  69. argus_cache-0.7.0/README.md +0 -494
  70. argus_cache-0.7.0/README_TR.md +0 -551
  71. argus_cache-0.7.0/argus_cache/adapters/claude_gateway.py +0 -902
  72. argus_cache-0.7.0/argus_cache.egg-info/PKG-INFO +0 -534
  73. argus_cache-0.7.0/argus_cache.egg-info/requires.txt +0 -11
  74. argus_cache-0.7.0/tests/test_argus_service.py +0 -570
  75. argus_cache-0.7.0/tests/test_claude_gateway.py +0 -358
  76. {argus_cache-0.7.0 → argus_cache-0.8.1}/LICENSE +0 -0
  77. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/__init__.py +0 -0
  78. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/adapters/vllm.py +0 -0
  79. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/backends/__init__.py +0 -0
  80. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/backends/eviction.py +0 -0
  81. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/backends/quantization.py +0 -0
  82. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/__init__.py +0 -0
  83. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/activation.py +0 -0
  84. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/balloon_driver.py +0 -0
  85. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/dashboard.py +0 -0
  86. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/disk_pool.py +0 -0
  87. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/granularity.py +0 -0
  88. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/host_spill.py +0 -0
  89. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/jl_operators.py +0 -0
  90. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/logger.py +0 -0
  91. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/outliers.py +0 -0
  92. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/page_store.py +0 -0
  93. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/pool_allocator.py +0 -0
  94. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/quantization.py +0 -0
  95. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/core/triton_kernels.py +0 -0
  96. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/bindings.cpp +0 -0
  97. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_cuda_attention.h +0 -0
  98. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_disk_buffer.cpp +0 -0
  99. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_disk_buffer.h +0 -0
  100. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_disk_gpu.cpp +0 -0
  101. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_disk_store.h +0 -0
  102. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_host_buffer.cpp +0 -0
  103. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_host_buffer.h +0 -0
  104. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_kv_policy.cpp +0 -0
  105. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_kv_policy.h +0 -0
  106. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_paged_attention.cpp +0 -0
  107. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/ggml_profile.h +0 -0
  108. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/manager.cpp +0 -0
  109. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/manager.h +0 -0
  110. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/quantization_kernels.cu +0 -0
  111. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/tier_codec.cpp +0 -0
  112. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/tier_codec.h +0 -0
  113. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/zero_copy_pool.cpp +0 -0
  114. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/csrc/zero_copy_pool.h +0 -0
  115. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/models/__init__.py +0 -0
  116. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/models/attention_wrapper.py +0 -0
  117. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/models/hf_attention.py +0 -0
  118. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/plugins/__init__.py +0 -0
  119. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/plugins/capabilities.py +0 -0
  120. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache/plugins/registry.py +0 -0
  121. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache.egg-info/dependency_links.txt +0 -0
  122. {argus_cache-0.7.0 → argus_cache-0.8.1}/argus_cache.egg-info/top_level.txt +0 -0
  123. {argus_cache-0.7.0 → argus_cache-0.8.1}/integrations/llama.cpp/cuda-kv.patch +0 -0
  124. {argus_cache-0.7.0 → argus_cache-0.8.1}/integrations/llama.cpp/host-kv.patch +0 -0
  125. {argus_cache-0.7.0 → argus_cache-0.8.1}/setup.cfg +0 -0
  126. {argus_cache-0.7.0 → argus_cache-0.8.1}/setup.py +0 -0
  127. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_adaptive_activation.py +0 -0
  128. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_attention_parity_matrix.py +0 -0
  129. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_balloon_driver.py +0 -0
  130. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_baseline_harness.py +0 -0
  131. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_clock_sweep.py +0 -0
  132. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_compression_loss.py +0 -0
  133. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_context_ladder.py +0 -0
  134. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_direct_paged_attention.py +0 -0
  135. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_disk_pages.py +0 -0
  136. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_flash_attention_sink_pinning.py +0 -0
  137. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_granularity_invariants.py +0 -0
  138. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_hf_attention_bridge.py +0 -0
  139. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_host_spill.py +0 -0
  140. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_hybrid_qwen_cache.py +0 -0
  141. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_jl_operators.py +0 -0
  142. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_kv_cache.py +0 -0
  143. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_llama_integration.py +0 -0
  144. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_logger.py +0 -0
  145. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_memory_intelligence.py +0 -0
  146. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_paper_grade_benchmarks.py +0 -0
  147. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_pluggable_backends.py +0 -0
  148. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_plugin_system.py +0 -0
  149. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_pool_allocator.py +0 -0
  150. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_prefetch.py +0 -0
  151. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_quantization.py +0 -0
  152. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_stability.py +0 -0
  153. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_streaming_attention.py +0 -0
  154. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_telemetry_extraction.py +0 -0
  155. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_ui_mate_workload.py +0 -0
  156. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_variable_granularity.py +0 -0
  157. {argus_cache-0.7.0 → argus_cache-0.8.1}/tests/test_zero_copy_pcie.py +0 -0
@@ -1,12 +1,130 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.8.1 — OCR adjustment
4
+
5
+ A patch release for ARGUS Studio's screen reading. It also removes the Claude Code
6
+ integration added in v0.8.0; anything that imported `claude_gateway` should pin
7
+ `argus-cache==0.8.0`.
8
+
9
+ A lighter OCR model was measured and not adopted: RapidOCR (PP-OCRv5 Latin, ONNX)
10
+ read 26/29 of the same hand-read lines in 6.2 s against 29/29 in 3.5 s for the tuned
11
+ Tesseract, missing short words ("go", "Amcı").
12
+
13
+ ### Removed
14
+ - **The Claude Code integration.** ARGUS Studio no longer serves the Anthropic Messages
15
+ API, and the stdlib gateway (`argus_cache.adapters.claude_gateway`, the
16
+ `ClaudeGatewayHandler` / `create_gateway_server` / `MessageFormatAdapter` exports, the
17
+ `argus-gateway` script and the `gateway` extra), the Claude session launcher
18
+ (`claude_session`, `argus_ctl.sh claude`, `scripts/claude_argus.sh`,
19
+ `--sync-claude`) and the OpenAI-to-Anthropic translator are gone. ARGUS serves its own
20
+ Studio UI and an OpenAI-compatible API; it no longer touches `~/.claude/settings.json`.
21
+ - The telemetry UI's per-request panel, whose only data source was the gateway.
22
+
23
+ ### Fixed
24
+ - Studio credited chat timestamps and read ticks as messages ("16:03 ✓✓" read as
25
+ "Siz: 160347") and gave a reply's quoted text to the replier. Lines with fewer than
26
+ two letters are dropped from the chat view, and text repeating an earlier line
27
+ (also truncated, or a letter apart in OCR) is marked `↪ alıntı`.
28
+ - OCR input is no longer shrunk to 1600 px: dark themes are inverted and screens under
29
+ 2000 px are read at 2x. On two real ZapZap captures (29 hand-read lines) recognition
30
+ went from 26/29 to 29/29, picking up short messages such as "go"; Studio's chat read
31
+ took 1.7 s instead of ~3 s.
32
+ - Text in the conversation's message box is labelled as an unsent draft, so the model
33
+ no longer reports a typed-but-unsent message as sent.
34
+ - **Chat lines say who wrote them.** The colour behind each line is sampled and roles are
35
+ learned per screen: the mostly right-aligned bubble colour is `[Siz]`, the left one
36
+ `[Gelen]`, and a darker shade of either is that side's `↪ alıntı` box. On both test
37
+ captures every line was attributed correctly in ~1.8 s, where a vision-language read
38
+ of the same screen took 40 s and still mixed up authors. Without two bubble colours
39
+ (apps without bubbles) the position-based labels stay.
40
+ - An empty message box is reported as empty: the faint placeholder ("Bir mesaj yazın",
41
+ measured contrast 131 against 213 for typed text) is no longer read as an unsent draft.
42
+
43
+ ## v0.8.0 — Long context on a 4 GB card, and a local stack that stays out of the way
44
+
45
+ v0.8 moves `libargus` from paging KV to managing it across GPU and CPU at once, and
46
+ makes the local stack it runs in usable day to day. Numbers below are on an RTX 3050 Ti
47
+ Laptop (4 GB VRAM, PCIe Gen3 x4), 4-core i5-11300H, 32 GB RAM; every figure links to a
48
+ recorded run in the README.
49
+
50
+ ### Added (llama.cpp integration, `argus_cache/csrc/ggml_*`)
51
+ - **K1** CPU decode attention that reads each KV head once (`f32`/`f16`/`q8_0`/`q4_0`),
52
+ within `2e-6` of a `float64` reference and bit-identical across thread counts.
53
+ - **S1** KV tiers with split decode attention: an `f16` GPU mirror sized from free
54
+ VRAM plus K1 over the host KV. On `Qwen3.6-35B-A3B` (`--cpu-moe`) decode is **6.6x**
55
+ stock `-nkvo` at 64K (`12.31` vs `1.86 tok/s`) and **6.0x** at 128K, where stock GPU
56
+ KV does not load.
57
+ - **P2/P3** GPU prefill; P3 streams each layer's MoE experts across PCIe once per prompt
58
+ instead of once per microbatch, sharing VRAM with the KV mirrors: **1.93x** faster
59
+ prefill at 32K, **1.86x** at 64K.
60
+ - **C1** mixed-precision tiers (`q8_0`/`q4_0`, or `K=q8_0, V=q4_0`, in host RAM with an
61
+ `f16` GPU mirror) and opt-in **E1** bounded-mass block skipping.
62
+ - **`ARGUS_AUTO=1`** turns the proven levers on together; the heterogeneous scheduler
63
+ reclaims dead compute-buffer and GGUF host-page reservations.
64
+ - Layer-major prefill for Gemma 4 without per-layer inputs (**not yet measured**).
65
+
66
+ ### Added (local stack)
67
+ - **ARGUS Studio speaks the Anthropic Messages API** on `:8090` (`/v1/messages`,
68
+ `/v1/models`, `/v1/messages/count_tokens`), so Claude Code points at one port. Before
69
+ this, `argus_ctl.sh claude` aimed Claude Code at Studio, which answered 404.
70
+ - `argus-studio` and `argus-gateway` console scripts; a `studio` extra
71
+ (`fastapi`, `uvicorn`, `httpx`, `pydantic`, `python-multipart`); Studio's page now
72
+ ships as package data.
73
+ - `scripts/systemd/`: user services under `argus.target`, started by the compositor after
74
+ login rather than at boot, and an `ARGUS Studio` launcher that opens Studio as an app
75
+ window.
76
+ - **Cold-start warm-up.** With `--load-mode mmap` the first request after boot read the
77
+ experts from the SSD (14-token prefill **9.7 s**). The launcher now reads the GGUF into
78
+ page cache at idle I/O and CPU priority; the same cold start answered in **0.65 s**.
79
+ - Hermes desktop shortcuts are read live from `hyprctl binds -j` and pressed as key
80
+ combinations, so a changed `hyprland.lua` can no longer leave them stale.
81
+
82
+ ### Changed
83
+ - **Ollama is out of the local path.** The gateway and service manager no longer probe,
84
+ start or forward to Ollama; `llama-server` is the only backend. `OllamaAdapter` stays
85
+ as a library adapter.
86
+ - llama-server launch planning moved to `argus_cache.adapters.llama_server`;
87
+ `argus_cache.adapters.ollama` re-exports the old names, so v0.7 imports still work.
88
+ - llama-server's bundled web page is off by default (Studio replaces it). `--jinja` is
89
+ now always passed; it used to be tied to the web page flag.
90
+ - `argus_ctl.sh start` and the systemd launcher share one launch planner (the RAM
91
+ reserve setting had only reached one of them).
92
+ - The OpenAI-to-Anthropic stream translation is one transport-free state machine shared
93
+ by the gateway and Studio; a `length` finish is now reported as `max_tokens`.
94
+ - `requires-python` is `>=3.10` (3.8 and 3.9 are end of life); classifiers 3.10–3.14.
95
+
96
+ ### Removed
97
+ - `create_gateway_server(backend=...)`, `--backend`, `resolve_backend`,
98
+ `build_ollama_options`, `parse_ollama_residency`, `SseUsageTracker`, and the Ollama
99
+ residency rows of the telemetry UI: all served only the Ollama route.
100
+
101
+ ### Fixed
102
+ - **Import on Python 3.10–3.13 (shipped broken in v0.7.0).** `PagedDynamicKVCache`
103
+ annotated with `Dict`/`Any` without importing them; Python 3.14 defers annotations, so
104
+ it only failed on older interpreters, at import. `CacheTelemetry.sync_pending_cuda_events`
105
+ used `torch` without importing it.
106
+ - **Studio read chat screens out of order.** OCR words were grouped in (top, left) order,
107
+ so a right-hand word one pixel higher opened its own line and bubbles came back split
108
+ and reversed. Lines are now built by row; the sidebar split follows the layout's
109
+ gutter instead of a fixed 33%, which had pushed the chat list's timestamps into the
110
+ conversation.
111
+ - Screen readings replayed from earlier turns are labelled as old, so the model re-reads
112
+ the screen instead of answering from another chat's capture.
113
+ - Context compaction counted message text but not the tool output replayed with it, so
114
+ tool-heavy turns grew the context unchecked.
115
+ - Desktop shortcuts that open windows (launcher, terminal, zapret…) ran without asking;
116
+ everything but volume/media/brightness now needs approval.
117
+ - The gateway listened on `0.0.0.0`; it forwards cloud credentials, so it now binds
118
+ loopback by default.
119
+ - ARGUS no longer starts at boot and holds the login screen.
120
+
3
121
  ## v0.7.0 — Closing the measured gap, exactly
4
122
 
5
123
  v0.7 was an optimization campaign on one workload: Qwen2.5-0.5B-Instruct Q4_K_M,
6
124
  F16 KV, 4K context, RTX 3050 Ti Laptop. Every step kept every ARGUS attention path
7
125
  bit-exact with the staged reference; the output hash is `a152ed56` throughout.
8
126
 
9
- Final baseline (profiler off, 5 repeats, MCP indexers paused, commit `17ad9c2`):
127
+ Final baseline (profiler off, 5 repeats, MCP indexers paused, commit `95c74fa`):
10
128
 
11
129
  | mode | prefill | vs stock | decode |
12
130
  |---|---:|---:|---:|
@@ -11,6 +11,8 @@ recursive-include argus_cache/csrc *.h *.cuh *.cpp *.cu
11
11
  # they compile, so a PyPI install has everything the README's build steps need.
12
12
  include README_TR.md
13
13
  recursive-include integrations/llama.cpp *.patch *.md
14
+ # Studio's page, scripts and styles are package data, not code.
15
+ recursive-include argus_cache/webui/static *
14
16
 
15
17
  # Never ship build artifacts or local measurement scratch.
16
18
  prune build
@@ -0,0 +1,492 @@
1
+ Metadata-Version: 2.4
2
+ Name: argus_cache
3
+ Version: 0.8.1
4
+ Summary: Paged KV-cache memory manager for LLM runtimes: GPU/pinned/RAM/disk tiers for llama.cpp with exact CUDA attention, plus a quantized-tier research path for HuggingFace
5
+ Author: Muhammed Emin Çelik
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Zwannfrederick/ARGUS-Anchored-Random-Geometric-Unbiased-Storage
8
+ Project-URL: Repository, https://github.com/Zwannfrederick/ARGUS-Anchored-Random-Geometric-Unbiased-Storage
9
+ Project-URL: Changelog, https://github.com/Zwannfrederick/ARGUS-Anchored-Random-Geometric-Unbiased-Storage/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/Zwannfrederick/ARGUS-Anchored-Random-Geometric-Unbiased-Storage/issues
11
+ Keywords: kv-cache,quantization,transformers,llm-inference,paged-attention,memory-management,cuda,vram
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: C++
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: System :: Hardware :: Symmetric Multi-processing
24
+ Classifier: Operating System :: POSIX :: Linux
25
+ Classifier: Environment :: GPU :: NVIDIA CUDA
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: torch>=2.0.0
30
+ Requires-Dist: triton>=2.0.0
31
+ Requires-Dist: transformers>=4.38.0
32
+ Provides-Extra: studio
33
+ Requires-Dist: fastapi; extra == "studio"
34
+ Requires-Dist: uvicorn; extra == "studio"
35
+ Requires-Dist: httpx; extra == "studio"
36
+ Requires-Dist: pydantic; extra == "studio"
37
+ Requires-Dist: python-multipart; extra == "studio"
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest; extra == "dev"
40
+ Requires-Dist: matplotlib; extra == "dev"
41
+ Requires-Dist: httpx; extra == "dev"
42
+ Requires-Dist: fastapi; extra == "dev"
43
+ Requires-Dist: uvicorn; extra == "dev"
44
+ Requires-Dist: pydantic; extra == "dev"
45
+ Requires-Dist: python-multipart; extra == "dev"
46
+ Requires-Dist: ruff; extra == "dev"
47
+ Dynamic: license-file
48
+
49
+ # ARGUS (`libargus`)
50
+
51
+ **An autonomous C++/CUDA KV-cache and MoE bandwidth orchestrator for LLM runtimes.
52
+ Instead of pinning the KV cache and expert weights to a single device, `libargus`
53
+ orchestrates them across a phase-shared hierarchy — GPU VRAM, pinned RAM, pageable
54
+ RAM, and verified `O_DIRECT` disk — so long contexts and large MoE models can run
55
+ within tight VRAM budgets while outperforming host-offloaded baselines in both
56
+ prefill and decode.**
57
+
58
+ ARGUS is not an inference server. It is the systems layer underneath one (`llama.cpp`
59
+ / GGML), owning where each KV cell or page lives, how it is written, how prefill
60
+ streams expert weights across PCIe, and how decode attention reads across GPU and
61
+ CPU tiers at the same time.
62
+
63
+ **Status: v0.8.1.** Measured results on an RTX 3050 Ti Laptop (4 GB VRAM, PCIe Gen3 x4,
64
+ 4-core Intel i5-11300H):
65
+ - **Heterogeneous CPU/GPU Execution Scheduler & Adaptive RAM/VRAM Memory Manager (`ARGUS_AUTO=1`):**
66
+ On `Qwen3.6-35B-A3B` (`Q4_K_M`, 4 GB VRAM + 32 GB RAM), the heterogeneous scheduler (`ARGUS_HETERO_SCHED=1`, `ARGUS_HETERO_OVERLAP=1`) eliminates `150 MiB` of dead MoE compute-buffer reservations, bounds P3 graph reservation to a 2-layer envelope (`u_batch=512`, `n_outputs_max=16`), eliminates 480–960 redundant Gated DeltaNet graph rebuilds and `34.23–132.87 GiB` of unused `kq_mask` CPU writes, reclaims `1,521.9 MiB` of non-active GGUF host pages, and overlaps GPU `ffn_shexp` with CPU `RoutedExperts` via asynchronous batched PCIe transfers (`-48.9%` split sync latency). At **32K**, `CUDA0` compute buffer drops by **80.0%–85.0%** (`879.3 MiB` / `658.1 MiB` → **`132.03 MiB`**, saving **`524.0 MiB` VRAM**), prefill reaches **`431.93 tok/s`** (`73.49 s`, **`+49.1%`** over prior baseline), and decode doubles (`2.01x`, `p50` cut from `516.29 ms` to `259.85 ms`) under constrained RAM pressure while reaching **`14.50–21.93 tok/s`** (`45.60 ms/tok`) in warm RAM. At **64K (`65,536`)**, 100% of KV cells (`1,280.0 MiB`) fit in the `S1` GPU mirror on 4 GB VRAM (`376.87 tok/s` prefill, `5.29 tok/s` median decode, `3/3` multi-needle accuracy across 8K, 32K, and 64K) ([Hetero report](docs/measurements/v080-libargus-2026-10-27/hetero_architecture_report.md)).
67
+ - **35B MoE at 32K–128K filled context (`Qwen3.6-35B-A3B` Q4_K_M, `--cpu-moe`):**
68
+ At 64K and 128K context, stock GPU KV cannot start (VRAM OOM). Against stock
69
+ `-nkvo`, `libargus` (`S1` split decode + `K1` CPU attention + `P2` GPU prefill)
70
+ delivers **6.6x faster decode at 64K** (`12.31` vs `1.86 tok/s`) and **6.0x faster
71
+ decode at 128K** (`6.18` vs `1.02 tok/s`), while `P3` layer-major prefill cuts
72
+ 32K/64K prefill time by **1.93x / 1.86x** (`114.3 s → 59.1 s` at 32K; `242.2 s →
73
+ 130.4 s` at 64K) by streaming each layer's MoE experts across PCIe once per prompt
74
+ instead of once per microbatch ([M1](docs/measurements/v080-m1-2026-09-27/README.md),
75
+ [P3](docs/measurements/v080-prefill-2026-09-28/README.md)).
76
+ - **Mixed-Precision Tiers (`C1`), Multipole / V-Centroid Bounded-Mass Skipping (`E1`), & Sparse MoE `MADV_RANDOM` (`ARGUS_AUTO=1`):**
77
+ On 8K filled context (`Qwen2.5-0.5B-Instruct` Q4_K_M), default `ARGUS_AUTO=1` with
78
+ asymmetric `K=q8_0, V=q4_0` host KV (**-59.4% host KV RAM** + `f16` GPU mirror) cuts
79
+ prefill time to **0.815 s (9,936 tok/s, 1.10x faster than stock)** and accelerates
80
+ decode from **23.18 tok/s** (stock `-nkvo`) to **175.45 tok/s (7.57x)** while cutting
81
+ peak RSS by **75.0 MiB**. Under a strict 16 MiB split mirror (1280 GPU + 6912 host
82
+ cells), `ARGUS_AUTO=1` reaches **79.54 tok/s (3.43x)** on `f16` and **69.60 tok/s
83
+ (3.00x)** on `K=q8_0, V=q4_0`, retrieving the hidden 6-digit needle in every mode.
84
+ In standalone 16K–128K synthetic kernel benchmarks (without QK-Norm), `K1`
85
+ exact is **9.9x–10.1x faster** than stock GGML CPU FlashAttention (`5.79 ms` vs
86
+ `57.43 ms` at 64K; `11.35 ms` vs `114.72 ms` at 128K, with `q8_0` reaching `10.95 ms`),
87
+ and `K1 + E1` bounded-mass block skipping (`ARGUS_KV_SKIP_EPS=1e-4`) reaches **0.91 ms
88
+ (62.8x faster)** at 64K `f16` and **2.56 ms (44.9x faster)** at 128K `f16`/`q4_0`
89
+ (**44.1x faster than stock `f16` with 47% less RAM** on `q8_0`) at `< 6.1e-7` relative
90
+ error ([v0.8 levers](docs/measurements/v080-libargus-2026-10-27/README.md)).
91
+ - **Direct-disk paged KV (v0.7 path, 4K context, `Qwen2.5-0.5B`):**
92
+ Prefill is **1.29x** stock llama.cpp's time with all KV on GPU and **1.36x** with the
93
+ placement policy managing GPU/pinned/RAM/disk tiers; decode is **55.6** and
94
+ **48.2 tok/s** vs stock's **37.5 tok/s** ([v0.7 baseline](docs/measurements/v070-e10-2026-09-26/)).
95
+
96
+ [![packaging](https://github.com/Zwannfrederick/ARGUS-Anchored-Random-Geometric-Unbiased-Storage/actions/workflows/packaging.yml/badge.svg)](https://github.com/Zwannfrederick/ARGUS-Anchored-Random-Geometric-Unbiased-Storage/actions/workflows/packaging.yml)
97
+
98
+ Türkçe belge: [README_TR.md](README_TR.md)
99
+
100
+ ---
101
+
102
+ ## Contents
103
+
104
+ - [Status at a glance](#status-at-a-glance)
105
+ - [What ARGUS is and is not](#what-argus-is-and-is-not)
106
+ - [Architecture: The Five Levers of `libargus`](#architecture-the-five-levers-of-libargus)
107
+ - [Using `libargus` with llama.cpp](#using-libargus-with-llamacpp) — build, autonomous mode, tiers, disk modes, every setting
108
+ - [Local stack: ARGUS Studio and the services](#local-stack-argus-studio-and-the-services)
109
+ - [v0.8 results: Long-context tiers, MoE prefill, C1 & E1](#v08-results-long-context-tiers-moe-prefill-c1--e1)
110
+ - [v0.7 results: Direct-disk paged KV](#v07-results-direct-disk-paged-kv)
111
+ - [Reading the stock comparison](#reading-the-stock-comparison)
112
+ - [Using ARGUS with HuggingFace (legacy research path)](#using-argus-with-huggingface-legacy-research-path)
113
+ - [Benchmark methodology](#benchmark-methodology)
114
+ - [Known limits](#known-limits)
115
+ - [Earlier evidence (v0.4–v0.6)](#earlier-evidence-v04v06)
116
+ - [Roadmap](#roadmap)
117
+
118
+ ---
119
+
120
+ ## Status at a glance
121
+
122
+ Nothing here is a projection. Every number is a recorded run you can open; every
123
+ behaviour is backed by a test that fails if it stops being true; anything that has
124
+ not been measured says **Not measured**.
125
+
126
+ | Claim | Status | Evidence |
127
+ |---|---|---|
128
+ | `ARGUS_AUTO=1` autonomously enables K1 CPU decode, S1 VRAM mirrors, P2 GPU prefill, P3 layer-major prefill, `MADV_RANDOM` on sparse MoE tensors, and the Heterogeneous CPU/GPU Execution Scheduler & Adaptive RAM/VRAM Manager (`ARGUS_HETERO_SCHED=1`, `ARGUS_HETERO_OVERLAP=1`), while keeping E1, Multipole, Hot-Expert Cache, and Top-$r$ opt-in | Proven | [`argus_config.h`](argus_cache/csrc/argus_config.h), [`argus_hetero.h`](argus_cache/csrc/argus_hetero.h), [`hetero_architecture_report.md`](docs/measurements/v080-libargus-2026-10-27/hetero_architecture_report.md) |
129
+ | K1 CPU decode attention (`f32`/`f16`/`q8_0`/`q4_0`) is within `2e-6` of `float64` reference and bit-identical across `{1,2,3,4,8}` threads | Proven (10 geometries, SIMD + scalar; `< 3e-7` isolated error across all 10 full-attention layers of `Qwen3.6-35B-A3B`) | [`test_ggml_decode_attention.cpp`](tests/cpp/test_ggml_decode_attention.cpp), [`v0.8 report`](docs/measurements/v080-libargus-2026-10-27/README.md) |
130
+ | S1 split decode attention (GPU `f16` mirror + CPU `K1` on `f16`/`q8_0`/`q4_0` host KV) matches `float64` reference within `2e-6` | Proven (7 `f16` + 2 `C1` mixed-precision cases) | [`test_ggml_split_attention.cpp`](tests/cpp/test_ggml_split_attention.cpp) |
131
+ | E1 + Multipole bounded-mass approximate skipping (`ARGUS_KV_SKIP_EPS=1e-4`, `ARGUS_MULTIPOLE=1`) prunes `12.0%–12.6%` K-blocks and `34.8%–60.2%` V-cells on real `Qwen3.6-35B-A3B` while reducing attention output error `2.4x–11.4x`, 8K mean KL divergence vs `E1 OFF` by `40%` (`2.50e-5`), and 32K max logit error by `2.79x` (`1.064` vs `2.969`) | Proven (8K & 32K 8-mode ablation on `Qwen3.6-35B-A3B`, `3/3` needles; synthetic non-QK-Norm kernel benchmark reaches `62.8x` at 64K `f16`) | [`real_a3b_validation.json`](docs/measurements/v080-libargus-2026-10-27/real_a3b_validation.json), [`README.md`](docs/measurements/v080-libargus-2026-10-27/README.md) |
132
+ | C1 mixed-precision tiers (`q8_0`, `q4_0`, or asymmetric `K=q8_0, V=q4_0` in host RAM + `f16` GPU mirror) cut host KV RAM by 47%–72% while accelerating decode 2.9x–7.6x over stock `-nkvo` | Proven at 8K on `Qwen2.5-0.5B` (`needle_found: true` on `f16`, `q8_0`, and `K=q8_0/V=q4_0`; `0.815 s` prefill and `175.45 tok/s` decode with `auto` mirror) | [`bench_e2e_result.json`](docs/measurements/v080-libargus-2026-10-27/README.md) |
133
+ | 64K & 128K decode on `Qwen3.6-35B-A3B` (`--cpu-moe`) where stock GPU KV OOMs | Proven: **6.6x faster** than stock `-nkvo` at 64K (`12.31` vs `1.86 tok/s`), **6.0x faster** at 128K (`6.18` vs `1.02 tok/s`), needle found | [M1 report](docs/measurements/v080-m1-2026-09-27/README.md) |
134
+ | P3 layer-major MoE prefill with phase-shared VRAM arena on `Qwen3.6-35B-A3B` | Proven at 5.3K–64K (**1.93x faster** at 32K, **1.86x faster** at 64K); 128K adaptive VRAM budget planner unit-tested, 128K live P3 run **Not measured** | [P3 report](docs/measurements/v080-prefill-2026-09-28/README.md), [`test_ggml_decode_attention.cpp`](tests/cpp/test_ggml_decode_attention.cpp) |
135
+ | Direct-disk KV pages migrate GPU ↔ pinned ↔ pageable ↔ disk, checksum-verified (`crc32c`), corrupt pages refused | Proven | [`test_ggml_cuda_mechanism.cpp`](tests/cpp/test_ggml_cuda_mechanism.cpp), [`test_ggml_disk_buffer.cpp`](tests/cpp/test_ggml_disk_buffer.cpp) |
136
+ | Unsupported attention features or `-np > 1` fall back cleanly to llama.cpp's own KV cache at load | Proven | [`test_unsupported_model_falls_back_to_stock_kv_at_load`](tests/test_native_llama_paged.py) |
137
+ | Long-context throughput at 262K | **Not measured** | — |
138
+ | End-to-end 32K–128K runs on `Gemma-4-26B-A4B` and `UI-Mate-9B` | **Not measured** (kernel geometries verified in `K1`/`S1`) | — |
139
+ | Quality under INT4, INT2, 1-bit or JL tiers on the HuggingFace research path | **Not measured**; only FP8 was reached | [Quality](#quality-huggingface-path) |
140
+
141
+ Local verification suites on the development machine (Python 3.14): Python **375 passed, 27 skipped**
142
+ (import/repo hygiene included); native `llama.cpp` K1 (`simd` + `scalar`) and S1/C1
143
+ CUDA split-attention suites **all passed**.
144
+
145
+ ---
146
+
147
+ ## What ARGUS is and is not
148
+
149
+ - **Not an inference server.** Sampling, batching, HTTP serving, and GGUF loading stay
150
+ in `llama.cpp`. `libargus` hooks into `llama.cpp`'s KV cache, graph builder, and
151
+ execution loop via three focused patches (`host-kv.patch`, `cuda-kv.patch`,
152
+ `v08-kv.patch`).
153
+ - **Two complementary operating families in one library:**
154
+ 1. **v0.8 In-Memory & MoE Orchestrator (`ARGUS_AUTO=1`):** Operates directly on
155
+ `llama.cpp`'s `-nkvo` host KV cache (`f16`, `q8_0`, `q4_0`). Mirrors the hot prefix
156
+ in `f16` GPU VRAM (`S1`), computes the remaining host KV with grouped SIMD CPU
157
+ decode (`K1`) and optional bounded-mass approximate skipping (`E1` + `Multipole` V-centroid compensation), runs prefill attention
158
+ on the GPU (`P2`), shares the VRAM arena between prefill MoE expert caches and
159
+ decode KV mirrors (`P3`), and applies `POSIX_MADV_RANDOM` to sparse host MoE expert tensors.
160
+ 2. **v0.7 Direct-Disk Paged Store (`ARGUS_KV_DIR`):** Places KV in an unlinked
161
+ `O_DIRECT` backing file with 4 KiB checksummed pages promoted/demoted across GPU,
162
+ pinned RAM, pageable RAM, and disk within strict byte budgets.
163
+ - **Honest scope.** Experimental side projects (`hermes`, `neo-mobile`, container
164
+ experiments) are archived under [`experiments/`](experiments/README.md) and excluded
165
+ from the package.
166
+
167
+ ---
168
+
169
+ ## Architecture: The Five Levers of `libargus`
170
+
171
+ ```text
172
+ llama.cpp (-nkvo -fa on) + libargus (ARGUS_AUTO=1)
173
+ |
174
+ +-- [Prefill Phase] ----------------------------------------------------------+
175
+ | 1. P3 Layer-Major MoE Prefill (ggml_layer_prefill.cpp): |
176
+ | Detaches KV mirrors, borrows the phase-shared VRAM arena to stage one |
177
+ | layer's MoE experts on the GPU across all ubatches (1x PCIe transfer |
178
+ | per layer instead of N_ubatches x), then refills KV mirrors from host. |
179
+ | 2. P2 GPU Prefill Attention (ggml_kv_tiers.cpp): |
180
+ | Streams the host K/V view to the GPU once per batch for FlashAttention.|
181
+ | |
182
+ +-- [Decode Phase] -----------------------------------------------------------+
183
+ 1. C1 Mixed-Precision Write-Through (ggml_split_attention.cu):
184
+ A single CUDA kernel writes new KV rows in F16 to the GPU mirror and
185
+ in F16, Q8_0, or Q4_0 to pinned host memory.
186
+ 2. S1 Split Decode Attention (ggml_split_attention.cu + ggml_kv_tiers.cpp):
187
+ GPU computes softmax partials (max, sum, weighted V) over mirrored
188
+ cells [0, G) in VRAM while CPU computes partials over [G, n_kv) in RAM;
189
+ both merge by exact log-sum-exp reduction.
190
+ 3. K1 Grouped SIMD CPU Decode + E1 Bounded-Mass Skipping (ggml_decode_attention.cpp):
191
+ Reads each KV head once for all GQA query heads with AVX2/AVX-512
192
+ in-register decoding (F16, Q8_0, Q4_0). With ARGUS_KV_SKIP_EPS > 0,
193
+ uses cached [mu_k, rad_k, mu_v] multipole boxes and sink watermarks to skip
194
+ blocks/cells with bounded softmax mass and compensate skipped V cells via mu_v.
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Using `libargus` with llama.cpp
200
+
201
+ ### 1. Build `llama.cpp` with `libargus`
202
+
203
+ `libargus` patches pinned `llama.cpp` revision `54315813269112dd0baed7112ec87ad93a8218ca`
204
+ (see [`integrations/llama.cpp/README.md`](integrations/llama.cpp/README.md)). Apply the
205
+ three patches in order (or the single combined `argus.patch`) and point CMake at `argus_cache/csrc`:
206
+
207
+ ```bash
208
+ git -C /path/to/llama.cpp apply /path/to/ARGUS/integrations/llama.cpp/host-kv.patch
209
+ git -C /path/to/llama.cpp apply /path/to/ARGUS/integrations/llama.cpp/cuda-kv.patch
210
+ git -C /path/to/llama.cpp apply /path/to/ARGUS/integrations/llama.cpp/v08-kv.patch
211
+ cmake -S /path/to/llama.cpp -B /path/to/llama.cpp/build-cuda \
212
+ -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 \
213
+ -DARGUS_CORE_DIR=/path/to/ARGUS/argus_cache/csrc
214
+ cmake --build /path/to/llama.cpp/build-cuda --target llama-server -j4
215
+ ```
216
+
217
+ With no `ARGUS_*` environment variable set, the compiled binary behaves identically to
218
+ stock `llama.cpp`.
219
+
220
+ ### 2. Recommended v0.8 Modes (`ARGUS_AUTO=1`)
221
+
222
+ ```bash
223
+ # 1. Zero-config autonomous mode (F16 host KV + auto F16 VRAM mirror + K1 + P2 + P3 + MADV_RANDOM)
224
+ export ARGUS_AUTO=1
225
+ llama-server -m model.gguf -c 65536 -ngl 99 --cpu-moe -fa on -nkvo -b 65536 -ub 2048
226
+
227
+ # 2. C1 Asymmetric Mixed-Precision (~60% less host KV RAM, F16 GPU mirror) + Opt-in E1 Multipole Bounded-Mass Skip
228
+ export ARGUS_AUTO=1
229
+ export ARGUS_KV_SKIP_EPS=1e-4
230
+ export ARGUS_MULTIPOLE=1
231
+ llama-server -m model.gguf -c 65536 -ngl 99 -fa on -nkvo -ctk q8_0 -ctv q4_0
232
+ ```
233
+
234
+ ### 3. v0.8 Configuration Reference (`argus_config.h`)
235
+
236
+ | Variable | Values | Meaning |
237
+ |---|---|---|
238
+ | `ARGUS_AUTO` | `1` / `on` / `0` / `off` | Enables autonomous orchestration (`ARGUS_KV_CPU_ATTENTION=k1`, `ARGUS_KV_VRAM_BYTES=auto`, `ARGUS_KV_PREFILL=gpu`, `ARGUS_PREFILL=layers`, `ARGUS_MADV_RANDOM=1`; keeps `ARGUS_KV_SKIP_EPS=0.0`, `ARGUS_MULTIPOLE=0`, `ARGUS_MOE_CACHE=0`, `ARGUS_TOP_R=0` opt-in). Any explicit variable below overrides its respective knob. |
239
+ | `ARGUS_KV_CPU_ATTENTION` | `k1` / `stock` | Selects K1 grouped SIMD CPU decode attention over host KV. |
240
+ | `ARGUS_K1_MAX_TOKENS` | integer (default `16`) | Maximum batch token count handled by the K1 / S1 decode path (covers single-token decode and speculative / MTP draft batches). |
241
+ | `ARGUS_KV_SKIP_EPS` | float in `[0, 1)` (default `0.0`) | Opt-in E1 bounded-mass approximate skipping threshold (or `ARGUS_E1=1` for `1e-4`). `0.0` is exact; `1e-4` prunes cold 32-cell K-blocks and V-cells. |
242
+ | `ARGUS_MULTIPOLE` | `1` / `on` / `0` / `off` (default `0`) | Opt-in Multipole monopole/dipole K-box bounds and V-centroid compensation (`W_skip * mu_V`) when `ARGUS_KV_SKIP_EPS > 0`. |
243
+ | `ARGUS_MADV_RANDOM` | `1` / `on` / `0` / `off` (default `1` in `ARGUS_AUTO`) | Applies `POSIX_MADV_RANDOM` to host MoE expert tensors (`--cpu-moe`), disabling OS sequential readahead bloat. |
244
+ | `ARGUS_MOE_CACHE` | `1` / `on` / `0` / `off` (default `0`) | Opt-in frequency-tracked hot-expert cache (`mlock` / `MADV_COLD`, `ARGUS_HOT_EXPERTS=32`) for systems with raised `RLIMIT_MEMLOCK` (`ulimit -l`). |
245
+ | `ARGUS_TOP_R` | `1` / `on` / `0` / `off` (default `0`) | Opt-in Top-$r$ (`r=32`) Cauchy-Schwarz tail bound for K-boxes (disabled by default because QK-Norm models have flat channel spectra). |
246
+ | `ARGUS_KV_VRAM_BYTES` | `auto` or byte count | Enables S1 `F16` GPU mirrors of `-nkvo` host KV (`f16`, `q8_0`, `q4_0`). `auto` sizes the arena from free VRAM after compute buffers are reserved. |
247
+ | `ARGUS_KV_VRAM_MARGIN` | byte count (default `256 MiB`) | Free VRAM margin kept by `ARGUS_KV_VRAM_BYTES=auto` (adapts down to a `64 MiB` safety floor when needed to fit the P3 shared MoE expert cache). |
248
+ | `ARGUS_KV_PREFILL` | `gpu` / `cpu` | P2: runs prefill FlashAttention on the GPU when KV lives on the host (`-nkvo`). |
249
+ | `ARGUS_PREFILL` | `layers` / `batches` | P3: runs multi-ubatch prefill layer-major so `--cpu-moe` expert weights cross PCIe once per prompt call, sharing the VRAM arena with S1 KV mirrors. |
250
+
251
+ *(For the v0.7 direct-disk `ARGUS_KV_DIR` settings, see [`integrations/llama.cpp/README.md`](integrations/llama.cpp/README.md).)*
252
+
253
+ ---
254
+
255
+ ## Local stack: ARGUS Studio and the services
256
+
257
+ The repository also ships the stack it is developed on: an ARGUS-built
258
+ `llama-server` plus **ARGUS Studio**, a local chat UI with permissioned tools.
259
+ There is no Ollama in the path.
260
+
261
+ | Port | What | Notes |
262
+ |---|---|---|
263
+ | `8080` | ARGUS `llama-server`, OpenAI API only | llama.cpp's bundled web page is off (`"webui": false`); Studio replaces it |
264
+ | `8090` | ARGUS Studio | chat UI, documents, web search, Hermes desktop tools |
265
+
266
+ ```bash
267
+ pip install --no-build-isolation "argus-cache[studio]" # FastAPI/uvicorn for Studio
268
+ argus-studio --upstream http://127.0.0.1:8080/v1 # UI on :8090
269
+ ```
270
+
271
+ `scripts/install_systemd_service.sh` installs two user services under
272
+ `argus.target`. They do **not** start at boot: loading an 18 GB MoE model alongside
273
+ the display manager held the login screen (measured: the engine started with SDDM
274
+ at 10 s, the desktop arrived 62 s later). The compositor starts the target after
275
+ login (`systemctl --user start argus.target`); the installed `ARGUS Studio`
276
+ launcher does the same and opens Studio as an app window.
277
+
278
+ With `--load-mode mmap` the experts stay on disk until first touched, so the first
279
+ request after boot paid the SSD read (a 14-token prefill took **9.7 s**). The
280
+ launcher now reads the GGUF into page cache at idle I/O and CPU priority
281
+ (`ionice -c3`, `nice 19`; honoured by BFQ), which only spends disk time nobody
282
+ else wants and leaves ordinary reclaimable cache. Same cold start afterwards:
283
+ **0.65 s**.
284
+
285
+ Hermes desktop tools (window list, OCR, clicks, the user's own Hyprland
286
+ shortcuts) load only when `experiments/hermes` is present; the PyPI install runs
287
+ Studio without them. Shortcuts are read live from `hyprctl binds -j` and pressed
288
+ as key combinations, so editing `hyprland.lua` never leaves them stale; anything
289
+ other than volume/media/brightness asks for approval first.
290
+
291
+ ---
292
+
293
+ ## v0.8 results: Long-context tiers, MoE prefill, C1 & E1
294
+
295
+ ### 1. 35B MoE at 32K–128K Filled Context (`Qwen3.6-35B-A3B` UD-Q4_K_M, `--cpu-moe`, `f16` KV)
296
+
297
+ Measured via [`benchmarks/bench_long_context.py`](benchmarks/bench_long_context.py) on
298
+ RTX 3050 Ti Laptop (4 GB) + i5-11300H (4 pinned threads, turbo off). Each context is
299
+ completely filled with prefilled tokens hiding a 6-digit code near the beginning,
300
+ followed by 32 decoded tokens ([M1 data](docs/measurements/v080-m1-2026-09-27/README.md),
301
+ [P3 data](docs/measurements/v080-prefill-2026-09-28/README.md)):
302
+
303
+ | Context | Stock GPU KV Decode | Stock `-nkvo` Decode | `libargus` K1 (`-nkvo`) | `libargus` S1 Tiers (`auto`) | S1 vs Best Stock | Prefill: Batch-Major (`P2`) | Prefill: Layer-Major (`P3`) | `P3` Speedup |
304
+ |---:|---:|---:|---:|---:|---:|---:|---:|---:|
305
+ | **32K** | **22.47 tok/s** | 3.15 tok/s | 13.23 tok/s | 20.12 tok/s | 0.90x | 114.3 s | **59.1 s** | **1.93x** |
306
+ | **64K** | *VRAM OOM* | 1.86 tok/s | 9.49 tok/s | **12.31 tok/s** | **6.6x** | 242.2 s | **130.4 s** | **1.86x** |
307
+ | **128K** | *VRAM OOM* | 1.02 tok/s | 4.41 tok/s | **6.18 tok/s** | **6.0x** | 540.3 s | *Not measured live* ¹ | — |
308
+
309
+ ¹ *At 128K, the original static 256 MiB margin left 386.6 MiB of free VRAM (< 498 MiB needed for the largest layer's experts). `argus_plan_vram_budget` in `argus_config.h` resolves this by adapting the margin to a 64 MiB floor when `free_vram >= shared_expert_bytes + 64 MiB` (verified in unit tests; live 128K P3 rerun is not yet recorded).*
310
+
311
+ ### 1.1 Real `Qwen3.6-35B-A3B` End-to-End Validation & SOTA-3 Ablation (`8192` & `32768`, 3 Warmup + 5 Measured Runs)
312
+
313
+ Measured via [`bench_real_a3b_validation.cpp`](docs/measurements/v080-libargus-2026-10-27/bench_real_a3b_validation.cpp) ([JSON artifact](docs/measurements/v080-libargus-2026-10-27/real_a3b_validation.json), [full report](docs/measurements/v080-libargus-2026-10-27/README.md)) on `Qwen3.6-35B-A3B-UD-Q4_K_M-MTP.gguf` (seed `2026`, deterministic greedy sampling, 32 decoded tokens, 3 needles at 10% / 50% / 85% depth: `657446`, `839204`, `412975`):
314
+
315
+ | Context | Mode | Prefill (`tok/s` / `s`) | TTFT (`s`) | Decode Median (`tok/s`) | Token Lat `p50 / p95` (`ms`) | K-Block Skip % | V-Cell Skip % | Logit `max_abs` (vs Stock / vs E1-OFF) | $\text{KL}_{\text{mean}}$ (vs Stock / vs E1-OFF) | Needles (`10%/50%/85%`) |
316
+ |---:|---|---:|---:|---:|---:|---:|---:|---:|---:|:---:|
317
+ | **8192** | `Stock llama.cpp` *(disk I/O bottleneck)* | 25.1 (`321.68 s`) | 321.85 | **5.73** | `168.0 / 237.6` | 0.00% | 0.00% | `0 / —` | `0 / —` | **3/3** |
318
+ | **8192** | `ARGUS AUTO (E1 OFF)` | **114.9 (`70.21 s`)** | **70.27** | **18.55** | **`48.3` / `65.0`** | 0.00% | 0.00% | `2.14 / 0` | `3.20e-5 / 0` | **3/3** |
319
+ | **8192** | `A: ARGUS AUTO (SOTA-3 OFF)` | 114.9 (`70.21 s`) | 70.27 | **18.31** | `48.9 / 66.5` | **12.49%** | **38.98%** | `2.27 / 1.60` | `3.65e-5 / 4.16e-5` | **3/3** |
320
+ | **8192** | `B: A + MADV_RANDOM` | 114.9 (`70.21 s`) | 70.27 | **18.04** | `49.7 / 68.7` | **12.49%** | **38.98%** | `2.27 / 1.60` | `3.65e-5 / 4.16e-5` | **3/3** |
321
+ | **8192** | `C: B + Hot-Expert Cache` *(68.1% hit)* | 114.9 (`70.21 s`) | 70.27 | **17.95** | `50.4 / 72.3` | **12.49%** | **38.98%** | `2.27 / 1.60` | `3.65e-5 / 4.16e-5` | **3/3** |
322
+ | **8192** | `D: C + Multipole / V-Centroid` | 114.9 (`70.21 s`) | 70.27 | **18.25** | `49.4` / **`64.4`** | **12.57%** | **39.01%** | `7.26 / 7.95` | `3.93e-5` / **`2.50e-5`** | **3/3** |
323
+ | **8192** | `E: D + Top-r` *(disables K-skip)* | 114.9 (`70.21 s`) | 70.27 | **17.49** | `50.0 / 70.0` | `0.00%` | `36.18%` | `3.78 / 3.94` | `5.18e-5 / 3.64e-5` | **3/3** |
324
+ | **32768** | `Stock llama.cpp` | 33.1 (`986.81 s`) | 987.18 | **2.69** | `361.7 / 457.5` | 0.00% | 0.00% | `0 / —` | `0 / —` | **3/3** |
325
+ | **32768** | `ARGUS AUTO (E1 OFF)` | **322.7 (`101.15 s`)** | **101.24** | **10.90** *(14.22¹)* | `85.7 / 149.6` | 0.00% | 0.00% | `1.51 / 0` | `2.68e-5 / 0` | **3/3** |
326
+ | **32768** | `A: ARGUS AUTO (SOTA-3 OFF)` | 322.7 (`101.15 s`) | 101.25 | **10.56** *(14.29¹)* | `84.4 / 131.0` | **12.17%** | **34.83%** | `2.38 / 2.46` | `2.10e-5 / 2.18e-5` | **3/3** |
327
+ | **32768** | `B: A + MADV_RANDOM` | 322.7 (`101.15 s`) | 101.24 | **10.79** | `84.7` / **`111.7`** | **12.17%** | **34.83%** | `2.64 / 2.72` | `4.63e-5 / 2.57e-5` | **3/3** |
328
+ | **32768** | `C: B + Hot-Expert Cache` *(68.7% hit)* | 322.7 (`101.15 s`) | 101.24 | **11.15** | **`81.7`** / `129.3` | **12.17%** | **34.83%** | `2.85 / 2.97` | `4.39e-5 / 3.68e-5` | **3/3** |
329
+ | **32768** | `D: C + Multipole / V-Centroid` | 322.7 (`101.15 s`) | 101.25 | **10.65** | `86.9 / 114.8` | **12.03%** | **34.81%** | **`1.94 / 1.06`** | **`2.85e-5 / 2.35e-5`** | **3/3** |
330
+ | **32768** | `E: D + Top-r` *(disables K-skip)* | 322.7 (`101.15 s`) | 101.25 | **10.49** | `91.1 / 147.5` | `0.00%` | `32.73%` | `2.52 / 2.44` | `1.74e-5 / 2.26e-5` | **3/3** |
331
+
332
+ ¹ *In the earlier unloaded-host run (`MemAvailable > 23 GiB`, `RSS ~ 22.1 GiB`), `ARGUS AUTO` reached `14.22–14.29 tok/s` at 32K vs `Stock`'s `2.86 tok/s`. In the continuous 8-mode ablation above (`MemAvailable = 15.2 GiB`, `RSS = 10.6 GiB`), `ARGUS AUTO` delivered `10.90–11.15 tok/s` (`4.05x–4.15x` over `Stock`'s `2.69 tok/s`) and `322.7 tok/s` prefill (`9.76x` over `Stock`), while `MADV_RANDOM` cut 32K `p95` latency by `-25.3%` (`149.6 -> 111.7 ms`) and `Multipole / V-Centroid` cut 32K max logit error vs `E1 OFF` by `2.79x` (`2.969 -> 1.064`). See [full ablation & Layer 27 mathematical audit](docs/measurements/v080-libargus-2026-10-27/README.md).*
333
+
334
+ ### 1.2 32K Runtime Bottleneck Isolation on `Qwen3.6-35B-A3B` (5-Question Systems Audit)
335
+
336
+ Measured via [`bench_32k_bottleneck_audit.cpp`](docs/measurements/v080-libargus-2026-10-27/bench_32k_bottleneck_audit.cpp) ([JSON telemetry](docs/measurements/v080-libargus-2026-10-27/bottleneck_32k_audit.json), [cold readahead JSON](docs/measurements/v080-libargus-2026-10-27/q3_cold_readahead.json), [Section 3.5 report](docs/measurements/v080-libargus-2026-10-27/README.md#35-32k-runtime-bottleneck-isolation-on-qwen36-35b-a3b)):
337
+
338
+ | Bottleneck Question | Measured 32K Finding | Key Metric / Evidence |
339
+ |---|---|---|
340
+ | **Q1. CPU MoE RAM Residency (`mincore(2)`)** | Across `18,662.00 MiB` (`4,777,592` 4 KiB pages) of CPU MoE weights (`466.55 MiB/layer × 40`), **`51.87%` (`9,680.17 MiB`)** is resident immediately after 32K `P3` prefill (`46.28%` / `8,637.75 MiB` under `~11–13 GiB` desktop RAM pressure; **`100%`** when `>= 19 GiB` free RAM is available). | `mincore(2)` per-layer scan across `ffn_{up,gate,down}_exps` |
341
+ | **Q2. Per-Layer Major Page Faults (`blk.0..39`)** | Because `P3` layer-major prefill streams `blk.0 -> blk.39` sequentially, **`blk.30..39` finish prefill warm at `61.0%–92.5%` residency** (`2,190` `majflt`, `8.55 MiB` read), pushing **`blk.0..29` down to `25.2%–50.3%`**. In decode, **`blk.18..29`** is the #1 fault hotspot (`30,590` `majflt`, `119.33 MiB` read over 8 tokens), followed by **`blk.0..7`** (`8,741` `majflt`, `34.85 MiB`). | Per-layer `ru_majflt` + `/proc/self/io` `read_bytes` hooks |
342
+ | **Q3. `MADV_RANDOM` vs `MADV_NORMAL` Readahead I/O** | Evicting `blk.0..7` (`3,712 MiB`) to `0.01%` residency and decoding 8 tokens (`335` routed experts = `607.19 MiB`): `MADV_NORMAL` pulls **`2,060.04 MiB`** into `blk.0..7` (**`+1,452.85 MiB` / `3.39x` readahead bloat**), reads `1,684.73 KiB/majflt`, triggers **`12,036.62 MiB` (`11.75 GiB`)** total disk reads across `blk.0..39`, and runs at `0.17 tok/s`. `MADV_RANDOM` pulls **`612.18 MiB`** (**`+5.00 MiB` overhead, `-99.66%` bloat**), reads **`4.07 KiB/majflt`**, cuts disk I/O **`19.29x` (`623.92 MiB`)**, and speeds up cold decode **`2.45x` (`0.42 tok/s`)**. | `madvise(MADV_DONTNEED)` + `posix_fadvise(POSIX_FADV_DONTNEED)` cold test |
343
+ | **Q4. `Multipole` K/V Bytes Read & Kernel Time** | Across 10 full-attention layers at 32K (`637.97 MiB/tok` exact KV): `E1 ON, Multipole OFF` reads **`317.11 MiB/tok` (GPU `S1`) / `313.95 MiB/tok` (CPU `K1`)** (`-50.3% / -50.8%`), cutting kernel time `11.522 -> 10.122 ms/tok` (`-12.15%`) on GPU `S1` and `37.977 -> 25.659 ms/tok` (`-32.44%`) on CPU `K1`. `Multipole ON` reads **`322.39 / 319.31 MiB/tok`** (`-49.5% / -49.9%`, `+6.56 MiB/tok` for $\mu_V$) and reaches **`9.780 ms/tok` (`-15.12%`)** on GPU `S1` (`26.368 ms/tok`, `-30.57%` on CPU `K1`). | `cudaEventElapsedTime` (`S1`) + `steady_clock` (`K1`) + exact byte counters |
344
+ | **Q5. Graph-Split & `P3` Decode Contribution** | At 32K warm RAM: `Stock (-nkvo)` runs at **`3.13 tok/s`** (`282` splits, `316.35 ms/tok`). `S1+K1` alone reaches **`9.00 tok/s` (`2.87x`, `-209.30 ms/tok`)**. Keeping Recurrent State on GPU (`ARGUS_RS_GPU_OPT=1`) eliminates **`180` graph splits (`282 -> 102`)** across 30 Gated DeltaNet layers and doubles decode to **`18.23 tok/s` (`+2.03x`, `-53.25 ms/tok`, `5.82x` over Stock)**. `MoE Split Fusion` prevents an `+80` split regression (`102 -> 182`) when `ARGUS_MOE_CACHE=1` is active. | `ARGUS_RS_GPU_OPT` & `ARGUS_MOE_SPLIT_OPT` ablation |
345
+
346
+ ### 2. End-to-End `ARGUS_AUTO=1`, C1 Mixed-Precision & E1 Skipping (8K Filled Context, `Qwen2.5-0.5B`)
347
+
348
+ Measured on `qwen2.5-0.5b-instruct-q4_k_m.gguf` at 8192 context (8096 prompt tokens +
349
+ 32 decoded tokens) across both a constrained 16 MiB split mirror (`1280` of `8192` cells
350
+ mirrored in `F16` on the GPU; `6912` cells on the host) and the default `ARGUS_AUTO=1`
351
+ `auto` mirror (`8192` cells mirrored in `F16` on the GPU with GPU mirror prefill bypass)
352
+ ([data](docs/measurements/v080-libargus-2026-10-27/README.md)):
353
+
354
+ | Configuration | Host KV Codec | GPU Mirror | Host KV Memory Saved | Prefill | Decode Rate | vs Stock `-nkvo` | Peak RSS | Needle (`657446`) |
355
+ |---|---|---|---:|---:|---:|---:|---:|:---:|
356
+ | `stock-nkvo-f16` | `f16` | None | 0% | 0.898 s (9,012 tok/s) | **23.18 tok/s** | 1.00x | 713.5 MiB | Found |
357
+ | `argus-auto-f16` *(16 MiB split)* | `f16` | `f16` (1280) | 0% | 0.888 s (9,122 tok/s) | **79.54 tok/s** | **3.43x** | 699.3 MiB | Found |
358
+ | `argus-auto-c1-q8_0` *(16 MiB split)* | `q8_0` | `f16` (1280) | **-46.9% (1.88x)** | 0.891 s (9,084 tok/s) | **66.94 tok/s** | **2.89x** | 658.2 MiB (**-55.3 MiB**) | Found |
359
+ | `argus-auto-c1-q8_0-e1-skip` *(16 MiB split)* | `q8_0` | `f16` (1280) | **-46.9% (1.88x)** | 0.889 s (9,108 tok/s) | **67.67 tok/s** | **2.92x** | 665.2 MiB (**-48.3 MiB**) | Found |
360
+ | `argus-auto-c1-k_q8-v_q4-skip` *(16 MiB split)* | **K=`q8_0`, V=`q4_0`** | `f16` (1280) | **-59.4% (2.46x)** | 0.925 s (8,751 tok/s) | **69.60 tok/s** | **3.00x** | 659.7 MiB (**-53.8 MiB**) | Found |
361
+ | `argus-auto-full-mirror-k_q8-v_q4` *(`auto` mirror)* | **K=`q8_0`, V=`q4_0`** | `f16` (8192) | **-59.4% (2.46x)** | **0.815 s (9,936 tok/s)** | **175.45 tok/s** | **7.57x** | **638.5 MiB (-75.0 MiB)** | **Found** |
362
+
363
+ ### 3. Standalone Synthetic CPU Decode Kernel: Stock GGML vs K1 Exact vs K1 + E1 Skip (`Qwen3.6-35B-A3B` Geometry Without QK-Norm)
364
+
365
+ Single-token CPU decode latency on synthetic non-QK-Norm tensors across 16K, 64K, and 128K cells (`d = 256`, `16/2`
366
+ heads, 4 threads, `-march=native`, [source & data](docs/measurements/v080-libargus-2026-10-27/README.md)):
367
+
368
+ | Context | KV Codec | KV Size / Layer | Stock GGML (ms) | `libargus` K1 Exact (ms) | `libargus` K1 + E1 Skip (ms) | Speedup vs Stock | Blocks Skipped (K / Total) | Max Rel Err |
369
+ |---:|---|---:|---:|---:|---:|---:|---:|---:|
370
+ | **16K** | `f16` | 32.0 MiB | 12.91 ms | 1.72 ms (7.5x) | **0.48 ms** | **26.7x** | 1002 / 1024 | `4.35e-07` |
371
+ | **16K** | `q8_0` | 17.0 MiB (-47%) | 10.12 ms | 2.41 ms (4.2x) | **0.33 ms** | **31.1x** *(39.1x vs Stock F16)* | 1002 / 1024 | `4.67e-07` |
372
+ | **16K** | `q4_0` | 9.0 MiB (-72%) | 7.84 ms | 2.38 ms (3.3x) | **0.45 ms** | **17.3x** *(28.7x vs Stock F16)* | 1002 / 1024 | `3.88e-07` |
373
+ | **64K** | `f16` | 128.0 MiB | 57.43 ms | 5.79 ms (9.9x) | **0.91 ms** | **62.8x** | 4074 / 4096 | `5.81e-07` |
374
+ | **64K** | `q8_0` | 68.0 MiB (-47%) | 34.32 ms | 9.60 ms (3.6x) | **1.33 ms** | **25.8x** *(43.2x vs Stock F16)* | 4074 / 4096 | `3.94e-07` |
375
+ | **64K** | `q4_0` | 36.0 MiB (-72%) | 37.43 ms | 9.40 ms (4.0x) | **1.34 ms** | **27.9x** *(42.9x vs Stock F16)* | 4074 / 4096 | `4.43e-07` |
376
+ | **128K** | `f16` | 256.0 MiB | 114.72 ms | 11.35 ms (10.1x) | **2.56 ms** | **44.9x** | 8170 / 8192 | `6.03e-07` |
377
+ | **128K** | `q8_0` | 136.0 MiB (-47%) | 81.50 ms | **10.95 ms (7.4x)** | **2.60 ms** | **31.4x** *(44.1x vs Stock F16)* | 8170 / 8192 | `3.28e-07` |
378
+ | **128K** | `q4_0` | 72.0 MiB (-72%) | 83.19 ms | 18.66 ms (4.5x) | **2.56 ms** | **32.5x** *(44.8x vs Stock F16)* | 8170 / 8192 | `4.10e-07` |
379
+
380
+ ---
381
+
382
+ ## v0.7 results: Direct-disk paged KV
383
+
384
+ `Qwen2.5-0.5B-Instruct` Q4_K_M, `F16` KV, 4096 context, 4016-token prompt, 16 generated
385
+ tokens, ubatch 64, RTX 3050 Ti Laptop (4 GB), `-nkvo`, GPU/pinned budgets 64 MiB
386
+ ([data](docs/measurements/v070-e10-2026-09-26/)):
387
+
388
+ | Mode | Prefill | vs Stock | Decode | Output Hash |
389
+ |---|---:|---:|---:|---|
390
+ | stock llama.cpp, host KV (tensor-core FlashAttention) | 1.336 s (1.331–1.341) | 1.00x | 37.5 tok/s | `007ddc77` |
391
+ | ARGUS, GPU control (diagnostic, all KV on GPU) | 1.719 s (1.666–1.759) | 1.29x | 55.6 tok/s | `a152ed56` |
392
+ | ARGUS, policy on (GPU/pinned/RAM/disk) | 1.821 s (1.814–1.826) | 1.36x | 48.2 tok/s | `a152ed56` |
393
+
394
+ When KV exceeds the GPU budget (`2 MiB` GPU and `2 MiB` pinned tiers for `48 MiB` of
395
+ KV): `47.6 s` prefill and `1.0 tok/s` decode (`2.1 GB` read from disk per request).
396
+
397
+ ---
398
+
399
+ ## Reading the stock comparison
400
+
401
+ - **Arithmetic contracts.** In default exact mode (`ARGUS_KV_SKIP_EPS=0`), `K1` and `S1`
402
+ match a `float64` reference within `2e-6` (`fp32` accumulation) and `K1` is
403
+ bit-identical across thread counts. When `ARGUS_KV_SKIP_EPS > 0` (`E1`), `K1` and `S1`
404
+ use bounded-mass approximate skipping with Multipole V-centroid compensation (`W_skip * mu_V`). Stock
405
+ `llama.cpp` on the GPU uses tensor-core FlashAttention with its own accumulation
406
+ order.
407
+ - **Measured hardware.** Every measurement in this repository was taken on one machine
408
+ (Intel i5-11300H + RTX 3050 Ti Laptop 4 GB, PCIe Gen3 x4). Do not extrapolate ratios
409
+ to multi-GPU server hardware without measuring there.
410
+
411
+ ---
412
+
413
+ ## Using ARGUS with HuggingFace (legacy research path)
414
+
415
+ The Python package (`pip install --no-build-isolation -e .`) provides the v0.4
416
+ HuggingFace `PagedDynamicKVCache` research path:
417
+
418
+ ```python
419
+ import torch
420
+ from transformers import AutoModelForCausalLM
421
+ from argus_cache import AdaptiveCachePolicy, patch_model_with_argus
422
+
423
+ model = AutoModelForCausalLM.from_pretrained(
424
+ "Qwen/Qwen2.5-0.5B-Instruct", dtype=torch.float16,
425
+ ).to("cuda")
426
+
427
+ model = patch_model_with_argus(
428
+ model,
429
+ page_size=1024,
430
+ max_active_pages=2,
431
+ max_fp8_pages=2,
432
+ sink_tokens=4,
433
+ activation_policy=AdaptiveCachePolicy(mode="balanced", expected_tokens=16_448),
434
+ pipeline_profile="balanced",
435
+ )
436
+ ```
437
+
438
+ ---
439
+
440
+ ## Benchmark methodology
441
+
442
+ ```bash
443
+ # 1. Python unit & hygiene suite
444
+ .venv/bin/python -m pytest -q --ignore=tests/test_native_llama_paged.py
445
+
446
+ # 2. Native llama.cpp C++/CUDA kernel & lifecycle suite
447
+ ARGUS_TEST_CUDA=1 \
448
+ ARGUS_LLAMA_CPP_DIR="$PWD/scratch/llama.cpp-v050" \
449
+ ARGUS_LLAMA_BUILD=build-cuda \
450
+ ARGUS_TEST_GGUF="$PWD/scratch/models/stories15M.gguf" \
451
+ ARGUS_TEST_QUANT_GGUF="$PWD/scratch/models/qwen2.5-0.5b-instruct-q4_k_m.gguf" \
452
+ .venv/bin/python -m pytest -q tests/test_native_llama_paged.py
453
+
454
+ # 3. End-to-end v0.8 long-context & C1/E1 benchmark
455
+ .venv/bin/python benchmarks/bench_long_context.py \
456
+ --server scratch/llama.cpp-v050/build-cuda/bin/llama-server \
457
+ --model scratch/models/qwen2.5-0.5b-instruct-q4_k_m.gguf \
458
+ --configs docs/measurements/v080-libargus-2026-10-27/bench_e2e_configs.json \
459
+ --contexts 8192 --predict 32 --output result.json
460
+ ```
461
+
462
+ ---
463
+
464
+ ## Known limits
465
+
466
+ - **Single KV stream (`-np 1`):** `libargus` manages single-sequence KV caches; multi-stream (`-np > 1` without a unified cache) or MLA/ALiBi/soft-capping models automatically fall back to `llama.cpp`'s native KV cache at load.
467
+ - **Supported head dimensions in S1 GPU kernels:** `d` in `{64, 128, 256, 512}`; other dimensions automatically fall back to K1 on the CPU.
468
+ - **Short-turn prefill is CPU-bound with experts in RAM:** prompts under the P3 threshold (128 tokens) run the MoE experts on the CPU at ~30–40 ms per token on the 4-core test machine, the same rate as decode; P3 takes over above it.
469
+ - **Pinned `llama.cpp` revision:** The patches target upstream commit `54315813269112dd0baed7112ec87ad93a8218ca`.
470
+
471
+ ---
472
+
473
+ ## Earlier evidence (v0.4–v0.6)
474
+
475
+ - **v0.5 KV ownership & quantized CPU parity:** Zero logit difference across 19 steps (including crop and state restore) for `f32`, `f16`, `q8_0`, and `q4_0` on `Qwen2.5-0.5B` ([artifact](docs/measurements/v050-llama-host-ownership-2026-09-15.json)).
476
+ - **v0.6 first operating point (4K):** Prefill `2.12x` (GPU control) and `7.42x` (policy on) vs stock; closed to `1.29x` and `1.36x` in v0.7 ([checkpoint](docs/measurements/v060-checkpoint-2026-09-18.md)).
477
+ - **v0.4 HuggingFace path (`Qwen2.5-0.5B`):** `-7.7%` VRAM at 16K for `4.2x` TPOT; perplexity delta `-0.0176` reaching only the `FP8` tier ([analysis](docs/findings-2026-08-14.md)).
478
+
479
+ ### Quality (HuggingFace path)
480
+
481
+ On the HuggingFace research path, only the `FP8` tier was reached in perplexity evaluations; `INT4`, `INT2`, `1-bit`, and `JL` tiers are **Not measured** for end-to-end model quality.
482
+
483
+ ---
484
+
485
+ ## Roadmap
486
+
487
+ - **v0.8 (current):** `libargus` unified autonomous config (`ARGUS_AUTO=1`), `K1` grouped SIMD CPU decode, `E1` + `Multipole` bounded-mass approximate skipping, `S1` split GPU+CPU decode, `C1` mixed-precision (`Q8_0`/`Q4_0` host + `F16` GPU mirror) tiers, `P2` GPU prefill, `P3` phase-shared layer-major MoE prefill, and sparse MoE `MADV_RANDOM` + opt-in Hot-Expert Cache.
488
+ - **Next:** Record live 128K `P3` layer-major prefill timing on `Qwen3.6-35B-A3B` with the adaptive VRAM budget planner, and measure `Gemma-4-26B-A4B` and `UI-Mate-9B` end to end.
489
+
490
+ ## License
491
+
492
+ ARGUS is licensed under the [Apache 2.0 License](LICENSE).