Archive

1422 posts · Page 8 of 119. ← Blog

Pratik Dhanave · ·5 min read

Learning to Denoise — DDPM and the Loss That Trains Every Image Model

The reverse of destruction is generation — but only if a network can learn to run one small step of the destruction backwards. The surprise at the heart of DDPM is how plain the training recipe turned out to be: corrupt an image, ask the network which noise was added, score it with mean squared error. No adversary, no instability — a regression loss so simple it reads like a tutorial exercise, hiding a derivation that connects it to maximum likelihood.

Small Gaussian forward steps make each reverse step approximately Gaussian — so generation reduces to regression. DDPM's recipe: predict the added noise, score it with plain mean squared error, sample by walking the chain backwards with fresh noise injected each step. Four lines of training loop, and why they beat the trilemma.

Pratik Dhanave · ·4 min read

The FDE Craft: People, Practice & Influence

Everything technical in this field guide runs on something human: the ability to work with stakeholders, grow in the role, build a team, and shape a community. This theme is the craft and the career — the part that doesn't show up in a repo but decides whether the rest works. This post maps it.

Everything technical runs on something human: working with stakeholders, growing in the role, building a team, and shaping a community. The craft and the career — stakeholders, the role and spectrum, careers, hiring, mentoring and coaching, community and influence — plus why the role is exploding at AI companies and builder-communicators are the scarce resource.

Pratik Dhanave · ·4 min read

The Durable Intake Architecture — Queues Behind Endpoints, DLQs, and Poison Events

The naive webhook handler does everything inline: receive, verify, run business logic, call three services, return 200. It works in the demo and fails in every interesting way in production — timeouts under load, lost events on deploy, one bad payload blocking the stream. The production architecture is almost boringly uniform across serious teams: a thin endpoint that durably enqueues and immediately acks, workers that process from the queue, and explicit machinery for the events that refuse to process. This post builds that architecture piece by piece.

The production receiver: a thin verifying endpoint that durably enqueues and acks in milliseconds, workers processing idempotently partitioned by resource, bounded retries for transients, and a monitored, diagnosable, replayable DLQ so one poison payload never dams the stream. The dashboard falls out of the design.

Pratik Dhanave · ·4 min read

Dual-Writes and Shadow Reads — Proving Two Copies Agree

Every serious migration passes through a phase where the same truth lives in two places — old column and new, old table and new, old store and new — and the entire migration's integrity rests on those copies agreeing. Hope is not a strategy and spot-checking is barely one; the disciplines that actually prove agreement are dual-writes done with eyes open, shadow reads that compare on every request, and diff sweeps that check everything else. This is the migration's measurement layer — post 1's third vow made operational.

The measurement layer: dual-writes with the race named (source of truth declared, outbox/CDC when stakes outgrow tolerate-and-repair), shadow reads comparing on live traffic with noise filtering, diff sweeps for the cold data — all feeding idempotent repair and producing the agreement rate that gates cutover.

Pratik Dhanave · ·4 min read

The Fraud Problem — Adversarial, Asymmetric, and Allergic to Textbook ML

Fraud detection looks like a classification problem and behaves like nothing else in machine learning: the adversary adapts to your model, the classes are wildly imbalanced, the labels arrive months late, your own decisions censor the data you learn from, and both kinds of error cost real money in different currencies. This series builds fraud and risk systems from first principles — and this opening post is about why the textbook assumptions fail, because every architecture decision downstream flows from these five inversions.

Fraud inverts the textbook five ways: an adversary that adapts to your model, tiny base rates with asymmetric error currencies, labels that arrive months late and partly wrong, decisions that censor their own training data, and a milliseconds budget in the payment path. The answer is a decision system, not a classifier. Opens the series.

Pratik Dhanave · ·4 min read

Gradual Typing Migrations — Retrofitting Types onto a Living Codebase

The great typing migrations — millions of dynamic-language lines brought under TypeScript, or type checkers built for Ruby and Python — are the canonical org-loop projects: multi-year, codebase-wide, impossible to pause the business for, and transformative when they land. They're worth studying even if you never run one, because they exercise every DevProd muscle at once: incremental adoption machinery, codemod fleets, ratchets that prevent backsliding, and the political craft of keeping a thousand engineers on board for years.

The worked example of org-loop transformation: a strictness map turned module by module, explicit boundaries with counted escape hatches, trunk-first sequencing — run on inference-powered codemod fleets, a CI ratchet making typedness monotonic, and the political craft that keeps a thousand engineers on board for years.

Pratik Dhanave · ·5 min read

The Forward Process — Destroying Images with Noise, Carefully

Diffusion models begin with the only part of the pipeline that involves no learning at all: a fixed, mechanical procedure that gradually turns any image into pure static. It seems almost too simple to matter — yet every design choice in it (Gaussian noise, small steps, a schedule, a closed-form shortcut) is load-bearing for everything the model later learns. Understanding the destruction is half of understanding the generation.

The forward process is a fixed Markov chain that turns any image into pure Gaussian static — no learning anywhere. Why Gaussian noise (closure), what the noise schedule allocates (practice time across corruption levels), the closed-form jump that makes training random-access, and the known endpoint generation starts from.

Pratik Dhanave · ·3 min read

Shipping AI: Production, Security & Reliability

Proving value on a prototype is the halfway point. The other half — and the harder one — is making it survive production: evaluated, secured, compliant, reliable, and owned by the customer's team. This post maps the shipping theme of the field guide, where most AI initiatives actually stall.

Proving value on a prototype is the halfway point; the harder half is making it survive production — evaluated, secured, compliant, reliable, and owned by the customer's team. Deployment, evaluation, AI security, sovereignty and compliance, reliability, and handover, plus the new AI topics (agent security, operationalized governance, sovereign AI, evals as infrastructure).

Pratik Dhanave · ·4 min read

Webhook Security — Signatures, Replay Windows, and the Attack Surface Nobody Audits

A webhook endpoint is a public URL that accepts POSTs and changes state in your systems — which is to say, it's an unauthenticated write API unless you make it otherwise. The security model is well understood and regularly skipped: verify signatures correctly (several popular ways to do it wrong), bound the replay window, and remember that on the provider side, delivering webhooks means making HTTP requests to arbitrary customer URLs — an SSRF machine by design. This post covers both directions of the attack surface.

Receivers: HMAC over raw bytes, constant-time, scheme-aware, rotatable secret lists; signed-timestamp replay windows; fail closed loudly — and schema-validate anyway. Providers: webhook delivery is SSRF by design — resolve-validate-pin destinations, egress-isolate workers, bound and never echo responses.

Pratik Dhanave · ·4 min read

Backfills at Scale — Rewriting a Billion Rows Under Live Traffic

The expand phase created an empty column; something has to fill it for a billion existing rows while production traffic continues oblivious. Backfills are the manual labor of migrations — conceptually trivial, operationally where migrations actually spend their calendar time and take their production risks. The craft is entirely in the adverbs: incrementally, throttled, resumably, idempotently.

Backfills are made safe by four adverbs: incrementally (keyset-walked, time-sized, per-batch-committed), throttled (a control loop yielding to replication lag, content to take days), resumably (transactional checkpoints), idempotently (absolute writes, safe re-runs). The transform is reviewed code with a verify-only mode.

Pratik Dhanave · ·4 min read

Codemods at Scale — Changing Ten Thousand Call Sites Before Lunch

Every large codebase carries changes everyone wants and no one will do: the deprecated API with ten thousand call sites, the formatting standard half-adopted, the pattern that post-dates most of the code. By hand they're quarter-long projects that die in review; as codemods — programs that rewrite programs — they're an afternoon of transform engineering and an overnight run. The capability compounds: an organization that can safely change everything everywhere stops being afraid of its own codebase.

Codemods are programs that rewrite programs: AST-based (semantic targeting, idempotent, format-preserving), honest about their residue. Landing is logistics — ownership-sharded PR fleets, review the transform plus sampled output, lint rules closing the door. The product is reversibility at codebase scale.

Pratik Dhanave · ·5 min read

Why Generating Images Is Hard — The Problem Diffusion Solved

Every text-to-image system — Stable Diffusion, Midjourney, DALL·E, Imagen — rests on one idea: destroy an image with noise, then learn to run the destruction backwards. Before that idea, a decade of generative modeling fought a three-way trade-off between sample quality, training stability, and diversity — and every architecture picked two. This series builds diffusion models from first principles: what problem they solve, why the math works, and how the pieces (latents, guidance, transformers, flow matching) assembled into the systems generating images and video today.

Every text-to-image system rests on one idea: destroy an image with noise, then learn to run the destruction backwards. Why generation is sampling (not prediction), how VAEs blur and GANs collapse, the quality/diversity/stability trilemma — and the iterative-refinement move that escaped it, opening a 10-post series.