Blog
Notes on backend systems, LLM infrastructure and AI safety, mostly from things I built and got wrong first.
2026
- My research agent's citations were 37% supportedHow I measured whether an agent's citations actually back its claims, why the judge had to be tested first, a prompt change that doubled fully supported citations, and an agentic idea that made them worse.
- I built an agent to debug my agent. Running it found what my tests missed.A diagnosis agent for failed AI-agent jobs, built on one rule: it can investigate anything and decide nothing. Ablations showed why it needs two checks, not one, and running the real loop found six bugs that 400+ unit tests had not.
- Merging multiple sources of truth safelyWhen a system answers a question by combining a stored rule, a cached copy of external data, and a live authoritative source, the merge needs an explicit priority order and explicit staleness handling, or the wrong sources win silently.
- Cloud free tiers don't remove cost, they relocate itA free tier makes one number on the invoice zero. The cost moves into engineering time, architectural complexity, or the risk behind a quota you haven't hit yet.
- When talking to the database directly is fine, and when it isn'tFirebase and Supabase let a client write to the database with security rules as the only gate. Whether that's reasonable depends on how much of your access control can be written declaratively.
- RAG's real bottleneck is trust in the source, not retrievalMost RAG effort goes into retrieval quality: better embeddings, reranking, chunking. Perfect retrieval doesn't guarantee the generated answer traces back to what was retrieved. Faithfulness is separate from relevance, and harder to measure.
- Constraining an LLM's output space beats prompting it to be carefulWhen a wrong answer has real consequences, don't prompt the model to double-check itself. Remove its ability to generate the risky part of the output.
- What chaos testing catches that code review can'tCode review catches the bugs a reviewer can imagine happening. Load and chaos testing catch races, partial failures and resource exhaustion that only exist under real concurrency.
- Fail open vs fail closedWhen the infrastructure behind a check goes down, you have to decide what happens to the request in front of it. Which answer is safer depends on what the check protects.
- Modeling state with more than two outcomesA boolean can only mean two things. Once 'false' has to cover both 'never happened' and 'happened, then got superseded', you need a type with more states.
- A critic-and-revise loop needs a graph, not a pipelineA linear chain of steps can't express 'go back to step 2 if step 3 fails a check'. A revise-and-retry loop needs cyclic control flow, plus a cap so the loop ends.
- Typed signatures instead of hand-written prompt stringsChange a word in a raw prompt string and the output format can shift with nothing to catch it until a user does. Declaring inputs and outputs as a typed signature makes that contract checkable.
- Client-side encryption is a trust boundary decision, not just an algorithmEncrypting data before it leaves the client means the server can't read what it stores. That one choice turns off deduplication, content inspection and anything else that needs the plaintext.
- Erasure coding vs replication: the actual tradeoff behind cheap storageReplication survives failures by storing extra full copies. Erasure coding gets the same guarantee for a fraction of the storage and pays in CPU and complexity instead. The math behind that trade, using a real Reed-Solomon implementation.
- The trap of a perfect eval scoreA perfect score on your own eval is ambiguous. The system might be good, or the eval might never have been hard enough to fail. The number alone can't tell you which.
- Idempotency keys are a caching problemAn idempotency key is a cache with a client-generated key and one specific invalidation rule. It applies to any POST with a side effect, not only payments.
- Preventing overselling in a flash saleHow a flash sale engine keeps inventory correct under load test traffic from 10,000 simulated users, using Redis Lua scripts and an explicit state machine.
- Building a Production-Ready Distributed LLM PlatformWhat I learned building K2-Chat, a self-hosted multimodal AI platform on FastAPI, gRPC and Postgres.
2024
- PyTorch Performance Optimization TipsWays to speed up PyTorch training and inference, from mixed precision to data loading.
- PyTorch Basics: Tensors and AutogradPyTorch basics: tensor operations, automatic differentiation and building a neural network from scratch.
- Finetuning LLMs - A brief OverviewWhat to know before you start finetuning an LLM
- Introduction to Transformer ArchitectureHow the architecture behind GPT, BERT and today's large language models works.
- Grokking in Neural NetworksA mechanistic interpretability perspective into how neural networks suddenly generalize after memorizing training data.
- Refusal Vector Ablation in LLMsUsing mechanistic interpretability to see how large language models decide when and how to refuse harmful requests.
- Understanding PyTorch TensorsPyTorch's basic data structure and how to use it in deep learning code.
- Getting Started with Neural NetworksBuilding your first neural network from scratch using PyTorch and understanding the fundamentals of deep learning.