quantum-memory-graph 0.1.0__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. quantum_memory_graph-1.0.0/PKG-INFO +321 -0
  2. quantum_memory_graph-1.0.0/README.md +289 -0
  3. quantum_memory_graph-1.0.0/benchmarks/dedup_benchmark.py +183 -0
  4. quantum_memory_graph-1.0.0/benchmarks/generate_scenarios.py +363 -0
  5. quantum_memory_graph-1.0.0/benchmarks/longmemeval_bench.py +211 -0
  6. quantum_memory_graph-1.0.0/benchmarks/longmemeval_bench_v2.py +231 -0
  7. quantum_memory_graph-1.0.0/benchmarks/longmemeval_bench_v3.py +257 -0
  8. quantum_memory_graph-1.0.0/benchmarks/longmemeval_bench_v4.py +322 -0
  9. quantum_memory_graph-1.0.0/benchmarks/longmemeval_bench_v5.py +226 -0
  10. quantum_memory_graph-1.0.0/benchmarks/longmemeval_bench_v6.py +187 -0
  11. quantum_memory_graph-1.0.0/benchmarks/longmemeval_bench_v7.py +194 -0
  12. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/benchmarks/memcombine.py +2 -2
  13. quantum_memory_graph-1.0.0/benchmarks/run_final.py +101 -0
  14. quantum_memory_graph-1.0.0/benchmarks/run_full_benchmark.py +218 -0
  15. quantum_memory_graph-1.0.0/benchmarks/run_full_benchmark_v2.py +153 -0
  16. quantum_memory_graph-1.0.0/pyproject.toml +29 -0
  17. quantum_memory_graph-1.0.0/quantum_memory_graph/__init__.py +44 -0
  18. quantum_memory_graph-1.0.0/quantum_memory_graph/api.py +328 -0
  19. quantum_memory_graph-1.0.0/quantum_memory_graph/dedup.py +196 -0
  20. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/quantum_memory_graph/graph.py +64 -7
  21. quantum_memory_graph-1.0.0/quantum_memory_graph/obsidian.py +315 -0
  22. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/quantum_memory_graph/pipeline.py +28 -1
  23. quantum_memory_graph-1.0.0/quantum_memory_graph/recency.py +265 -0
  24. quantum_memory_graph-1.0.0/quantum_memory_graph/sharing.py +250 -0
  25. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/quantum_memory_graph/subgraph_optimizer.py +23 -2
  26. quantum_memory_graph-1.0.0/quantum_memory_graph/tiers.py +320 -0
  27. quantum_memory_graph-1.0.0/quantum_memory_graph.egg-info/PKG-INFO +321 -0
  28. quantum_memory_graph-1.0.0/quantum_memory_graph.egg-info/SOURCES.txt +40 -0
  29. quantum_memory_graph-1.0.0/quantum_memory_graph.egg-info/entry_points.txt +2 -0
  30. quantum_memory_graph-1.0.0/quantum_memory_graph.egg-info/requires.txt +22 -0
  31. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/setup.cfg +2 -1
  32. quantum_memory_graph-1.0.0/tests/test_dedup.py +122 -0
  33. quantum_memory_graph-1.0.0/tests/test_recency.py +211 -0
  34. quantum_memory_graph-1.0.0/tests/test_sharing.py +118 -0
  35. quantum_memory_graph-1.0.0/tests/test_tiers.py +163 -0
  36. quantum-memory-graph-0.1.0/PKG-INFO +0 -216
  37. quantum-memory-graph-0.1.0/README.md +0 -197
  38. quantum-memory-graph-0.1.0/pyproject.toml +0 -3
  39. quantum-memory-graph-0.1.0/quantum_memory_graph/__init__.py +0 -16
  40. quantum-memory-graph-0.1.0/quantum_memory_graph/api.py +0 -132
  41. quantum-memory-graph-0.1.0/quantum_memory_graph.egg-info/PKG-INFO +0 -216
  42. quantum-memory-graph-0.1.0/quantum_memory_graph.egg-info/SOURCES.txt +0 -18
  43. quantum-memory-graph-0.1.0/quantum_memory_graph.egg-info/requires.txt +0 -18
  44. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/LICENSE +0 -0
  45. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/benchmarks/__init__.py +0 -0
  46. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/quantum_memory_graph/__main__.py +0 -0
  47. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/quantum_memory_graph.egg-info/dependency_links.txt +0 -0
  48. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/quantum_memory_graph.egg-info/top_level.txt +0 -0
  49. {quantum-memory-graph-0.1.0 → quantum_memory_graph-1.0.0}/tests/test_full_pipeline.py +0 -0
@@ -0,0 +1,321 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantum-memory-graph
3
+ Version: 1.0.0
4
+ Summary: Relationship-aware memory for AI agents — knowledge graph + QAOA subgraph optimization
5
+ Home-page: https://github.com/Dustin-a11y/quantum-memory-graph
6
+ Author: Coinkong (Chef's Attraction)
7
+ Author-email: Coinkong <dustin@chefsattraction.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/Dustin-a11y/quantum-memory-graph
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: numpy
14
+ Requires-Dist: networkx
15
+ Requires-Dist: sentence-transformers
16
+ Provides-Extra: quantum
17
+ Requires-Dist: qiskit>=1.0; extra == "quantum"
18
+ Requires-Dist: qiskit-aer; extra == "quantum"
19
+ Provides-Extra: api
20
+ Requires-Dist: fastapi; extra == "api"
21
+ Requires-Dist: uvicorn; extra == "api"
22
+ Provides-Extra: full
23
+ Requires-Dist: qiskit>=1.0; extra == "full"
24
+ Requires-Dist: qiskit-aer; extra == "full"
25
+ Requires-Dist: fastapi; extra == "full"
26
+ Requires-Dist: uvicorn; extra == "full"
27
+ Requires-Dist: spacy; extra == "full"
28
+ Requires-Dist: requests; extra == "full"
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # Quantum Memory Graph ⚛️🧠
34
+
35
+ **Full memory system for AI agents. Knowledge graphs + QAOA optimization + semantic tiers + deduplication + cross-agent sharing.**
36
+
37
+ v1.0.0 — the complete memory architecture for multi-agent systems.
38
+
39
+ ## What It Does
40
+
41
+ Most memory systems treat memories as independent documents — search, rank, stuff into context. QMG maps **relationships** between memories, organizes them into **tiers** by recency, **deduplicates** similar memories, and enables **cross-agent knowledge sharing**. The QAOA optimizer selects the best *combination* of memories — not just the most relevant individuals, but the best connected subgraph.
42
+
43
+ ## Architecture
44
+
45
+ ```
46
+ ┌─────────────────────────────┐
47
+ │ Hot Tier (< 1 hour) │ In-memory deque
48
+ │ Zero latency, auto-demote │ Survives compaction
49
+ └──────────┬──────────────────┘
50
+ │ demote
51
+ ┌──────────▼──────────────────┐
52
+ │ Warm Tier (1–24 hours) │ SQLite-backed
53
+ │ Keyword searchable, fast │ Per-agent isolation
54
+ └──────────┬──────────────────┘
55
+ │ demote
56
+ ┌──────────▼──────────────────┐
57
+ │ Cold Tier (> 24 hours) │ Full knowledge graph
58
+ │ QAOA optimization, semantic │ Embedding search
59
+ └──────────┬──────────────────┘
60
+
61
+ ┌────────────────────┼────────────────────┐
62
+ │ │ │
63
+ ┌───────▼───────┐ ┌────────▼────────┐ ┌───────▼───────┐
64
+ │ Dedup Engine │ │ Shared Memory │ │ Obsidian │
65
+ │ Cosine ≥ 0.95 │ │ Cross-agent │ │ Vault Export │
66
+ │ Smart merge │ │ Access control │ │ Wikilinks │
67
+ └───────────────┘ └─────────────────┘ └───────────────┘
68
+ ```
69
+
70
+ ## Benchmarks
71
+
72
+ ### LongMemEval (ICLR 2025) — Industry Standard
73
+
74
+ | System | R@5 | R@10 | NDCG@10 |
75
+ |--------|-----|------|---------|
76
+ | **Quantum Memory Graph (gte-large)** | **96.6%** | **98.7%** | **94.3%** |
77
+ | MemPalace raw | 96.6% | 98.2% | 88.9% |
78
+ | OMEGA | 95.4% | — | — |
79
+ | Mastra OM | 94.9% | — | — |
80
+ | Quantum Memory Graph (MiniLM, default) | 93.4% | 97.4% | 90.8% |
81
+
82
+ **#1 to our knowledge.** Tied on R@5, best R@10 and NDCG@10 among published results.
83
+
84
+ ### MemCombine — Combination Recall (250 Scenarios)
85
+
86
+ | Method | Coverage | Evidence Recall | F1 | Perfect |
87
+ |--------|----------|----------------|----|---------|
88
+ | Embedding Top-K | 92.3% | 93.9% | 91.3% | 181/250 |
89
+ | **Graph + QAOA** | **96.2%** | **97.7%** | **95.1%** | **212/250** |
90
+
91
+ ## Install
92
+
93
+ ```bash
94
+ # Core (no quantum deps, uses greedy fallback)
95
+ pip install quantum-memory-graph
96
+
97
+ # With QAOA quantum optimization
98
+ pip install quantum-memory-graph[quantum]
99
+
100
+ # Full install (API server + quantum + NLP)
101
+ pip install quantum-memory-graph[full]
102
+
103
+ # Development
104
+ pip install quantum-memory-graph[dev]
105
+ ```
106
+
107
+ ## Quick Start
108
+
109
+ ```python
110
+ from quantum_memory_graph import store, recall
111
+
112
+ # Store memories — builds knowledge graph automatically
113
+ store("Project Alpha uses React with TypeScript.")
114
+ store("Project Alpha backend is FastAPI with PostgreSQL.")
115
+ store("FastAPI connects to PostgreSQL via SQLAlchemy ORM.")
116
+
117
+ # Recall — graph traversal + QAOA finds the optimal combination
118
+ result = recall("What is Project Alpha's tech stack?", K=4)
119
+ for memory in result["memories"]:
120
+ print(f" {memory['text']}")
121
+ ```
122
+
123
+ ## Features
124
+
125
+ ### 1. Semantic Memory Tiers
126
+
127
+ Three-tier system for optimal latency at every time scale:
128
+
129
+ ```python
130
+ from quantum_memory_graph.tiers import MemoryTierManager
131
+
132
+ tiers = MemoryTierManager(agent_id="daisy", warm_db_path="~/.qmg/warm.db")
133
+
134
+ # Store — goes to hot tier automatically
135
+ tiers.store("User wants the dashboard updated", agent_id="daisy")
136
+
137
+ # Recall — searches all tiers, hot first
138
+ results = tiers.recall("dashboard", agent_id="daisy", limit=5)
139
+
140
+ # Maintenance — demotes hot → warm → cold
141
+ stats = tiers.tick()
142
+ print(stats) # {"hot": 5, "warm": 23, "cold": 412, "demoted": 3}
143
+ ```
144
+
145
+ - **Hot** (< 1 hour): In-memory deque. Zero latency. Survives context compaction.
146
+ - **Warm** (1–24 hours): SQLite-backed. Keyword searchable. Per-agent isolation.
147
+ - **Cold** (> 24 hours): Full knowledge graph + QAOA optimization.
148
+
149
+ ### 2. Memory Deduplication
150
+
151
+ Keeps your memory clean — merges near-duplicates automatically:
152
+
153
+ ```python
154
+ from quantum_memory_graph.dedup import MemoryDeduplicator
155
+
156
+ dedup = MemoryDeduplicator(threshold=0.95)
157
+
158
+ # Dry run first
159
+ stats = dedup.merge_duplicates(graph, dry_run=True)
160
+ print(f"Would remove {stats['duplicates_removed']} duplicates")
161
+
162
+ # Real merge — keeps the richest version of each memory
163
+ stats = dedup.merge_duplicates(graph)
164
+ print(f"Removed {stats['duplicates_removed']}, merged {stats['entities_merged']} entities")
165
+ ```
166
+
167
+ Smart canonical selection: keeps the memory with the most entities, most recent timestamp, and longest text.
168
+
169
+ ### 3. Cross-Agent Memory Sharing
170
+
171
+ Shared knowledge pool with access control:
172
+
173
+ ```python
174
+ from quantum_memory_graph.sharing import SharedMemoryPool
175
+
176
+ pool = SharedMemoryPool(db_path="~/.qmg/shared_pool.db")
177
+
178
+ # Store shared knowledge — visible to specific agents or all
179
+ pool.store(
180
+ text="Chef's Attraction runs on CookUnity",
181
+ author_agent="daisy",
182
+ category="business",
183
+ access="public" # or ["daisy", "luigi", "bowser"]
184
+ )
185
+
186
+ # Any authorized agent can recall
187
+ results = pool.recall("CookUnity", requesting_agent="mario", limit=5)
188
+ ```
189
+
190
+ Categories: `business`, `technical`, `rules`, `people`, `general`
191
+
192
+ ### 4. Obsidian Vault Export
193
+
194
+ Visualize your agent's knowledge graph in Obsidian:
195
+
196
+ ```python
197
+ from quantum_memory_graph.obsidian import export_vault, export_from_mem0
198
+
199
+ # Export from a running QMG graph
200
+ export_vault(graph, "/path/to/vault", agent_memories={"daisy": [...], "dk": [...]})
201
+
202
+ # Or pull directly from a Mem0 API
203
+ export_from_mem0(
204
+ mem0_url="http://localhost:8500",
205
+ vault_path="/path/to/vault",
206
+ agents=["daisy", "luigi", "bowser"]
207
+ )
208
+ ```
209
+
210
+ Each memory becomes a markdown note with YAML frontmatter, `[[wikilinks]]` for connections, and `#tags` for entities. Open in Obsidian → Graph View to see your agent's knowledge mapped visually.
211
+
212
+ ### 5. QAOA Subgraph Optimization
213
+
214
+ The core quantum advantage — optimal memory combination selection:
215
+
216
+ ```python
217
+ result = recall(
218
+ "query",
219
+ K=5,
220
+ alpha=0.4, # Relevance weight
221
+ beta_conn=0.35, # Connectivity weight
222
+ gamma_cov=0.25, # Coverage/diversity weight
223
+ hops=3, # Graph traversal depth
224
+ top_seeds=7, # Initial seed nodes
225
+ max_candidates=14, # Max candidates for QAOA
226
+ )
227
+ ```
228
+
229
+ Falls back to greedy selection when Qiskit is not installed — still beats pure similarity search.
230
+
231
+ ### 6. Short-Term Memory
232
+
233
+ Session-aware memory with recency boosting:
234
+
235
+ ```python
236
+ from quantum_memory_graph.recency import ShortTermMemory
237
+
238
+ stm = ShortTermMemory()
239
+ stm.start_session("conv_123")
240
+ stm.add_turn("conv_123", "What's our deadline?", "March 15th")
241
+
242
+ # Recent conversations get boosted in recall
243
+ boosted = stm.boost_results(results, session_id="conv_123")
244
+ ```
245
+
246
+ ## API Server
247
+
248
+ ```bash
249
+ pip install quantum-memory-graph[api]
250
+ python -m quantum_memory_graph.api --port 8502
251
+ ```
252
+
253
+ ### Endpoints
254
+
255
+ | Method | Path | Description |
256
+ |--------|------|-------------|
257
+ | `POST` | `/store` | Store a memory |
258
+ | `POST` | `/store-batch` | Batch store (max 500) |
259
+ | `POST` | `/recall` | Graph + QAOA recall |
260
+ | `POST` | `/dedup` | Run deduplication |
261
+ | `POST` | `/tiers/store` | Store to tier system |
262
+ | `POST` | `/tiers/recall` | Recall from all tiers |
263
+ | `POST` | `/tiers/tick` | Run tier maintenance |
264
+ | `POST` | `/shared/store` | Store shared memory |
265
+ | `POST` | `/shared/recall` | Recall shared memories |
266
+ | `GET` | `/shared/stats` | Shared pool statistics |
267
+ | `POST` | `/obsidian/export` | Export to Obsidian vault |
268
+ | `GET` | `/stats` | Graph statistics |
269
+ | `GET` | `/` | Health check |
270
+
271
+ All endpoints require `Authorization: Bearer <token>` when `QMG_API_TOKEN` is set.
272
+
273
+ ## Choosing a Model
274
+
275
+ | Model | Size | GPU? | R@5 | Best For |
276
+ |-------|------|------|-----|----------|
277
+ | `all-MiniLM-L6-v2` (default) | 90MB | No | 93.4% | Laptops, CI/CD |
278
+ | `BAAI/bge-large-en-v1.5` | 1.3GB | Recommended | 95.9% | Production with GPU |
279
+ | `intfloat/e5-large-v2` | 1.3GB | Recommended | 96.0% | Best ranking (NDCG) |
280
+ | `thenlper/gte-large` | 1.3GB | Recommended | 96.6% | Maximum accuracy |
281
+
282
+ ```python
283
+ from quantum_memory_graph import MemoryGraph
284
+
285
+ mg = MemoryGraph() # Default — works everywhere
286
+ mg = MemoryGraph(model="thenlper/gte-large") # Best accuracy
287
+ ```
288
+
289
+ ## IBM Quantum Hardware
290
+
291
+ For production QAOA on real quantum hardware:
292
+
293
+ ```bash
294
+ pip install quantum-memory-graph[quantum]
295
+ export IBM_QUANTUM_TOKEN=your_token
296
+ ```
297
+
298
+ Validated on `ibm_fez` and `ibm_kingston` backends.
299
+
300
+ ## Requirements
301
+
302
+ - Python ≥ 3.9
303
+ - sentence-transformers, networkx, numpy
304
+ - Optional: qiskit + qiskit-aer (quantum), fastapi + uvicorn (API), spacy (NLP)
305
+
306
+ ## License
307
+
308
+ MIT License — Copyright 2026 Coinkong (Chef's Attraction)
309
+
310
+ ## Links
311
+
312
+ - [GitHub](https://github.com/Dustin-a11y/quantum-memory-graph)
313
+ - [PyPI](https://pypi.org/project/quantum-memory-graph/)
314
+ - [Changelog](CHANGELOG.md)
315
+
316
+ ## Author
317
+
318
+ Built by **Dustin Taylor** / Coinkong — Chef's Attraction AI Lab
319
+
320
+ - 𝕏 [@Coinkong](https://x.com/Coinkong)
321
+ - 📸 [@Dustin.c.Taylor](https://instagram.com/Dustin.c.Taylor)
@@ -0,0 +1,289 @@
1
+ # Quantum Memory Graph ⚛️🧠
2
+
3
+ **Full memory system for AI agents. Knowledge graphs + QAOA optimization + semantic tiers + deduplication + cross-agent sharing.**
4
+
5
+ v1.0.0 — the complete memory architecture for multi-agent systems.
6
+
7
+ ## What It Does
8
+
9
+ Most memory systems treat memories as independent documents — search, rank, stuff into context. QMG maps **relationships** between memories, organizes them into **tiers** by recency, **deduplicates** similar memories, and enables **cross-agent knowledge sharing**. The QAOA optimizer selects the best *combination* of memories — not just the most relevant individuals, but the best connected subgraph.
10
+
11
+ ## Architecture
12
+
13
+ ```
14
+ ┌─────────────────────────────┐
15
+ │ Hot Tier (< 1 hour) │ In-memory deque
16
+ │ Zero latency, auto-demote │ Survives compaction
17
+ └──────────┬──────────────────┘
18
+ │ demote
19
+ ┌──────────▼──────────────────┐
20
+ │ Warm Tier (1–24 hours) │ SQLite-backed
21
+ │ Keyword searchable, fast │ Per-agent isolation
22
+ └──────────┬──────────────────┘
23
+ │ demote
24
+ ┌──────────▼──────────────────┐
25
+ │ Cold Tier (> 24 hours) │ Full knowledge graph
26
+ │ QAOA optimization, semantic │ Embedding search
27
+ └──────────┬──────────────────┘
28
+
29
+ ┌────────────────────┼────────────────────┐
30
+ │ │ │
31
+ ┌───────▼───────┐ ┌────────▼────────┐ ┌───────▼───────┐
32
+ │ Dedup Engine │ │ Shared Memory │ │ Obsidian │
33
+ │ Cosine ≥ 0.95 │ │ Cross-agent │ │ Vault Export │
34
+ │ Smart merge │ │ Access control │ │ Wikilinks │
35
+ └───────────────┘ └─────────────────┘ └───────────────┘
36
+ ```
37
+
38
+ ## Benchmarks
39
+
40
+ ### LongMemEval (ICLR 2025) — Industry Standard
41
+
42
+ | System | R@5 | R@10 | NDCG@10 |
43
+ |--------|-----|------|---------|
44
+ | **Quantum Memory Graph (gte-large)** | **96.6%** | **98.7%** | **94.3%** |
45
+ | MemPalace raw | 96.6% | 98.2% | 88.9% |
46
+ | OMEGA | 95.4% | — | — |
47
+ | Mastra OM | 94.9% | — | — |
48
+ | Quantum Memory Graph (MiniLM, default) | 93.4% | 97.4% | 90.8% |
49
+
50
+ **#1 to our knowledge.** Tied on R@5, best R@10 and NDCG@10 among published results.
51
+
52
+ ### MemCombine — Combination Recall (250 Scenarios)
53
+
54
+ | Method | Coverage | Evidence Recall | F1 | Perfect |
55
+ |--------|----------|----------------|----|---------|
56
+ | Embedding Top-K | 92.3% | 93.9% | 91.3% | 181/250 |
57
+ | **Graph + QAOA** | **96.2%** | **97.7%** | **95.1%** | **212/250** |
58
+
59
+ ## Install
60
+
61
+ ```bash
62
+ # Core (no quantum deps, uses greedy fallback)
63
+ pip install quantum-memory-graph
64
+
65
+ # With QAOA quantum optimization
66
+ pip install quantum-memory-graph[quantum]
67
+
68
+ # Full install (API server + quantum + NLP)
69
+ pip install quantum-memory-graph[full]
70
+
71
+ # Development
72
+ pip install quantum-memory-graph[dev]
73
+ ```
74
+
75
+ ## Quick Start
76
+
77
+ ```python
78
+ from quantum_memory_graph import store, recall
79
+
80
+ # Store memories — builds knowledge graph automatically
81
+ store("Project Alpha uses React with TypeScript.")
82
+ store("Project Alpha backend is FastAPI with PostgreSQL.")
83
+ store("FastAPI connects to PostgreSQL via SQLAlchemy ORM.")
84
+
85
+ # Recall — graph traversal + QAOA finds the optimal combination
86
+ result = recall("What is Project Alpha's tech stack?", K=4)
87
+ for memory in result["memories"]:
88
+ print(f" {memory['text']}")
89
+ ```
90
+
91
+ ## Features
92
+
93
+ ### 1. Semantic Memory Tiers
94
+
95
+ Three-tier system for optimal latency at every time scale:
96
+
97
+ ```python
98
+ from quantum_memory_graph.tiers import MemoryTierManager
99
+
100
+ tiers = MemoryTierManager(agent_id="daisy", warm_db_path="~/.qmg/warm.db")
101
+
102
+ # Store — goes to hot tier automatically
103
+ tiers.store("User wants the dashboard updated", agent_id="daisy")
104
+
105
+ # Recall — searches all tiers, hot first
106
+ results = tiers.recall("dashboard", agent_id="daisy", limit=5)
107
+
108
+ # Maintenance — demotes hot → warm → cold
109
+ stats = tiers.tick()
110
+ print(stats) # {"hot": 5, "warm": 23, "cold": 412, "demoted": 3}
111
+ ```
112
+
113
+ - **Hot** (< 1 hour): In-memory deque. Zero latency. Survives context compaction.
114
+ - **Warm** (1–24 hours): SQLite-backed. Keyword searchable. Per-agent isolation.
115
+ - **Cold** (> 24 hours): Full knowledge graph + QAOA optimization.
116
+
117
+ ### 2. Memory Deduplication
118
+
119
+ Keeps your memory clean — merges near-duplicates automatically:
120
+
121
+ ```python
122
+ from quantum_memory_graph.dedup import MemoryDeduplicator
123
+
124
+ dedup = MemoryDeduplicator(threshold=0.95)
125
+
126
+ # Dry run first
127
+ stats = dedup.merge_duplicates(graph, dry_run=True)
128
+ print(f"Would remove {stats['duplicates_removed']} duplicates")
129
+
130
+ # Real merge — keeps the richest version of each memory
131
+ stats = dedup.merge_duplicates(graph)
132
+ print(f"Removed {stats['duplicates_removed']}, merged {stats['entities_merged']} entities")
133
+ ```
134
+
135
+ Smart canonical selection: keeps the memory with the most entities, most recent timestamp, and longest text.
136
+
137
+ ### 3. Cross-Agent Memory Sharing
138
+
139
+ Shared knowledge pool with access control:
140
+
141
+ ```python
142
+ from quantum_memory_graph.sharing import SharedMemoryPool
143
+
144
+ pool = SharedMemoryPool(db_path="~/.qmg/shared_pool.db")
145
+
146
+ # Store shared knowledge — visible to specific agents or all
147
+ pool.store(
148
+ text="Chef's Attraction runs on CookUnity",
149
+ author_agent="daisy",
150
+ category="business",
151
+ access="public" # or ["daisy", "luigi", "bowser"]
152
+ )
153
+
154
+ # Any authorized agent can recall
155
+ results = pool.recall("CookUnity", requesting_agent="mario", limit=5)
156
+ ```
157
+
158
+ Categories: `business`, `technical`, `rules`, `people`, `general`
159
+
160
+ ### 4. Obsidian Vault Export
161
+
162
+ Visualize your agent's knowledge graph in Obsidian:
163
+
164
+ ```python
165
+ from quantum_memory_graph.obsidian import export_vault, export_from_mem0
166
+
167
+ # Export from a running QMG graph
168
+ export_vault(graph, "/path/to/vault", agent_memories={"daisy": [...], "dk": [...]})
169
+
170
+ # Or pull directly from a Mem0 API
171
+ export_from_mem0(
172
+ mem0_url="http://localhost:8500",
173
+ vault_path="/path/to/vault",
174
+ agents=["daisy", "luigi", "bowser"]
175
+ )
176
+ ```
177
+
178
+ Each memory becomes a markdown note with YAML frontmatter, `[[wikilinks]]` for connections, and `#tags` for entities. Open in Obsidian → Graph View to see your agent's knowledge mapped visually.
179
+
180
+ ### 5. QAOA Subgraph Optimization
181
+
182
+ The core quantum advantage — optimal memory combination selection:
183
+
184
+ ```python
185
+ result = recall(
186
+ "query",
187
+ K=5,
188
+ alpha=0.4, # Relevance weight
189
+ beta_conn=0.35, # Connectivity weight
190
+ gamma_cov=0.25, # Coverage/diversity weight
191
+ hops=3, # Graph traversal depth
192
+ top_seeds=7, # Initial seed nodes
193
+ max_candidates=14, # Max candidates for QAOA
194
+ )
195
+ ```
196
+
197
+ Falls back to greedy selection when Qiskit is not installed — still beats pure similarity search.
198
+
199
+ ### 6. Short-Term Memory
200
+
201
+ Session-aware memory with recency boosting:
202
+
203
+ ```python
204
+ from quantum_memory_graph.recency import ShortTermMemory
205
+
206
+ stm = ShortTermMemory()
207
+ stm.start_session("conv_123")
208
+ stm.add_turn("conv_123", "What's our deadline?", "March 15th")
209
+
210
+ # Recent conversations get boosted in recall
211
+ boosted = stm.boost_results(results, session_id="conv_123")
212
+ ```
213
+
214
+ ## API Server
215
+
216
+ ```bash
217
+ pip install quantum-memory-graph[api]
218
+ python -m quantum_memory_graph.api --port 8502
219
+ ```
220
+
221
+ ### Endpoints
222
+
223
+ | Method | Path | Description |
224
+ |--------|------|-------------|
225
+ | `POST` | `/store` | Store a memory |
226
+ | `POST` | `/store-batch` | Batch store (max 500) |
227
+ | `POST` | `/recall` | Graph + QAOA recall |
228
+ | `POST` | `/dedup` | Run deduplication |
229
+ | `POST` | `/tiers/store` | Store to tier system |
230
+ | `POST` | `/tiers/recall` | Recall from all tiers |
231
+ | `POST` | `/tiers/tick` | Run tier maintenance |
232
+ | `POST` | `/shared/store` | Store shared memory |
233
+ | `POST` | `/shared/recall` | Recall shared memories |
234
+ | `GET` | `/shared/stats` | Shared pool statistics |
235
+ | `POST` | `/obsidian/export` | Export to Obsidian vault |
236
+ | `GET` | `/stats` | Graph statistics |
237
+ | `GET` | `/` | Health check |
238
+
239
+ All endpoints require `Authorization: Bearer <token>` when `QMG_API_TOKEN` is set.
240
+
241
+ ## Choosing a Model
242
+
243
+ | Model | Size | GPU? | R@5 | Best For |
244
+ |-------|------|------|-----|----------|
245
+ | `all-MiniLM-L6-v2` (default) | 90MB | No | 93.4% | Laptops, CI/CD |
246
+ | `BAAI/bge-large-en-v1.5` | 1.3GB | Recommended | 95.9% | Production with GPU |
247
+ | `intfloat/e5-large-v2` | 1.3GB | Recommended | 96.0% | Best ranking (NDCG) |
248
+ | `thenlper/gte-large` | 1.3GB | Recommended | 96.6% | Maximum accuracy |
249
+
250
+ ```python
251
+ from quantum_memory_graph import MemoryGraph
252
+
253
+ mg = MemoryGraph() # Default — works everywhere
254
+ mg = MemoryGraph(model="thenlper/gte-large") # Best accuracy
255
+ ```
256
+
257
+ ## IBM Quantum Hardware
258
+
259
+ For production QAOA on real quantum hardware:
260
+
261
+ ```bash
262
+ pip install quantum-memory-graph[quantum]
263
+ export IBM_QUANTUM_TOKEN=your_token
264
+ ```
265
+
266
+ Validated on `ibm_fez` and `ibm_kingston` backends.
267
+
268
+ ## Requirements
269
+
270
+ - Python ≥ 3.9
271
+ - sentence-transformers, networkx, numpy
272
+ - Optional: qiskit + qiskit-aer (quantum), fastapi + uvicorn (API), spacy (NLP)
273
+
274
+ ## License
275
+
276
+ MIT License — Copyright 2026 Coinkong (Chef's Attraction)
277
+
278
+ ## Links
279
+
280
+ - [GitHub](https://github.com/Dustin-a11y/quantum-memory-graph)
281
+ - [PyPI](https://pypi.org/project/quantum-memory-graph/)
282
+ - [Changelog](CHANGELOG.md)
283
+
284
+ ## Author
285
+
286
+ Built by **Dustin Taylor** / Coinkong — Chef's Attraction AI Lab
287
+
288
+ - 𝕏 [@Coinkong](https://x.com/Coinkong)
289
+ - 📸 [@Dustin.c.Taylor](https://instagram.com/Dustin.c.Taylor)