argus-cache 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,189 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are infringed by their Contribution(s)
80
+ alone or by combination of their Contribution(s) with the Work to
81
+ which such Contribution(s) was submitted. If You institute patent
82
+ litigation against any entity (including a cross-claim or counterclaim
83
+ in a lawsuit) alleging that the Work or a Contribution incorporated
84
+ within the Work constitutes direct or contributory patent infringement,
85
+ then any patent licenses granted to You under this License for that
86
+ Work shall terminate as of the date such litigation is filed.
87
+
88
+ 4. Redistribution. You may reproduce and distribute copies of the
89
+ Work or Derivative Works thereof in any medium, with or without
90
+ modifications, and in Source or Object form, provided that You
91
+ meet the following conditions:
92
+
93
+ (a) You must give any other recipients of the Work or
94
+ Derivative Works a copy of this License; and
95
+
96
+ (b) You must cause any modified files to carry prominent notices
97
+ stating that You changed the files; and
98
+
99
+ (c) You must retain, in the Source form of any Derivative Works
100
+ that You distribute, all copyright, patent, trademark, and
101
+ attribution notices from the Source form of the Work,
102
+ excluding those notices that do not pertain to any part of
103
+ the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a readable copy of the attribution notices contained
108
+ within such NOTICE file, excluding those notices that do not
109
+ pertain to any part of the Derivative Works, in at least one
110
+ of the following places: within a NOTICE text file distributed
111
+ as part of the Derivative Works; within the Source form or
112
+ documentation, if distributed along with the Derivative Works; or,
113
+ within a display generated by the Derivative Works, if and
114
+ wherever such third-party notices normally appear. The contents
115
+ of the NOTICE file are for informational purposes only and
116
+ do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and charge a fee for, acceptance of support, warranty, indemnity,
167
+ or other liability obligations and/or rights consistent with this
168
+ License. However, in accepting such obligations, You may act only
169
+ on Your own behalf and on Your sole responsibility, not on behalf
170
+ of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ Copyright 2026 Muhammed Emin Çelik
178
+
179
+ Licensed under the Apache License, Version 2.0 (the "License");
180
+ you may not use this file except in compliance with the License.
181
+ You may obtain a copy of the License at
182
+
183
+ http://www.apache.org/licenses/LICENSE-2.0
184
+
185
+ Unless required by applicable law or agreed to in writing, software
186
+ distributed under the License is distributed on an "AS IS" BASIS,
187
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
188
+ See the License for the specific language governing permissions and
189
+ limitations under the License.
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: argus_cache
3
+ Version: 0.1.0
4
+ Summary: ARGUS: Anchored Random Geometric Unbiased Storage - Advanced Dynamic Quantized KV Cache
5
+ Author: Muhammed Emin Çelik
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: torch>=2.0.0
11
+ Requires-Dist: triton>=2.0.0
12
+ Requires-Dist: transformers>=4.38.0
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: pytest
15
+ Dynamic: license-file
16
+ Dynamic: requires-python
17
+
18
+ # ⚡ ARGUS: Anchored Random Geometric Unbiased Storage
19
+
20
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
21
+
22
+ **ARGUS** is an academic-grade, production-ready **7-Tier Paged Dynamic Quantized KV Cache Manager** for long-context Transformers. Seamlessly integrates with the official HuggingFace `Cache` interface to enable plug-and-play generation.
23
+
24
+ Combines the **perfect associative recall** of Transformers with the **extreme memory efficiency** of State Space Models (SSM/Mamba), while fully resolving the repetitiveness loops of low-bit quantization.
25
+
26
+ ---
27
+
28
+ ## 🌍 Language Options / Dil Seçenekleri
29
+ - [English Version / İngilizce Detaylar](#-english-version)
30
+ - [Türkçe Sürüm / Türkçe Detaylar](#-turkce-surum)
31
+
32
+ ---
33
+
34
+ # 🇬🇧 English Version
35
+
36
+ ## 🎯 Architecture Overview
37
+
38
+ Transformer models suffer from quadratic memory scaling ($O(N^2)$) due to key-value (KV) cache accumulation during causal generation. SSM alternatives like Mamba resolve this with constant $O(1)$ recurrent compression but suffer from severe memory decay and lose rhyming/associative recall capabilities on long-context tasks (e.g. Passkey Retrieval).
39
+
40
+ This project presents a **7-Tier Paged Dynamic Quantized Cache** (`PagedDynamicQuantizedCache`) that divides the KV cache into fixed-size pages and transitions them through an in-place compression pipeline as they age, achieving **up to 65%+ VRAM savings** while maintaining **0.90+ Cosine Similarity** and **100% retrieval accuracy**.
41
+
42
+ ```
43
+ Sequence Direction: [Sinks (FP16)] -> [Rhyme Anchors (FP16)] -> [Active (FP16)] -> [FP8] -> [INT8] -> [INT4] -> [INT2] -> [1-Bit (Sign)] -> [Archive (JL FP16)]
44
+ ```
45
+
46
+ ### 🧬 The 7-Tier Memory Lifecycle
47
+ 1. **Tier 1: FP16 (Active Pages):** Pristine precision for the most recent tokens.
48
+ 2. **Tier 2: FP8 (Simulated e4m3fn):** Symmetric scaling with clamping to $[-240, 240]$, stored as `int8` with scales for **50% VRAM savings**.
49
+ 3. **Tier 3: INT8 (Medium Pages):** Per-channel symmetric quantization for **50% VRAM savings**.
50
+ 4. **Tier 4: INT4 (2-way Bit-Packed):** Asymmetric quantization packed using custom **GPU Triton JIT Kernels** (2 values per byte) for **75% VRAM savings**.
51
+ 5. **Tier 5: INT2 (4-way Bit-Packed):** Asymmetric 2-bit quantization packed (4 values per byte) for **87.5% VRAM savings**.
52
+ 6. **Tier 6: 1-Bit (Sign-Binarized Bit-Packed):** Binarized signs ($x \ge 0 \rightarrow 1$, else $0$) packed 8 values per byte using custom **GPU Triton JIT Kernels** for **93.7% normal VRAM savings**. Outliers isolated dynamically.
53
+ 7. **Tier 7: Johnson-Lindenstrauss Orthogonal Matrix Projection:** Sequence-dimension projection ($N \rightarrow M$, where $M = N // 4$) keeping FP16 precision. Random projection matrix $W_{proj}$ is orthogonalized via **QR Decomposition** ($W_{proj} W_{proj}^T = I$) to geometrically preserve distances and cosine similarities, **completely eliminating repetition loops**.
54
+
55
+ ---
56
+
57
+ ## 🏆 Key Beta-Phase Upgrades
58
+
59
+ ### 1. Library Packaging (`argus_cache`)
60
+ ARGUS has been refactored into a fully installable open-source library. Easily perform plug-and-play native model intercepting:
61
+ ```python
62
+ from argus_cache import patch_model_with_argus
63
+ from transformers import AutoModelForCausalLM
64
+
65
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
66
+ model = patch_model_with_argus(model) # Bitti. Ready for ultra-long context!
67
+ ```
68
+
69
+ ### 2. vLLM Production Docker & Service Orchestration
70
+ Includes native interception tools (`argus_vllm_models.py`) to monkey-patch vLLM's `ModelRegistry` and `LlamaAttention` layers, a custom compiler-enabled `Dockerfile.vllm`, and a dual-service `docker-compose.yml` for serving SaaS-GPT and Health-GPT APIs on modern L40S high-performance GPUs.
71
+
72
+ ### 3. Triton JIT 1-Bit CUDA GPU Kernels
73
+ Custom parallel JIT CUDA kernels (`triton_pack_1bit`, `triton_unpack_1bit`) binarize values on GPU SRAM and pack/unpack 8 sign bits into a single `uint8` byte, with an automatic vectorized PyTorch fallback for CPU execution.
74
+
75
+ ### 4. Dynamic Outlier Thresholding ($\sigma > 3.0$)
76
+ Calculates statistical variance in real-time. Signals exceeding $3.0\sigma$ standard deviation are dynamically isolated and stored permanently in high-fidelity FP16, while only the background normal range is compressed down. Reconstructed normal values are seamlessly combined with outliers:
77
+ $$\text{Reconstructed} = \text{where}(\text{Outlier Mask}, \text{FP16 Outliers}, \text{Dequantized Normal})$$
78
+ This completely prevents quantization scaling explosion and protects critical activation spikes.
79
+
80
+ ---
81
+
82
+ ## 📊 Empirical Evaluation Results
83
+
84
+ ### 📈 VRAM Context Scaling Benchmark
85
+ As sequence length scales up to **100k context**, the VRAM memory footprint reduction becomes massive. Standard FP16 cache escalates to over 12.2 GB, whereas ARGUS compresses the footprint down to just ~4.2 GB (**2.9x memory reduction**).
86
+
87
+ ![VRAM Scaling Graph](benchmarks/vram_scaling_graph.png)
88
+
89
+ ### 🔬 Passkey Retrieval: Accuracy, Memory & Speed Comparison
90
+ *A rigorous long-context associative recall evaluation where a hidden passkey is buried inside random background noise, evaluated across context lengths.*
91
+
92
+ | Architecture / Model | Metric | 64 tok | 256 tok | 512 tok | 1024 tok | 2048 tok |
93
+ | :--- | :--- | :---: | :---: | :---: | :---: | :---: |
94
+ | **Standard Transformer** | Accuracy | 100% | 100% | 100% | 100% | 100% |
95
+ | *(Exact FP16 Cache)* | Cache Memory | 16.0 KB | 64.0 KB | 128.0 KB | 256.0 KB | 512.0 KB |
96
+ | | Speed | 5,282 t/s | 4,952 t/s | 6,493 t/s | 6,394 t/s | 6,409 t/s |
97
+ | **Mamba SSM** | Accuracy | 0% | 0% | 0% | 0% | 0% |
98
+ | *(State Compression)* | Cache Memory | 0.5 KB | 0.5 KB | 0.5 KB | 0.5 KB | 0.5 KB |
99
+ | | Speed | 4,589 t/s | 7,937 t/s | 8,588 t/s | 8,031 t/s | 8,262 t/s |
100
+ | **ARGUS (Ours)** | Accuracy | **100%** | **100%** | **100%** | **100%** | **100%** |
101
+ | *(Paged Dynamic Cache)* | Cache Memory | **16.0 KB** | **64.0 KB** | **121.9 KB** | **223.4 KB** | **338.2 KB** |
102
+ | | Speed | 3,591 t/s | 5,912 t/s | 5,850 t/s | 5,422 t/s | 5,686 t/s |
103
+
104
+ > [!IMPORTANT]
105
+ > **VRAM Memory Savings:** At 2048 tokens, ARGUS achieves **33.9% VRAM savings** compared to standard Transformers, without losing a single percent of retrieval accuracy. When context scales to 100K+ tokens, memory reduction reaches **up to 65%+** (as shown in the VRAM Scaling Graph above).
106
+ >
107
+ > **Throughput & Speed:** Due to custom page managers and dynamic quantized de-serialization overhead, the Python simulation speed of ARGUS is slightly slower than standard models. However, in production native vLLM engines with custom CUDA streams and compiled fused Triton kernels, pre-fetching runs asynchronously in parallel, matching or exceeding base Transformer speeds while utilizing less than half the VRAM.
108
+
109
+ ---
110
+
111
+ # 🇹🇷 Türkçe Sürüm
112
+
113
+ ## 🎯 Mimari Genel Bakış
114
+
115
+ Transformers modelleri, causal üretim adımlarında biriken key-value (KV) durumları nedeniyle karesel ($O(N^2)$) bellek patlaması (Out-of-Memory - OOM) yaşarlar. Mamba gibi SSM alternatifleri bellek tüketimini recurrent bir scan döngüsüyle $O(1)$ seviyesinde sabitlese de, samanlıkta iğne arama (Passkey Retrieval) ve uzun vadeli uyak/vezin yapısı koruma gerektiren şiirsel metin üretimlerinde bellek sönümlenmesi (memory decay) yaşayarak başarısız olurlar.
116
+
117
+ Bu projede, iki dünyanın en iyi yönlerini birleştiren **7-Aşamalı Dinamik Kademeli Kuantize Sayfalanmış Bellek Yöneticisi** (`PagedDynamicQuantizedCache`) sunulmuştur. Sistem, KV Cache tensörlerini sabit boyutlu sayfalara böler ve sayfalar eskidikçe otomatik olarak yerinde (in-place) kuantizasyon ve projeksiyon adımlarından geçirir. Bu sayede **%65'i aşan VRAM tasarrufu** sağlanırken, dekuantizasyon Cosine Benzerliği **0.90+** seviyesinde korunur.
118
+
119
+ ```
120
+ Dizi Yönü: [Sinks (FP16)] -> [Rhyme Anchors (FP16)] -> [Active (FP16)] -> [FP8] -> [INT8] -> [INT4] -> [INT2] -> [1-Bit (Sign)] -> [Archive (JL FP16)]
121
+ ```
122
+
123
+ ### 🧬 7-Aşamalı Bellek Yaşam Döngüsü
124
+ 1. **Tier 1: FP16 (Aktif Sayfalar):** En güncel token'lar için tam çözünürlüklü FP16 bellek tamponu.
125
+ 2. **Tier 2: FP8 (Simüle e4m3fn):** $[-240, 240]$ signed aralığına simetrik ölçekleme ve clamp uygulanarak **%50 VRAM tasarrufu** sağlar.
126
+ 3. **Tier 3: INT8 (Orta Sayfalar):** Per-channel simetrik kuantizasyon ile **%50 VRAM tasarrufu** sağlar.
127
+ 4. **Tier 4: INT4 (2-way Packed):** Custom **Triton JIT CUDA GPU Kernelleri** ile iki adet 4-bitlik değerin tek bir `uint8` hücresine GPU SRAM üzerinde paralel paketlenmesiyle **%75 VRAM tasarrufu** sağlar.
128
+ 5. **Tier 5: INT2 (4-way Packed):** Dört adet 2-bitlik değerin tek bir `uint8` hücresine bit-packing ile paketlenmesiyle **%87.5 VRAM tasarrufu** sağlar.
129
+ 6. **Tier 6: 1-Bit (İşaret Binarize Bit-Packed):** İşaret değerlerini ($x \ge 0 \rightarrow 1$, else $0$) custom **Triton JIT CUDA Kernelleri** ile 8 adet 1-bitlik değeri tek bir `uint8` hücresine paralel paketleyerek **%93.7 normal VRAM tasarrufu** sağlar.
130
+ 7. **Tier 7: Johnson-Lindenstrauss Ortogonal Matris Projeksiyonu (JL):** En eski arşiv sayfalarında tekrarlama döngüsü bug'ına yol açan lossy INT2 yerine, sequence boyutu $N$ ortogonal bir rastgele matris $W_{proj}$ ile çarpılarak sequence boyutu 4 kat büzüştürülür. Sayılar yüksek çözünürlüklü **FP16** biçiminde tutulur, **tekrarlama döngüsü bug'ları tamamen önlenir**.
131
+
132
+ ---
133
+
134
+ ## 🏆 Temel Beta Fazı Yenilikleri
135
+
136
+ ### 1. Kütüphane Paketlemesi (`argus_cache`)
137
+ ARGUS, pip ile kurulabilir bağımsız bir Python kütüphanesine dönüştürülmüştür:
138
+ ```python
139
+ from argus_cache import patch_model_with_argus
140
+ from transformers import AutoModelForCausalLM
141
+
142
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
143
+ model = patch_model_with_argus(model) # Bitti!
144
+ ```
145
+
146
+ ### 2. vLLM Entegrasyonu & Docker Compose
147
+ vLLM ModelRegistry mekanizmasına sızarak `LlamaAttention` katmanlarını kesen `argus_vllm_models.py` modülü, derleme araçlarını içeren `Dockerfile.vllm` ve L40S kartı üzerinde SaaS ve Sağlık GPT servislerinin serve edilebileceği çift portlu `docker-compose.yml` altyapısı hazırlandı.
148
+
149
+ ### 3. GPU SRAM üzerinde Triton JIT 1-Bit Kernelleri
150
+ Doğrudan GPU SRAM üzerinde paralel koşan custom **Triton JIT 1-Bit Kernelleri** (`triton_pack_1bit`, `triton_unpack_1bit`) geliştirilmiştir (CPU için otomatik PyTorch fallback mevcuttur).
151
+
152
+ ### 4. Dinamik Outlier Kilitleme (Dynamic Outlier Locking - $\sigma > 3.0$)
153
+ Forward pass sırasında verilerin standart sapması hesaplanır ve $3.0\sigma$ limitini aşan aşırı fırlamış outlier kanallar FP16 biçiminde kalıcı olarak kilitlenir. Arka plandaki normal veriler ise 1-bit seviyesine kadar sıkıştırılır. Böylece kuantizasyon çözünürlük kaybı önlenmiş olur.
154
+
155
+ ---
156
+
157
+ ## 📊 Deneysel Değerlendirme Sonuçları
158
+
159
+ ### 📈 VRAM Bağlam Ölçekleme Karşılaştırması
160
+ Dizi uzunluğu **100k bağlam** seviyesine çıktığında, VRAM bellek ayak izindeki azalma devasa bir boyuta ulaşır. Standart FP16 cache 12.2 GB'ın üzerine çıkarken, ARGUS bu ayak izini sadece ~4.2 GB'a düşürür (**2.9 kat bellek tasarrufu**).
161
+
162
+ ![VRAM Scaling Graph](benchmarks/vram_scaling_graph.png)
163
+
164
+ ### 🔬 Passkey Retrieval: Doğruluk, Bellek ve Hız Karşılaştırması
165
+ *Rastgele arka plan gürültüsü içine gömülmüş gizli bir parolanın farklı bağlam uzunluklarında geri çağrılmasını test eden zorlu samanlıkta iğne arama (Passkey Retrieval) değerlendirmesi.*
166
+
167
+ | Mimari / Model | Metrik | 64 tok | 256 tok | 512 tok | 1024 tok | 2048 tok |
168
+ | :--- | :--- | :---: | :---: | :---: | :---: | :---: |
169
+ | **Standart Transformer** | Doğruluk | 100% | 100% | 100% | 100% | 100% |
170
+ | *(Kesin FP16 Cache)* | Önbellek Belleği | 16.0 KB | 64.0 KB | 128.0 KB | 256.0 KB | 512.0 KB |
171
+ | | Hız | 5.282 t/s | 4.952 t/s | 6.493 t/s | 6.394 t/s | 6.409 t/s |
172
+ | **Mamba SSM** | Doğruluk | 0% | 0% | 0% | 0% | 0% |
173
+ | *(Eyalet Sıkıştırma)* | Önbellek Belleği | 0.5 KB | 0.5 KB | 0.5 KB | 0.5 KB | 0.5 KB |
174
+ | | Hız | 4.589 t/s | 7.937 t/s | 8.588 t/s | 8.031 t/s | 8.262 t/s |
175
+ | **ARGUS (Bizim)** | Doğruluk | **100%** | **100%** | **100%** | **100%** | **100%** |
176
+ | *(Sayfalı Dinamik Önbellek)* | Önbellek Belleği | **16.0 KB** | **64.0 KB** | **121.9 KB** | **223.4 KB** | **338.2 KB** |
177
+ | | Hız | 3.591 t/s | 5.912 t/s | 5.850 t/s | 5.422 t/s | 5.686 t/s |
178
+
179
+ > [!IMPORTANT]
180
+ > **VRAM Bellek Kazancı:** 2048 tokende ARGUS, standart Transformers modeline kıyasla doğruluktan ödün vermeden **%33.9 VRAM tasarrufu** elde eder. Bağlam boyutu 100K+ token seviyesine ulaştığında bu kazanç **%65'in üzerine** çıkar (yukarıdaki VRAM Ölçekleme Grafiğinde görüldüğü gibi).
181
+ >
182
+ > **İşlem Hızı (Throughput):** Özel sayfa yöneticisi ve dinamik kuantizasyon/dekuantizasyon işlemlerinin getirdiği ek yük nedeniyle, ARGUS'un Python simülasyon hızı standart modelin biraz altındadır. Ancak, asenkron CUDA akışları ve derlenmiş Triton çekirdekleriyle çalışan gerçek vLLM entegrasyonunda prefetching işlemleri arka planda asenkron yürütülerek baz model hızına ulaşacak veya onu aşacaktır.
183
+
184
+ ---
185
+
186
+ ## 📂 Project Directory Structure / Proje Dizin Yapısı
187
+
188
+ ```text
189
+ ├── argus_cache/ # Exposable python library package
190
+ │ ├── __init__.py # Exposes patch_model_with_argus
191
+ │ ├── core/
192
+ │ │ ├── quantization.py # 1-bit, INT2, INT4, INT8 & JL-Projection maths
193
+ │ │ ├── memory_manager.py# 7-Tier Outlier-Aware Paged memory manager
194
+ │ │ └── triton_kernels.py# Triton JIT 1-bit and 4-bit CUDA kernels
195
+ │ └── models/
196
+ │ └── attention_wrapper.py# HuggingFace Cache wrapper with adaptive tiering
197
+ ├── core/ # Local root core files
198
+ ├── models/ # Local root models files
199
+ ├── benchmarks/
200
+ │ ├── generate_vram_graph.py# Matplotlib benchmark visualizer
201
+ │ ├── vram_profiler.py # VRAM memory scaling profiler
202
+ │ ├── llama_real_test.py # Native HuggingFace Llama-3-8B integration test
203
+ │ └── empirical_comparison.py# Passkey Retrieval evaluation dataset & model
204
+ ├── tests/
205
+ │ ├── test_compression_loss.py# 1-Bit vs Lossless Delta-encoding test
206
+ │ ├── test_quantization.py# Tests for INT8, INT4 packing & Triton compiler
207
+ │ └── test_kv_cache.py # Transitions & reconstruction errors tests
208
+ ├── Dockerfile.vllm # production vLLM deployment container
209
+ ├── docker-compose.yml # Dual service SaaS & Health orchestration
210
+ ├── argus_vllm_models.py # vLLM model registry bypass hook
211
+ ├── setup.py # Library package installer
212
+ ├── pyproject.toml # Library setup config
213
+ ├── demo_train_and_generate.py# Poetry causal QAT training demo
214
+ └── README.md # Bilingual documentation
215
+ ```
216
+
217
+ ---
218
+
219
+ ## ⚙️ Installation & Usage / Kurulum ve Çalıştırma
220
+
221
+ ### 1. Requirements / Gereksinimler
222
+ - Linux OS
223
+ - CUDA 11.8+ / 12.0+ (Optional, compiles Triton JIT kernels on-the-fly)
224
+ - Python 3.10+
225
+
226
+ ### 2. Local Library Install / Yerel Kütüphane Kurulumu
227
+ ```bash
228
+ # Clone the repository
229
+ git clone <repository_url>
230
+ cd "mamba fix"
231
+
232
+ # Install as editable package
233
+ pip install -e .
234
+ ```
235
+
236
+ ### 3. Run Automated Tests / Birim Testlerini Çalıştırın
237
+ ```bash
238
+ .venv/bin/pytest tests/
239
+ ```
240
+
241
+ ### 4. Generate the scaling benchmark graph / Grafiği Üretin
242
+ ```bash
243
+ .venv/bin/python benchmarks/generate_vram_graph.py
244
+ ```
245
+
246
+ ---
247
+
248
+ ## 📄 License & Lisans
249
+ * **English:** This project is licensed under the **Apache License 2.0**. See the [LICENSE](file:///home/zwannfrederick/Masa%C3%BCst%C3%BC/Sektor/Coding/mamba%20fix/LICENSE) file for details.
250
+ * **Türkçe:** Bu proje **Apache Lisansı 2.0** altında lisanslanmıştır. Detaylar için [LICENSE](file:///home/zwannfrederick/Masa%C3%BCst%C3%BC/Sektor/Coding/mamba%20fix/LICENSE) dosyasına göz atabilirsiniz.
251
+
252
+ ---
253
+
254
+ ## 🎓 Academic Citations / Akademik Atıflar
255
+ If you use this architecture or code in your thesis or research, please cite:
256
+ ```bibtex
257
+ @thesis{MuhammedEminARGUS2026,
258
+ author = {Muhammed Emin Çelik},
259
+ title = {ARGUS: Anchored Random Geometric Unbiased Storage for Key-Value Cache in Long-Context Large Language Models},
260
+ institution = {Academic Graduation Thesis},
261
+ year = {2026},
262
+ month = {May}
263
+ }
264
+ ```