atelya 0.1.19__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.
- atelya-0.1.19/LICENSE +202 -0
- atelya-0.1.19/PKG-INFO +171 -0
- atelya-0.1.19/README.md +147 -0
- atelya-0.1.19/amem/__init__.py +17 -0
- atelya-0.1.19/amem/bench.py +238 -0
- atelya-0.1.19/amem/cli.py +59 -0
- atelya-0.1.19/amem/client.py +200 -0
- atelya-0.1.19/amem/engine.py +234 -0
- atelya-0.1.19/amem/evict_regime.py +298 -0
- atelya-0.1.19/amem/extract.py +89 -0
- atelya-0.1.19/amem/integrations/__init__.py +4 -0
- atelya-0.1.19/amem/integrations/langgraph.py +188 -0
- atelya-0.1.19/amem/kv_engine.py +362 -0
- atelya-0.1.19/amem/kv_serve.py +465 -0
- atelya-0.1.19/amem/mcp_server.py +127 -0
- atelya-0.1.19/amem/memory.py +271 -0
- atelya-0.1.19/amem/proxy.py +314 -0
- atelya-0.1.19/amem/serve.py +320 -0
- atelya-0.1.19/amem/serve_common.py +96 -0
- atelya-0.1.19/amem/usage.py +142 -0
- atelya-0.1.19/atelya.egg-info/PKG-INFO +171 -0
- atelya-0.1.19/atelya.egg-info/SOURCES.txt +34 -0
- atelya-0.1.19/atelya.egg-info/dependency_links.txt +1 -0
- atelya-0.1.19/atelya.egg-info/entry_points.txt +2 -0
- atelya-0.1.19/atelya.egg-info/requires.txt +14 -0
- atelya-0.1.19/atelya.egg-info/top_level.txt +1 -0
- atelya-0.1.19/pyproject.toml +31 -0
- atelya-0.1.19/setup.cfg +4 -0
- atelya-0.1.19/tests/test_client_sdk.py +68 -0
- atelya-0.1.19/tests/test_edgecases.py +144 -0
- atelya-0.1.19/tests/test_embed_persist.py +89 -0
- atelya-0.1.19/tests/test_extract.py +50 -0
- atelya-0.1.19/tests/test_kv_serve.py +119 -0
- atelya-0.1.19/tests/test_langgraph_store.py +102 -0
- atelya-0.1.19/tests/test_serve_common.py +109 -0
- atelya-0.1.19/tests/test_usage.py +123 -0
atelya-0.1.19/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 [yyyy] [name of copyright owner]
|
|
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.
|
atelya-0.1.19/PKG-INFO
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: atelya
|
|
3
|
+
Version: 0.1.19
|
|
4
|
+
Summary: AI-first memory OS: semantic recall that returns reusable KV. One lifecycle memory, three front doors (self-host serve, closed-LLM proxy, MCP server).
|
|
5
|
+
Author: amem
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: memory,llm,kv-cache,rag,mcp,agents,vllm
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: numpy>=1.26
|
|
12
|
+
Requires-Dist: fastembed>=0.3
|
|
13
|
+
Requires-Dist: fastapi>=0.110
|
|
14
|
+
Requires-Dist: uvicorn>=0.27
|
|
15
|
+
Requires-Dist: pydantic>=2
|
|
16
|
+
Requires-Dist: mcp>=1.0
|
|
17
|
+
Provides-Extra: selfhost
|
|
18
|
+
Requires-Dist: vllm>=0.6; extra == "selfhost"
|
|
19
|
+
Requires-Dist: transformers>=4.40; extra == "selfhost"
|
|
20
|
+
Requires-Dist: torch; extra == "selfhost"
|
|
21
|
+
Provides-Extra: langgraph
|
|
22
|
+
Requires-Dist: langgraph>=0.2; extra == "langgraph"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# Atelya OS — KV-native memory for self-hosted agents
|
|
26
|
+
|
|
27
|
+
> Agent memory that lives in the model's **KV cache**, not just in text.
|
|
28
|
+
> Built for teams self-hosting open-model inference (vLLM / SGLang) with heavy, long-lived memory.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install atelya
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Most memory systems store **text** and re-prefill it into the prompt **every turn** — so the cost of
|
|
35
|
+
serving memory grows linearly with turns. Atelya OS (`amem`) keeps the relevant working set as
|
|
36
|
+
**reused KV**: compute it once, reuse it, don't recompute memory each turn.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## What's measured (not estimated)
|
|
41
|
+
|
|
42
|
+
All numbers below were measured on a single RTX 4070 with `bench_real.py` / `amem_headtohead.py` in
|
|
43
|
+
this repo. Full methodology, per-query data, and honest limits: **[BENCHMARK.md](BENCHMARK.md)**.
|
|
44
|
+
|
|
45
|
+
- **Fidelity — 97.5% answer-for-answer agreement** with a cold full re-prefill of the same chunks
|
|
46
|
+
(n = 200, LLM-judged). Reusing KV instead of recomputing it **does not change the answer**.
|
|
47
|
+
- **Cost — ~6x to ~54x less prefill.** Reusing KV vs re-prefilling the same retrieved set is **~6x
|
|
48
|
+
cheaper per query** (n = 200, the conservative, default behavior); for a **stable session** the
|
|
49
|
+
one-time working set amortizes to **~54x** (measured, 30 queries). Your real number lands in that
|
|
50
|
+
range depending on how much the relevant memory changes per query. Break-even ~1 query.
|
|
51
|
+
- **Quality — at parity, not a win.** Head-to-head vs Mem0 at a **matched answerer + injection
|
|
52
|
+
budget**, answer correctness was **60% (amem) vs 55% (Mem0)** — within noise at n = 20. We do
|
|
53
|
+
**not** claim a recall-accuracy win: dedicated recall systems (Mem0, Zep, EverOS) lead that, and
|
|
54
|
+
this comparison deliberately matches retrieval to isolate **cost**, so it does not reflect Mem0's
|
|
55
|
+
stronger production recall pipeline.
|
|
56
|
+
|
|
57
|
+
> Honest framing for the cost number: lead with **~6x** (rigorous, n = 200). The **~54x** is the
|
|
58
|
+
> best case (stable working set + Mem0 storing raw turns); Mem0's real extraction injects fewer
|
|
59
|
+
> tokens and narrows the gap — but amem still never re-prefills its resident KV. See BENCHMARK.md.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Who this is for
|
|
64
|
+
|
|
65
|
+
- **Full fit — you self-host vLLM / SGLang on a CUDA GPU**, with memory-heavy or long-horizon
|
|
66
|
+
agents. You own inference, so you can inject KV -> you get the flat cost curve **and** the KV moat.
|
|
67
|
+
- **Partial fit — closed APIs (OpenAI) or Ollama.** You can't inject KV into a model you don't
|
|
68
|
+
control, so amem **reduces** the per-turn memory bill but can't flatten it. The memory SDK still
|
|
69
|
+
helps; the KV-reuse cost curve does not apply.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install atelya # memory SDK + CLI (no GPU needed)
|
|
77
|
+
pip install 'atelya[selfhost]' # + vLLM / LMCache CacheBlend engine (CUDA GPU) — unlocks KV reuse
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The ~6x–54x cost win needs the self-host engine (`[selfhost]`). **`pip install atelya` alone is the
|
|
81
|
+
memory-layer SDK; the KV moat requires inference you control.** The Python package runs without the
|
|
82
|
+
optional Rust engine (that engine is a commercial performance deepener, not required).
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Quickstart
|
|
87
|
+
|
|
88
|
+
> Verified against **amem 0.1.18**. `kv-serve` (the KV-reuse moat) needs `amem[selfhost]` + a CUDA GPU.
|
|
89
|
+
> No GPU? Swap in `amem proxy` (drop-in for Claude / GPT) — same SDK; the cost curve just doesn't apply.
|
|
90
|
+
|
|
91
|
+
Start the KV-reuse memory server (loads the vLLM + CacheBlend engine):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
amem kv-serve # serves on http://localhost:8000 (needs amem[selfhost] + a CUDA GPU)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Use it from the tiny SDK — the second question reuses the first one's KV instead of re-prefilling
|
|
98
|
+
the memory:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from amem import Amem
|
|
102
|
+
|
|
103
|
+
mem = Amem("http://localhost:8000")
|
|
104
|
+
mem.remember("alice", ["Alice lives in Seattle and works at Boeing.",
|
|
105
|
+
"Alice's sister Maria lives in Denver."])
|
|
106
|
+
sid = mem.start_session("alice") # one resident working set for the chat
|
|
107
|
+
print(mem.ask("alice", "Where does Alice's sister live?", session=sid))
|
|
108
|
+
print(mem.ask("alice", "What company does Alice work for?", session=sid)) # different q -> reuses KV
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Or drop it in behind the **standard OpenAI SDK** — point `base_url` at amem and pass `user` as the
|
|
112
|
+
memory namespace (per-user residency is on by default):
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from openai import OpenAI
|
|
116
|
+
|
|
117
|
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")
|
|
118
|
+
r = client.chat.completions.create(
|
|
119
|
+
model="amem", user="alice",
|
|
120
|
+
messages=[{"role": "user", "content": "Where does Alice's sister live?"}])
|
|
121
|
+
print(r.choices[0].message.content)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## CLI
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
amem proxy # closed-LLM drop-in (Claude / GPT) + cache orchestration (light, no GPU)
|
|
130
|
+
amem mcp # MCP server for Claude Desktop / Cursor / Claude Code (stdio)
|
|
131
|
+
amem serve # self-host serve (local open model + KV residency) [amem[selfhost]]
|
|
132
|
+
amem kv-serve # KV-native serve: CacheBlend reuse + KvPolicy eviction (moat) [amem[selfhost]]
|
|
133
|
+
amem bench # reproducible cost-curve benchmark (KV-residency vs re-prefill) [amem[selfhost]]
|
|
134
|
+
amem version # print version
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Run `amem --help` for the authoritative list and flags.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## How it works — the bridge
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
text memory amem (the bridge) KV memory
|
|
145
|
+
re-prefilled every turn -> recall the relevant set, then -> its precomputed KV is REUSED
|
|
146
|
+
(linear cost) reuse its KV (not the text) (one-time prefill, then ~flat)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
- **CacheBlend** (via LMCache) reuses each chunk's attention KV **position-independently**, with
|
|
150
|
+
~15% selective recompute — so an arbitrary set of recalled chunks can be served from cached KV
|
|
151
|
+
instead of a full re-prefill.
|
|
152
|
+
- A **value-model residency policy** (relevance x recency x reuse - size) keeps the hottest memory
|
|
153
|
+
resident and tiers the rest to CPU/disk.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## What this is **not**
|
|
158
|
+
|
|
159
|
+
- **Not a recall-accuracy leaderboard claim.** Mem0 / Zep / EverOS lead LoCoMo / LongMemEval recall;
|
|
160
|
+
amem composes with a recall layer. Its edge is the **cost of serving memory at parity fidelity**.
|
|
161
|
+
- **Transformer-only.** CacheBlend reuses per-token attention KV. SSM / Mamba-hybrid models keep a
|
|
162
|
+
compressed recurrent state — there is no per-token KV to blend — so the KV-reuse moat does not
|
|
163
|
+
apply to them.
|
|
164
|
+
- **A storage trade.** KV is ~1000x the size of the text it represents; amem tiers it to CPU/disk.
|
|
165
|
+
You buy lower compute with more storage.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Status & license
|
|
170
|
+
|
|
171
|
+
Experimental, in active development — expect rough edges. Apache-2.0.
|
atelya-0.1.19/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Atelya OS — KV-native memory for self-hosted agents
|
|
2
|
+
|
|
3
|
+
> Agent memory that lives in the model's **KV cache**, not just in text.
|
|
4
|
+
> Built for teams self-hosting open-model inference (vLLM / SGLang) with heavy, long-lived memory.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pip install atelya
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Most memory systems store **text** and re-prefill it into the prompt **every turn** — so the cost of
|
|
11
|
+
serving memory grows linearly with turns. Atelya OS (`amem`) keeps the relevant working set as
|
|
12
|
+
**reused KV**: compute it once, reuse it, don't recompute memory each turn.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## What's measured (not estimated)
|
|
17
|
+
|
|
18
|
+
All numbers below were measured on a single RTX 4070 with `bench_real.py` / `amem_headtohead.py` in
|
|
19
|
+
this repo. Full methodology, per-query data, and honest limits: **[BENCHMARK.md](BENCHMARK.md)**.
|
|
20
|
+
|
|
21
|
+
- **Fidelity — 97.5% answer-for-answer agreement** with a cold full re-prefill of the same chunks
|
|
22
|
+
(n = 200, LLM-judged). Reusing KV instead of recomputing it **does not change the answer**.
|
|
23
|
+
- **Cost — ~6x to ~54x less prefill.** Reusing KV vs re-prefilling the same retrieved set is **~6x
|
|
24
|
+
cheaper per query** (n = 200, the conservative, default behavior); for a **stable session** the
|
|
25
|
+
one-time working set amortizes to **~54x** (measured, 30 queries). Your real number lands in that
|
|
26
|
+
range depending on how much the relevant memory changes per query. Break-even ~1 query.
|
|
27
|
+
- **Quality — at parity, not a win.** Head-to-head vs Mem0 at a **matched answerer + injection
|
|
28
|
+
budget**, answer correctness was **60% (amem) vs 55% (Mem0)** — within noise at n = 20. We do
|
|
29
|
+
**not** claim a recall-accuracy win: dedicated recall systems (Mem0, Zep, EverOS) lead that, and
|
|
30
|
+
this comparison deliberately matches retrieval to isolate **cost**, so it does not reflect Mem0's
|
|
31
|
+
stronger production recall pipeline.
|
|
32
|
+
|
|
33
|
+
> Honest framing for the cost number: lead with **~6x** (rigorous, n = 200). The **~54x** is the
|
|
34
|
+
> best case (stable working set + Mem0 storing raw turns); Mem0's real extraction injects fewer
|
|
35
|
+
> tokens and narrows the gap — but amem still never re-prefills its resident KV. See BENCHMARK.md.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Who this is for
|
|
40
|
+
|
|
41
|
+
- **Full fit — you self-host vLLM / SGLang on a CUDA GPU**, with memory-heavy or long-horizon
|
|
42
|
+
agents. You own inference, so you can inject KV -> you get the flat cost curve **and** the KV moat.
|
|
43
|
+
- **Partial fit — closed APIs (OpenAI) or Ollama.** You can't inject KV into a model you don't
|
|
44
|
+
control, so amem **reduces** the per-turn memory bill but can't flatten it. The memory SDK still
|
|
45
|
+
helps; the KV-reuse cost curve does not apply.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install atelya # memory SDK + CLI (no GPU needed)
|
|
53
|
+
pip install 'atelya[selfhost]' # + vLLM / LMCache CacheBlend engine (CUDA GPU) — unlocks KV reuse
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The ~6x–54x cost win needs the self-host engine (`[selfhost]`). **`pip install atelya` alone is the
|
|
57
|
+
memory-layer SDK; the KV moat requires inference you control.** The Python package runs without the
|
|
58
|
+
optional Rust engine (that engine is a commercial performance deepener, not required).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Quickstart
|
|
63
|
+
|
|
64
|
+
> Verified against **amem 0.1.18**. `kv-serve` (the KV-reuse moat) needs `amem[selfhost]` + a CUDA GPU.
|
|
65
|
+
> No GPU? Swap in `amem proxy` (drop-in for Claude / GPT) — same SDK; the cost curve just doesn't apply.
|
|
66
|
+
|
|
67
|
+
Start the KV-reuse memory server (loads the vLLM + CacheBlend engine):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
amem kv-serve # serves on http://localhost:8000 (needs amem[selfhost] + a CUDA GPU)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use it from the tiny SDK — the second question reuses the first one's KV instead of re-prefilling
|
|
74
|
+
the memory:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from amem import Amem
|
|
78
|
+
|
|
79
|
+
mem = Amem("http://localhost:8000")
|
|
80
|
+
mem.remember("alice", ["Alice lives in Seattle and works at Boeing.",
|
|
81
|
+
"Alice's sister Maria lives in Denver."])
|
|
82
|
+
sid = mem.start_session("alice") # one resident working set for the chat
|
|
83
|
+
print(mem.ask("alice", "Where does Alice's sister live?", session=sid))
|
|
84
|
+
print(mem.ask("alice", "What company does Alice work for?", session=sid)) # different q -> reuses KV
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or drop it in behind the **standard OpenAI SDK** — point `base_url` at amem and pass `user` as the
|
|
88
|
+
memory namespace (per-user residency is on by default):
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from openai import OpenAI
|
|
92
|
+
|
|
93
|
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")
|
|
94
|
+
r = client.chat.completions.create(
|
|
95
|
+
model="amem", user="alice",
|
|
96
|
+
messages=[{"role": "user", "content": "Where does Alice's sister live?"}])
|
|
97
|
+
print(r.choices[0].message.content)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## CLI
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
amem proxy # closed-LLM drop-in (Claude / GPT) + cache orchestration (light, no GPU)
|
|
106
|
+
amem mcp # MCP server for Claude Desktop / Cursor / Claude Code (stdio)
|
|
107
|
+
amem serve # self-host serve (local open model + KV residency) [amem[selfhost]]
|
|
108
|
+
amem kv-serve # KV-native serve: CacheBlend reuse + KvPolicy eviction (moat) [amem[selfhost]]
|
|
109
|
+
amem bench # reproducible cost-curve benchmark (KV-residency vs re-prefill) [amem[selfhost]]
|
|
110
|
+
amem version # print version
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Run `amem --help` for the authoritative list and flags.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## How it works — the bridge
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
text memory amem (the bridge) KV memory
|
|
121
|
+
re-prefilled every turn -> recall the relevant set, then -> its precomputed KV is REUSED
|
|
122
|
+
(linear cost) reuse its KV (not the text) (one-time prefill, then ~flat)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- **CacheBlend** (via LMCache) reuses each chunk's attention KV **position-independently**, with
|
|
126
|
+
~15% selective recompute — so an arbitrary set of recalled chunks can be served from cached KV
|
|
127
|
+
instead of a full re-prefill.
|
|
128
|
+
- A **value-model residency policy** (relevance x recency x reuse - size) keeps the hottest memory
|
|
129
|
+
resident and tiers the rest to CPU/disk.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## What this is **not**
|
|
134
|
+
|
|
135
|
+
- **Not a recall-accuracy leaderboard claim.** Mem0 / Zep / EverOS lead LoCoMo / LongMemEval recall;
|
|
136
|
+
amem composes with a recall layer. Its edge is the **cost of serving memory at parity fidelity**.
|
|
137
|
+
- **Transformer-only.** CacheBlend reuses per-token attention KV. SSM / Mamba-hybrid models keep a
|
|
138
|
+
compressed recurrent state — there is no per-token KV to blend — so the KV-reuse moat does not
|
|
139
|
+
apply to them.
|
|
140
|
+
- **A storage trade.** KV is ~1000x the size of the text it represents; amem tiers it to CPU/disk.
|
|
141
|
+
You buy lower compute with more storage.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Status & license
|
|
146
|
+
|
|
147
|
+
Experimental, in active development — expect rough edges. Apache-2.0.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""amem — AI-first memory OS: semantic recall that returns reusable KV.
|
|
2
|
+
|
|
3
|
+
Four front doors on ONE lifecycle memory store (~/amem_data):
|
|
4
|
+
- kv-serve : self-host KV-native moat (CacheBlend position-independent reuse
|
|
5
|
+
+ KvPolicy value-model eviction). Hardened: API-key auth,
|
|
6
|
+
input validation, durable startup, per-user concurrency,
|
|
7
|
+
$-saved observability. -> the full KV moat, production-shaped.
|
|
8
|
+
- serve : self-host APC serve (local open model + KV residency).
|
|
9
|
+
- proxy : closed-LLM drop-in (Claude/GPT) + cache orchestration -> on-ramp.
|
|
10
|
+
- mcp : MCP server for Claude Desktop / Cursor / Claude Code (stdio).
|
|
11
|
+
"""
|
|
12
|
+
__version__ = "0.1.19"
|
|
13
|
+
|
|
14
|
+
from .memory import MemoryStore, Session # noqa: F401
|
|
15
|
+
from .client import Amem, AmemError # noqa: F401 (stdlib-only SDK; cheap to import)
|
|
16
|
+
|
|
17
|
+
__all__ = ["MemoryStore", "Session", "Amem", "AmemError", "__version__"]
|