Loading video...

Video Failed to Load

Go Home

A developer figured out how to give AI permanent memory for $0.40 a year. No complex vector databases. No massive cloud storage. Just a single 4,000-token file that refuses to grow. The secret? True memory isn’t about storing everything. It’s about aggressive deletion. Instead of endlessly appending data, his...

17,304 views • 9 days ago •via X (Twitter)

0 Comments

No comments available

Comments from the original post will appear here

Related Videos

A tricky LLM interview question: You're serving a reasoning model on vLLM, and it keeps running out of GPU memory on long traces. So you add KV cache compression and evict 90% of the cached tokens. VRAM usage stays as is and GPU still runs out of memory. Why? (answer below) Evicting 90% of the KV cache can free almost none of the memory it was using. This sounds counterintuitive, but it follows directly from how production servers store the cache today. The KV cache grows with every token a model generates. Each token appends its key and value vectors across every layer, and nothing is freed while generation continues. This is the dominant memory cost for reasoning models. If a 32K-token CoT caches ~32K tokens of KV vectors, a Qwen3-32B with 4-bit weights will run out-of-memory around 24K tokens on a 24GB GPU. One obvious solution is to keep the important tokens and drop the rest, since attention is sparse enough to allow it. But this does not solve the memory problem yet. The reason is paged attention, which is the memory manager behind vLLM and most production servers. Under the hood, it splits GPU memory into fixed physical blocks, each one holds the KV for about 16 tokens. This block returns to the allocator only when every slot inside it is empty. Since the eviction logic selects tokens by importance, and such tokens are scattered across blocks... ...so despite eviction, almost every block is left with at least some survivor tokens. For instance, if the logic evicts 14k of 16k tokens across 1,000 blocks, most likely every block will still have a token. This means the allocator frees almost nothing. Placing the new tokens into those freed slots is not ideal because it breaks the cache's layout. Say token 16,001 arrives, and it's placed in the slot the 40th token used to hold. The cache now reads position 38, then 16,001, then 41, so the cache is no longer in token order. Attention can still compute the right answer from that, but only if every slot now carries a separate note recording which position it actually holds. This introduces another bookkeeping cost that an in-order layout inherently avoids. So the cache is logically 90% smaller and still physically the same size. Many compression results miss this because they measure on pre-allocated contiguous tensors rather than a paged server. There's another problem. Eviction methods pick which tokens to keep by looking at the attention scores themselves (as expected). But fast attention kernels used in production, like FlashAttention, never save those scores. They compute attention in small pieces and throw the full score grid away as they go, which is also why they're fast. So the exact signal eviction methods need isn't available in memory. The workaround is to fall back to eager attention and build the full matrix, which gives up the speed FlashAttention was there to provide. NVIDIA published a method called TriAttention to solve both these problems. It never needs attention scores. Instead, it scores tokens from the geometry of the model's key and query vectors before RoPE is applied, where those vectors sit in stable clusters. For the memory problem, it runs a compaction pass every 128 decoded tokens. The surviving tokens slide forward to close the holes eviction creates, so whole blocks empty out and return to the allocator while the cache stays in token order. On long reasoning traces, the approach matches full-attention accuracy while decoding 2.5x faster and using 10.7x less KV memory. KV cache compression is a big infrastructure problem. The number that decides whether it works is the count of freed blocks, not the count of evicted tokens. You can find the NVIDIA write-up here: I wrote a first-principles breakdown of how the KV cache works. It walks through why the model stores keys and values at all, why the cache grows with every token, and a comparison of LLM generation speed with and without KV caching. Read it below.

Avi Chawla

271,839 views • 2 months ago

THIS GUY AUDITED 926 CLAUDE CODE SESSIONS AND FOUND MOST OF THE TOKEN WASTE WAS ON HIS SIDE everyone is blaming anthropic for the limits, so he decided to actually look at the data 858 sessions, 18,903 turns, and $1,619 estimated spend across 33 days here's what he found: 1\ one default setting was burning 14,000 tokens per turn Claude Code loads the full JSON schema for every tool into context at session start. whether you use them or not. 20,000 tokens of tool definitions sitting there on every single turn. the fix: one line in your settings.json "ENABLE_TOOL_SEARCH": "true" context dropped from 45K to 20K instantly. across 858 sessions that one setting was wasting an estimated 264 million tokens 2\ cache expiry is the single biggest waste 54% of his turns came after a 5+ minute idle gap. every one of those turns re-processed the entire conversation at full price which caused a 10x cost jump you go grab coffee. come back 5 minutes later. type your next message. everything rebuilds from scratch. the context didn't change. you didn't change. the cache just expired. 12.3 million tokens wasted on idle gaps alone 3\ 42 skills loaded. 19 of them used twice or less across 858 sessions. every one of those skill schemas sat in context on every turn eating tokens for nothing. 4\ 1,122 redundant file reads where the same file was read 3+ times one session read the same file 33 times. he ALSO built a full token auditor dashboard that shows you exactly where your waste is coming from 19 charts, opens in your browser, free AND open source

Om Patel

299,832 views • 5 months ago

HERMES AGENT WITHOUT THESE 3 FILES IS A CHATBOT. WITH THEM IT KNOWS WHO IT IS, WHO YOU ARE, AND WHAT IT LEARNED. SOUL.md — who the agent is. first thing in the system prompt. defines personality, voice, values, how it operates, what it can and can't do. structure yours like this: → identity (name, role, relationship to you) → values (what matters, what principles guide decisions) → voice (how it communicates, tone, style) → operations (autonomy level, ground rules) → restrictions (what it never does) → failure protocol (how to operate when things break) lives in ~/.hermes/SOUL.md. auto-seeded on first install. edit anytime. scanned for prompt injection on every load. keep it concise. SOUL.md injects into every turn. a 200-line soul burns tokens on every message. aim for 50-80 lines. one paragraph per section. MEMORY.md — what the agent remembers. persistent facts, insights, preferences. survives across sessions and restarts. capped at ~800 tokens by default: memory: memory_char_limit: 2200 the agent writes to this automatically as it learns about your work. USER.md — who you are. your profile, preferences, context. capped at ~500 tokens by default: memory: user_char_limit: 1375 injected every turn so the agent always knows who it's working for. bonus: AGENTS.md — project-specific instructions. drop one in any project folder. subdirectory AGENTS.md files load lazily during tool calls, not at startup. keeps your system prompt light. prompt stack order on every turn: SOUL.md → tool guidance → MEMORY.md + USER.md → skills index → AGENTS.md → platform hints skills come preloaded. 60+ built-in tools. the agent creates more skills from completed work. you focus on these 3 files. each profile gets its own copy: ~/.hermes/SOUL.md (default profile) ~/.hermes/profiles/researcher/SOUL.md ~/.hermes/profiles/ops/SOUL.md different agent, different soul, different memory, same machine. full breakdown of Hermes as a Personal AI OS in the article 👇

YanXbt

28,924 views • 2 months ago

.Dwarkesh Patel: By 2030, it will be less expensive to monitor every single nook and cranny in America than it is to remodel the White House. “Mass surveillance is, at least in certain forms, already legal. It has just been impractical to enforce so far. Under current law, you have no Fourth Amendment protection against any data you share with a third party. That includes your bank, your ISP, your phone carrier, and your email provider. The government reserves the right to purchase and read this data in bulk without a warrant. What’s been missing is the ability to actually do anything with all of this data — no agency has the manpower to monitor every single camera, read every single message, and cross-reference every single transaction. However, that bottleneck goes away with AI. There are 100 million CCTV cameras in America. You can get pretty good open source multimodal models for 10 cents per million input tokens. So if you process a frame every ten seconds, and each frame is 1,000 tokens, then for 30 billion dollars, you can process every single camera in America. And remember that a given level of AI ability gets 10x cheaper every single year - so a year from now it’ll cost 3 billion, and then a year after 300 million, and by 2030, it’ll be less expensive to monitor every single nook and cranny in this country than it is to remodel the White House. Once the technical capacity for mass surveillance and political suppression exists, the only thing standing between us and an authoritarian state is the political expectation that this is not something we do here.”

Arjun Khemani

145,706 views • 5 months ago