<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Prathamesh Saraf · Blog</title>
    <link>https://prathameshsaraf.com/blogs/</link>
    <description>I help enterprise teams ship production GenAI: voice agents, agentic workflows, RAG, and the infrastructure to make them stick.</description>
    <language>en</language>
    <atom:link href="https://prathameshsaraf.com/rss.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>FlashAttention 2: Three Places the Chip Was Still Waiting</title>
      <link>https://prathameshsaraf.com/blogs/inference-04-flashattention-2/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/inference-04-flashattention-2/</guid>
      <pubDate>Tue, 01 Sep 2026 00:00:00 GMT</pubDate>
      <description>FlashAttention 1 solved the memory wall and still left three quarters of the tensor cores idle. The fix was not a better algorithm but an inventory of where the chip was waiting: bookkeeping on the wrong cores, too few thread blocks to fill the machine, and warps trading partial results they never should have held. Three rearrangements roughly double the fraction of peak, and then Hopper arrives and takes most of it back.</description>
      <category>llm-inference</category>
      <category>flash-attention</category>
      <category>kernels</category>
      <category>gpu</category>
      <category>occupancy</category>
      <category>warps</category>
      <category>scheduling</category>
    </item>
    <item>
      <title>Kernels and FlashAttention: When the Same Math Runs 7.6x Faster</title>
      <link>https://prathameshsaraf.com/blogs/inference-03-kernels-and-flashattention/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/inference-03-kernels-and-flashattention/</guid>
      <pubDate>Thu, 20 Aug 2026 00:00:00 GMT</pubDate>
      <description>Two kernels can compute identical attention on the same GPU and finish 7.6 times apart. The arithmetic cannot be the difference, so the whole gap lives in data movement. This post builds FlashAttention from first principles: why the N-by-N score matrix is the problem, how tiling keeps it off the memory bus, and how online softmax makes tiling legal, and why the result is exact rather than an approximation.</description>
      <category>llm-inference</category>
      <category>flash-attention</category>
      <category>kernels</category>
      <category>triton</category>
      <category>attention</category>
      <category>softmax</category>
      <category>gpu</category>
    </item>
    <item>
      <title>Inside the GPU: Why Moving a Byte Costs More Than Multiplying One</title>
      <link>https://prathameshsaraf.com/blogs/inference-02-inside-the-gpu/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/inference-02-inside-the-gpu/</guid>
      <pubDate>Fri, 14 Aug 2026 00:00:00 GMT</pubDate>
      <description>The last post found the bottleneck. This one opens the machine that creates it. You will see why a GPU spends its silicon on 270,000 slow threads instead of a few fast ones, why a trip to HBM costs 482 cycles while a register costs 1, how the chip hides that wait instead of avoiding it, and what two programming mistakes throw the whole advantage away. It ends on a controlled experiment Nvidia effectively ran for us: the same compute die with faster memory, and what that proves about inference.</description>
      <category>llm-inference</category>
      <category>gpu</category>
      <category>cuda</category>
      <category>tensor-cores</category>
      <category>memory-hierarchy</category>
      <category>quantization</category>
      <category>nvlink</category>
      <category>systems</category>
    </item>
    <item>
      <title>The Memory Wall: Where the 30 Milliseconds Actually Go</title>
      <link>https://prathameshsaraf.com/blogs/inference-01-memory-wall/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/inference-01-memory-wall/</guid>
      <pubDate>Mon, 10 Aug 2026 00:00:00 GMT</pubDate>
      <description>A frontier model emits an output token about every 30 milliseconds, but the arithmetic inside that token takes a tenth of a millisecond. This post accounts for the other 99 percent. You will derive an H100's ridge point of 295 operations per byte, place prefill and decode on a roofline 2,000x apart, compute a KV cache down to the byte, and finish able to predict any model's decode speed on any chip from just two numbers.</description>
      <category>llm-inference</category>
      <category>memory-wall</category>
      <category>roofline</category>
      <category>kv-cache</category>
      <category>gpu</category>
      <category>transformers</category>
      <category>systems</category>
    </item>
    <item>
      <title>DPO and Agentic RL: Align Without a Reward Model, Then Step Into the World</title>
      <link>https://prathameshsaraf.com/blogs/09-dpo-and-agentic-rl/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/09-dpo-and-agentic-rl/</guid>
      <pubDate>Tue, 30 Jun 2026 00:00:00 GMT</pubDate>
      <description>Two moves close the series. First we simplify: Direct Preference Optimization reaches the same aligned model as RLHF while firing both the reward model and the RL loop, and SimPO and KTO trim it further. Then we expand: point the same group-relative gradient at a multi-step world and the model stops answering and starts acting, calling tools, reading observations, and earning a reward only at the end. You will see the DPO loss derived from the RLHF objective, every number of a worked preference, and a runnable multi-turn agent that learns to use a tool from reward alone.</description>
      <category>reinforcement-learning</category>
      <category>dpo</category>
      <category>simpo</category>
      <category>kto</category>
      <category>preference-optimization</category>
      <category>agentic-rl</category>
      <category>rl-environments</category>
      <category>llm</category>
    </item>
    <item>
      <title>GRPO: Teaching a Model to Reason by Comparing It to Itself</title>
      <link>https://prathameshsaraf.com/blogs/08-grpo/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/08-grpo/</guid>
      <pubDate>Tue, 23 Jun 2026 00:00:00 GMT</pubDate>
      <description>RLHF aligned a model with two heavy passengers: a learned reward model and a value-head critic. This post throws both away. You will see why the critic was only ever a baseline and how a group of sampled answers replaces it for free, why a verifiable check beats a hackable reward model for math and code, how GRPO wraps that group-relative advantage in PPO's clip, and how this exact recipe produced DeepSeek-R1, all grounded in a hands-on run that trains Llama-3.2-3B to reason on grade-school math.</description>
      <category>reinforcement-learning</category>
      <category>grpo</category>
      <category>verifiable-rewards</category>
      <category>rlvr</category>
      <category>deepseek-r1</category>
      <category>reasoning</category>
      <category>ppo</category>
    </item>
    <item>
      <title>RLHF: Teaching a Language Model What &quot;Good&quot; Means</title>
      <link>https://prathameshsaraf.com/blogs/07-rlhf/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/07-rlhf/</guid>
      <pubDate>Tue, 16 Jun 2026 00:00:00 GMT</pubDate>
      <description>A language model only ever predicts the next token. This post earns the sentence &quot;PPO aligned ChatGPT&quot;: how generating text becomes an MDP, how human comparisons become a Bradley-Terry reward model, how a value head turns one end-of-answer score into a per-token signal, and how the KL leash keeps PPO from gaming a flawed reward, grounded in a hands-on build that aligns a tiny GPT-2 assistant.</description>
      <category>reinforcement-learning</category>
      <category>rlhf</category>
      <category>reward-model</category>
      <category>bradley-terry</category>
      <category>ppo</category>
      <category>kl-penalty</category>
    </item>
    <item>
      <title>TRPO and PPO: The Largest Safe Step a Policy Can Take</title>
      <link>https://prathameshsaraf.com/blogs/06-trpo-ppo/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/06-trpo-ppo/</guid>
      <pubDate>Tue, 09 Jun 2026 00:00:00 GMT</pubDate>
      <description>The gradient gives a direction, but who chooses the step size? This post explores the step-size crisis in RL, builds importance sampling from scratch, derives the surrogate objective, fences it with TRPO's KL constraint, then clips it with PPO, all grounded in a continuous-control example where PPO learns to swing a pendulum upright.</description>
      <category>reinforcement-learning</category>
      <category>ppo</category>
      <category>trpo</category>
      <category>importance-sampling</category>
      <category>trust-region</category>
      <category>gymnasium</category>
    </item>
    <item>
      <title>Policy Gradients: Learning the Policy Directly, from a Bandit to Actor-Critic</title>
      <link>https://prathameshsaraf.com/blogs/05-policy-gradients/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/05-policy-gradients/</guid>
      <pubDate>Tue, 02 Jun 2026 00:00:00 GMT</pubDate>
      <description>Stop learning values and reading a policy off them: parameterize the policy and climb expected reward directly. We derive the score-function trick on a one-state Archer bandit, watch one softmax update touch all nine logits, kill the variance with a baseline, add states and credit assignment, and end on an Actor-Critic that solves the Archer MDP.</description>
      <category>reinforcement-learning</category>
      <category>policy-gradients</category>
      <category>reinforce</category>
      <category>actor-critic</category>
      <category>advantage</category>
      <category>gymnasium</category>
    </item>
    <item>
      <title>SARSA, Q-learning, and DQN: From a Table to a Network That Plays Atari</title>
      <link>https://prathameshsaraf.com/blogs/04-sarsa-qlearning-dqn/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/04-sarsa-qlearning-dqn/</guid>
      <pubDate>Tue, 26 May 2026 00:00:00 GMT</pubDate>
      <description>Control = prediction + a max. We turn the TD update into Q-learning and SARSA, watch them disagree on a cliff, then swap the table for a neural network and train a DQN that learns Pong from raw pixels.</description>
      <category>reinforcement-learning</category>
      <category>q-learning</category>
      <category>sarsa</category>
      <category>dqn</category>
      <category>deep-rl</category>
      <category>gymnasium</category>
    </item>
    <item>
      <title>DP, Monte Carlo, and TD: Three Ways to Solve the Bellman Equation</title>
      <link>https://prathameshsaraf.com/blogs/03-dp-mc-td/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/03-dp-mc-td/</guid>
      <pubDate>Tue, 19 May 2026 00:00:00 GMT</pubDate>
      <description>Three algorithms (Dynamic Programming, Monte Carlo, and TD(0)) all solve the same Bellman equation. You'll implement each on a custom Mars Rover gridworld and watch them converge to the same values from different starting assumptions.</description>
      <category>reinforcement-learning</category>
      <category>dynamic-programming</category>
      <category>monte-carlo</category>
      <category>temporal-difference</category>
      <category>gymnasium</category>
    </item>
    <item>
      <title>MDPs and the Bellman Equation: The Recursion Behind Every RL Algorithm</title>
      <link>https://prathameshsaraf.com/blogs/02-mdps-and-bellman/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/02-mdps-and-bellman/</guid>
      <pubDate>Tue, 12 May 2026 00:00:00 GMT</pubDate>
      <description>How to formalize an environment as a Markov Decision Process, why the value of a state splits into V and Q, and the Bellman equation that ties them together recursively. Derive it once, verify it by hand, then solve it exactly on FrozenLake in Gymnasium.</description>
      <category>reinforcement-learning</category>
      <category>mdp</category>
      <category>bellman-equation</category>
      <category>gymnasium</category>
    </item>
    <item>
      <title>Reinforcement Learning from First Principles (and the Math You Actually Need)</title>
      <link>https://prathameshsaraf.com/blogs/01-rl-intro-and-prerequisites/</link>
      <guid isPermaLink="true">https://prathameshsaraf.com/blogs/01-rl-intro-and-prerequisites/</guid>
      <pubDate>Tue, 05 May 2026 00:00:00 GMT</pubDate>
      <description>What RL really is, why 'how good' means 'how good on average', and the five pieces of math (expectation, the Markov property, variance, running averages, and discounting) that the rest of the field is built on. Intuition first, one clean derivation each, a worked example, then code with Gymnasium.</description>
      <category>reinforcement-learning</category>
      <category>fundamentals</category>
      <category>probability</category>
      <category>gymnasium</category>
    </item>
  </channel>
</rss>
