<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Parallelism on Duo&#39;s Tech Blog</title>
    <link>https://duoan.github.io/tags/parallelism/</link>
    <description>Recent content in Parallelism on Duo&#39;s Tech Blog</description>
    <image>
      <title>Duo&#39;s Tech Blog</title>
      <url>https://duoan.github.io/images/papermod-cover.png</url>
      <link>https://duoan.github.io/images/papermod-cover.png</link>
    </image>
    <generator>Hugo -- 0.153.1</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 09 Jun 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://duoan.github.io/tags/parallelism/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Hiding Tensor-Parallel Collectives: AG/RS Overlap in Megatron</title>
      <link>https://duoan.github.io/posts/megatron-tp-comm-overlap/</link>
      <pubDate>Mon, 09 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://duoan.github.io/posts/megatron-tp-comm-overlap/</guid>
      <description>&lt;h1 id=&#34;hiding-tensor-parallel-collectives-agrs-overlap-in-megatron&#34;&gt;Hiding Tensor-Parallel Collectives: AG/RS Overlap in Megatron&lt;/h1&gt;
&lt;p&gt;Once Megatron SP is enabled, tensor-parallel communication often appears as AllGather and ReduceScatter rather than a single AllReduce.
That is a memory win because activations can stay sequence-sharded between tensor-parallel regions.
It also creates a scheduling question.
Can the collectives be hidden under GEMM work?
That question sits directly on top of Megatron&amp;rsquo;s tensor/sequence-parallel training path (&lt;a href=&#34;https://arxiv.org/abs/2104.04473&#34;&gt;arXiv:2104.04473&lt;/a&gt;, &lt;a href=&#34;https://arxiv.org/abs/2205.05198&#34;&gt;arXiv:2205.05198&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;This post is about that scheduling question.
It complements &lt;a href=&#34;../tensor-parallelism-megatron/&#34;&gt;Megatron tensor parallelism&lt;/a&gt; and &lt;a href=&#34;../sequence-parallelism-megatron-sp/&#34;&gt;Megatron SP&lt;/a&gt;.
The goal is not to memorize every flag in Megatron or Transformer Engine.
The goal is to recognize where the dependency graph allows overlap and where it does not.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sequence Parallelism IV: Megatron Context Parallel and Load-Balanced Rings</title>
      <link>https://duoan.github.io/posts/megatron-context-parallel/</link>
      <pubDate>Mon, 02 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://duoan.github.io/posts/megatron-context-parallel/</guid>
      <description>&lt;h1 id=&#34;sequence-parallelism-iv-megatron-context-parallel-and-load-balanced-rings&#34;&gt;Sequence Parallelism IV: Megatron Context Parallel and Load-Balanced Rings&lt;/h1&gt;
&lt;p&gt;Megatron Context Parallel, usually shortened to CP, brings long-context attention into Megatron&amp;rsquo;s hybrid-parallel world.
It keeps the familiar tensor, pipeline, and data-parallel axes, then adds a context axis that shards the sequence.
Inside that context group, attention behaves like a ring, borrowing the same blockwise K/V circulation idea as Ring Attention (&lt;a href=&#34;https://arxiv.org/abs/2310.01889&#34;&gt;arXiv:2310.01889&lt;/a&gt;) while staying compatible with Megatron-style tensor and pipeline parallelism (&lt;a href=&#34;https://arxiv.org/abs/2104.04473&#34;&gt;arXiv:2104.04473&lt;/a&gt;).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sequence Parallelism III: Ring Attention for Context That Does Not Fit</title>
      <link>https://duoan.github.io/posts/ring-attention/</link>
      <pubDate>Mon, 26 May 2025 00:00:00 +0000</pubDate>
      <guid>https://duoan.github.io/posts/ring-attention/</guid>
      <description>&lt;h1 id=&#34;sequence-parallelism-iii-ring-attention-for-context-that-does-not-fit&#34;&gt;Sequence Parallelism III: Ring Attention for Context That Does Not Fit&lt;/h1&gt;
&lt;p&gt;Megatron SP reduces replicated activation memory around tensor-parallel blocks.
DeepSpeed Ulysses uses All-to-All to turn sequence shards into head shards for attention.
Ring Attention changes the unit of work again.
It asks each rank to keep a block of queries fixed, then circulate key/value blocks around a ring until every query block has seen every key/value block it needs.
That is the core idea in &lt;em&gt;Ring Attention with Blockwise Transformers for Near-Infinite Context&lt;/em&gt; (&lt;a href=&#34;https://arxiv.org/abs/2310.01889&#34;&gt;arXiv:2310.01889&lt;/a&gt;).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sequence Parallelism II: DeepSpeed Ulysses and All-to-All Attention</title>
      <link>https://duoan.github.io/posts/sequence-parallelism-ulysses/</link>
      <pubDate>Mon, 19 May 2025 00:00:00 +0000</pubDate>
      <guid>https://duoan.github.io/posts/sequence-parallelism-ulysses/</guid>
      <description>&lt;h1 id=&#34;sequence-parallelism-ii-deepspeed-ulysses-and-all-to-all-attention&#34;&gt;Sequence Parallelism II: DeepSpeed Ulysses and All-to-All Attention&lt;/h1&gt;
&lt;p&gt;Megatron SP is a careful memory optimization around an existing tensor-parallel block.
DeepSpeed Ulysses starts from a different question.
What if each device owns a sequence slice most of the time, but attention temporarily wants each device to own a head slice instead?&lt;/p&gt;
&lt;p&gt;The answer in DeepSpeed Ulysses is an All-to-All transpose (&lt;a href=&#34;https://arxiv.org/abs/2309.14509&#34;&gt;arXiv:2309.14509&lt;/a&gt;).
Before attention, every rank has all heads for a subset of tokens.
After All-to-All, every rank has all tokens for a subset of heads.
That one layout change lets local attention run per head while the rest of the layer can remain sequence-sharded.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sequence Parallelism I: Megatron SP Cuts Activation Memory Along the Sequence</title>
      <link>https://duoan.github.io/posts/sequence-parallelism-megatron-sp/</link>
      <pubDate>Mon, 12 May 2025 00:00:00 +0000</pubDate>
      <guid>https://duoan.github.io/posts/sequence-parallelism-megatron-sp/</guid>
      <description>&lt;h1 id=&#34;sequence-parallelism-i-megatron-sp-cuts-activation-memory-along-the-sequence&#34;&gt;Sequence Parallelism I: Megatron SP Cuts Activation Memory Along the Sequence&lt;/h1&gt;
&lt;p&gt;Tensor parallelism is usually introduced as a way to make matrix multiplications fit.
That is true, but it hides a second problem.
After the weights are split, many activations are still replicated on every tensor-parallel rank.
For short contexts this is tolerable.
For long contexts it becomes one of the reasons training throughput collapses into activation checkpointing.&lt;/p&gt;
&lt;p&gt;Megatron sequence parallelism, usually shortened to Megatron SP, is a targeted fix from &lt;em&gt;Reducing Activation Recomputation in Large Transformer Models&lt;/em&gt; (&lt;a href=&#34;https://arxiv.org/abs/2205.05198&#34;&gt;arXiv:2205.05198&lt;/a&gt;).
It does not replace tensor parallelism.
It keeps Megatron&amp;rsquo;s column-parallel and row-parallel linear layers, then shards the sequence-local regions that tensor parallelism had left replicated.
The trick is small enough to miss and important enough to change the memory budget of a whole Transformer block.&lt;/p&gt;</description>
    </item>
    <item>
      <title>LLM Training Series: A Systems Map for Distributed Transformers</title>
      <link>https://duoan.github.io/posts/llm-training-series/</link>
      <pubDate>Sun, 02 Mar 2025 00:00:00 +0000</pubDate>
      <guid>https://duoan.github.io/posts/llm-training-series/</guid>
      <description>&lt;h1 id=&#34;llm-training-series-a-systems-map-for-distributed-transformers&#34;&gt;LLM Training Series: A Systems Map for Distributed Transformers&lt;/h1&gt;
&lt;p&gt;LLM training stops being &amp;ldquo;run the model on more GPUs&amp;rdquo; the moment one replica no longer fits, one link becomes the step time, or one schedule leaves half the cluster idle. From that point on, the training run is a placement problem.&lt;/p&gt;
&lt;p&gt;The stable question is simple: &lt;strong&gt;which bytes are replicated, which bytes are sharded, and which link moves them on the critical path?&lt;/strong&gt; Data parallelism, tensor parallelism, pipeline parallelism, ZeRO, sequence/context parallelism, and expert parallelism are different answers to that question. The public systems that matter - GPipe, Megatron-LM, DeepSpeed ZeRO, PyTorch DDP, GShard, Switch Transformer, and modern Megatron-Core - all expose the same constraints in different shapes (&lt;a href=&#34;https://arxiv.org/abs/1811.06965&#34;&gt;GPipe&lt;/a&gt;, &lt;a href=&#34;https://arxiv.org/abs/1909.08053&#34;&gt;Megatron-LM&lt;/a&gt;, &lt;a href=&#34;https://arxiv.org/abs/1910.02054&#34;&gt;ZeRO&lt;/a&gt;, &lt;a href=&#34;https://arxiv.org/abs/2006.15704&#34;&gt;PyTorch Distributed&lt;/a&gt;, &lt;a href=&#34;https://arxiv.org/abs/2006.16668&#34;&gt;GShard&lt;/a&gt;, &lt;a href=&#34;https://arxiv.org/abs/2101.03961&#34;&gt;Switch Transformer&lt;/a&gt;).&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
