<?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>Mig on vishctl</title><link>https://vishctl.dev/tags/mig/</link><description>Recent content in Mig on vishctl</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 09 Nov 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://vishctl.dev/tags/mig/index.xml" rel="self" type="application/rss+xml"/><item><title>GPU Sharing on Kubernetes: Time-Slicing, MPS, and MIG, Explained Simply</title><link>https://vishctl.dev/posts/kubernetes-gpu-sharing-time-slicing-mps-mig/</link><pubDate>Mon, 09 Nov 2026 00:00:00 +0800</pubDate><guid>https://vishctl.dev/posts/kubernetes-gpu-sharing-time-slicing-mps-mig/</guid><category>kubernetes</category><category>gpu</category><category>nvidia</category><category>gpu-sharing</category><category>mig</category><category>ai-infra</category><description>A simple, diagram-first guide to sharing one NVIDIA GPU between many Pods: what time-slicing, MPS, and MIG actually isolate, the ConfigMaps that turn them on, and which one fits LLM inference.</description><content:encoded><![CDATA[<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">Kubernetes counts GPU devices, not spare memory or compute.
</span></span><span class="line"><span class="cl">Sharing changes the devices it counts and the isolation behind them.
</span></span></code></pre></div><p>Kubernetes counts GPUs the way it counts chairs: whole ones only. A Pod asks for <code>nvidia.com/gpu: 1</code> and normally gets exclusive access to one GPU device, even if it only needs a corner of it. With MIG, that device can be a hardware partition.</p>
<p>That is fine for a training job that fills an H100. It is wasteful for an embedding model that uses 4 GB of an 80 GB card.</p>
<p>GPU sharing fixes that, and NVIDIA gives you three ways to do it. They sound similar, but they share very different things:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">Time-slicing = Pods take turns on the GPU. Nothing is isolated.
</span></span><span class="line"><span class="cl">MPS          = Pods run side by side. Memory and compute are capped in software.
</span></span><span class="line"><span class="cl">MIG          = The GPU is cut into smaller GPUs. Isolation is done in hardware.
</span></span></code></pre></div><figure class="mermaid-figure">
  <div class="mermaid">flowchart TD
    subgraph WHOLE["Whole GPUs"]
        direction LR
        P1["Embeddings<br/>needs 4 GB"] a1@--> G1["H100 A<br/>76 GB idle"]
        P2["Reranker<br/>needs 6 GB"] a2@--> G2["H100 B<br/>74 GB idle"]
        P3["Notebook<br/>needs 10 GB"] a3@--> G3["H100 C<br/>70 GB idle"]
    end

    subgraph SHARED["One shared GPU"]
        direction LR
        Q1["Embeddings<br/>4 GB"] b1@--> S1["H100 A<br/>20 GB used<br/>60 GB free"]
        Q2["Reranker<br/>6 GB"] b2@--> S1
        Q3["Notebook<br/>10 GB"] b3@--> S1
    end

    WHOLE ~~~ SHARED
    a1@{ animate: true }
    a2@{ animate: true }
    a3@{ animate: true }
    b1@{ animate: true }
    b2@{ animate: true }
    b3@{ animate: true }

    classDef input fill:#13264a,stroke:#38bdf8,color:#e6f6ff,stroke-width:2px;
    classDef gpu fill:#173f59,stroke:#22d3ee,color:#ecfeff,stroke-width:2px;
    classDef waste fill:#302410,stroke:#fbbf24,color:#fff3cf,stroke-width:2px;
    class P1,P2,P3,Q1,Q2,Q3 input;
    class G1,G2,G3 waste;
    class S1 gpu;</div>
  <figcaption>Top: three small workloads each hold a whole H100 and leave most of it idle. Bottom: the same three workloads share one card.</figcaption>
</figure>

<p>This post walks through all three with one running example: <strong>one H100 (80 GB) and three small workloads</strong> that would each waste a full card.</p>
<p>If the GPU software stack itself is new to you (driver, device plugin, GPU Operator), start with my <a href="https://vishctl.dev/posts/kubernetes-gpu-platform-engineering/">Kubernetes GPU platform guide</a> and come back.</p>
<h2 id="why-kubernetes-cannot-share-a-gpu-by-default">Why Kubernetes cannot share a GPU by default</h2>
<p>The NVIDIA device plugin tells the kubelet how many GPUs a node has. Kubernetes stores that as an <strong>extended resource</strong>, and extended resources have two strict rules:</p>
<ul>
<li>They are whole numbers. You cannot request <code>nvidia.com/gpu: 0.25</code>.</li>
<li>They cannot be overcommitted. One GPU is handed to exactly one container.</li>
</ul>
<p>So the scheduler is not being stubborn. It simply has no idea that a GPU has memory, compute, or anything else inside it. It sees a count.</p>
<p>Every sharing method below is a different answer to the same question: <strong>how do we make one physical GPU show up as more than one thing to count?</strong></p>
<h2 id="the-three-ways-at-a-glance">The three ways at a glance</h2>
<div class="table-scroll">
  <table>
    <thead>
        <tr>
            <th scope="col"></th>
            <th scope="col">Time-slicing</th>
            <th scope="col">MPS</th>
            <th scope="col">MIG</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>How it shares</td>
            <td>Takes turns</td>
            <td>Runs side by side</td>
            <td>Splits the hardware</td>
        </tr>
        <tr>
            <td>Memory isolation</td>
            <td>None</td>
            <td>Software limit per client</td>
            <td>Hardware, per instance</td>
        </tr>
        <tr>
            <td>Fault isolation</td>
            <td>None</td>
            <td>Weak</td>
            <td>Strong</td>
        </tr>
        <tr>
            <td>Predictable speed</td>
            <td>No guarantee</td>
            <td>Compute caps, no latency guarantee</td>
            <td>Better isolation, benchmark your workload</td>
        </tr>
        <tr>
            <td>Shares per GPU</td>
            <td>Configurable replicas</td>
            <td>Replicas within MPS client limits</td>
            <td>Up to 7 on the H100 used here</td>
        </tr>
        <tr>
            <td>Hardware support</td>
            <td>Broad CUDA GPU support</td>
            <td>Supported CUDA GPUs and software stack</td>
            <td>MIG-capable cards only</td>
        </tr>
    </tbody>
  </table>
</div>
<p>Keep this table in mind. The rest of the post is just explaining each row.</p>
<h2 id="1-time-slicing-take-turns">1. Time-slicing: take turns</h2>
<p>Time-slicing is the simplest option. You tell the device plugin to <strong>advertise each GPU several times</strong>.</p>
<p>With <code>replicas: 4</code>, a node with one H100 reports <code>nvidia.com/gpu: 4</code>. Four Pods can each request one &ldquo;GPU&rdquo; and all land on the same card.</p>
<p>Here is the important part: <strong>nothing changes on the GPU itself.</strong> The card was always able to switch between processes. Time-slicing only changes the number Kubernetes is allowed to count. The turns are between CUDA processes, not fixed per-Pod time slots; a Pod can launch several processes.</p>
<figure class="mermaid-figure">
  <div class="mermaid">flowchart TD
    subgraph COUNT["What Kubernetes sees"]
        direction LR
        H["1 physical<br/>H100"] c1@--> DP["Device plugin<br/>replicas 4"]
        DP c2@--> R["Node reports<br/>4 GPUs"]
    end

    subgraph TURNS["What the GPU does"]
        direction LR
        T1["Turn 1<br/>Pod A runs"] t1@--> T2["Turn 2<br/>Pod B runs"]
        T2 t2@--> T3["Turn 3<br/>Pod C runs"]
        T3 t3@--> T4["Turn 4<br/>Pod A again"]
    end

    COUNT ~~~ TURNS
    c1@{ animate: true }
    c2@{ animate: true }
    t1@{ animate: true }
    t2@{ animate: true }
    t3@{ animate: true }

    classDef input fill:#13264a,stroke:#38bdf8,color:#e6f6ff,stroke-width:2px;
    classDef gpu fill:#173f59,stroke:#22d3ee,color:#ecfeff,stroke-width:2px;
    classDef router fill:#281d48,stroke:#a78bfa,color:#f1edff,stroke-width:2px;
    classDef idle fill:#101e27,stroke:#324950,color:#8aa0a8;
    class H input;
    class DP router;
    class R gpu;
    class T1,T4 gpu;
    class T2,T3 idle;</div>
  <figcaption>Top: the device plugin turns one physical GPU into four countable replicas. Bottom: on the card, the Pods simply take turns.</figcaption>
</figure>

<h3 id="a-four-step-walkthrough">A four-step walkthrough</h3>
<p>Three Pods share one time-sliced H100. Watch what happens to memory:</p>
<div class="table-scroll">
  <table>
    <thead>
        <tr>
            <th scope="col">Step</th>
            <th scope="col">What happens</th>
            <th scope="col">GPU memory in use</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>Embeddings Pod loads its model</td>
            <td>4 GB</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Reranker Pod loads its model</td>
            <td>10 GB</td>
        </tr>
        <tr>
            <td>3</td>
            <td>Notebook user loads a 68 GB model by mistake</td>
            <td>78 GB</td>
        </tr>
        <tr>
            <td>4</td>
            <td>Embeddings Pod needs 3 GB more for a big batch</td>
            <td>Out of memory</td>
        </tr>
    </tbody>
  </table>
</div>
<p>Step 4 is the catch. The embeddings Pod did nothing wrong, yet it is the one that crashes.</p>
<p>That is what <strong>no memory isolation</strong> means. Every Pod sees all 80 GB, and whoever allocates first wins.</p>
<h3 id="what-time-slicing-does-not-give-you">What time-slicing does not give you</h3>
<ul>
<li><strong>No memory limit.</strong> Any Pod can fill the card.</li>
<li><strong>No fault isolation.</strong> NVIDIA&rsquo;s docs say plainly that there is no memory or fault isolation between replicas.</li>
<li><strong>No guaranteed share.</strong> Asking for 2 replicas does not buy twice the compute. It only takes two slots away from other Pods.</li>
<li><strong>Weaker per-Pod metrics.</strong> DCGM Exporter cannot tie GPU metrics to a container when time-slicing is on.</li>
</ul>
<h3 id="turn-it-on">Turn it on</h3>
<p>With the <a href="https://docs.nvidia.com/datacenter/cloud-native/gpu-operator/latest/gpu-sharing.html">GPU Operator</a>, time-slicing is one ConfigMap plus one patch.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="c"># time-slicing-config.yaml</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">ConfigMap</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">time-slicing-config</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">namespace</span><span class="p">:</span><span class="w"> </span><span class="l">gpu-operator</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">data</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">any</span><span class="p">:</span><span class="w"> </span><span class="p">|-</span><span class="sd">
</span></span></span><span class="line"><span class="cl"><span class="sd">    version: v1
</span></span></span><span class="line"><span class="cl"><span class="sd">    flags:
</span></span></span><span class="line"><span class="cl"><span class="sd">      migStrategy: none
</span></span></span><span class="line"><span class="cl"><span class="sd">    sharing:
</span></span></span><span class="line"><span class="cl"><span class="sd">      timeSlicing:
</span></span></span><span class="line"><span class="cl"><span class="sd">        renameByDefault: false
</span></span></span><span class="line"><span class="cl"><span class="sd">        failRequestsGreaterThanOne: true
</span></span></span><span class="line"><span class="cl"><span class="sd">        resources:
</span></span></span><span class="line"><span class="cl"><span class="sd">          - name: nvidia.com/gpu
</span></span></span><span class="line"><span class="cl"><span class="sd">            replicas: 4</span><span class="w">
</span></span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl apply -f time-slicing-config.yaml
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl patch clusterpolicies.nvidia.com/cluster-policy <span class="se">\
</span></span></span><span class="line"><span class="cl">  -n gpu-operator --type merge <span class="se">\
</span></span></span><span class="line"><span class="cl">  -p <span class="s1">&#39;{&#34;spec&#34;: {&#34;devicePlugin&#34;: {&#34;config&#34;: {&#34;name&#34;: &#34;time-slicing-config&#34;, &#34;default&#34;: &#34;any&#34;}}}}&#39;</span>
</span></span></code></pre></div><p>Two flags are worth understanding:</p>
<ul>
<li><code>failRequestsGreaterThanOne: true</code> causes allocation to fail for a container that asks for more than one replica. It is a device-plugin allocation check, not an admission policy. That stops people from believing <code>nvidia.com/gpu: 2</code> means &ldquo;twice the GPU&rdquo;.</li>
<li><code>renameByDefault: true</code> advertises the resource as <code>nvidia.com/gpu.shared</code> instead. Use it when you want Pods to say out loud that they accept a shared card.</li>
</ul>
<p>Then check that the node now reports four GPUs:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl get node &lt;node-name&gt; <span class="se">\
</span></span></span><span class="line"><span class="cl">  -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">&#39;{.status.allocatable.nvidia\.com/gpu}{&#34;\n&#34;}&#39;</span>
</span></span></code></pre></div><p>The node also gains a <code>nvidia.com/gpu.replicas=4</code> label, and the product label gets a <code>-SHARED</code> suffix. That suffix is handy for node selectors.</p>
<p>To see sharing in action, use a test cluster with exactly one eligible GPU node and one physical GPU. Run four Pods that each ask for one GPU; on a larger cluster the scheduler can spread them across different cards:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="c"># shared-gpu-test.yaml</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">apps/v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Deployment</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">shared-gpu-test</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">replicas</span><span class="p">:</span><span class="w"> </span><span class="m">4</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">selector</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">matchLabels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">shared-gpu-test</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">template</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">shared-gpu-test</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">containers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">cuda</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">nvcr.io/nvidia/cuda:12.4.1-base-ubuntu22.04</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">command</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">&#34;bash&#34;</span><span class="p">,</span><span class="w"> </span><span class="s2">&#34;-c&#34;</span><span class="p">,</span><span class="w"> </span><span class="s2">&#34;nvidia-smi -L; sleep infinity&#34;</span><span class="p">]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">resources</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">            </span><span class="nt">limits</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">              </span><span class="nt">nvidia.com/gpu</span><span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
</span></span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl apply -f shared-gpu-test.yaml
</span></span><span class="line"><span class="cl">kubectl rollout status deployment/shared-gpu-test --timeout<span class="o">=</span>180s
</span></span><span class="line"><span class="cl">kubectl logs -l <span class="nv">app</span><span class="o">=</span>shared-gpu-test --prefix <span class="p">|</span> sort
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Clean up after checking the UUIDs</span>
</span></span><span class="line"><span class="cl">kubectl delete deployment shared-gpu-test
</span></span></code></pre></div><p>All four Pods should print the <strong>same GPU UUID</strong>. That is the proof that they share one physical card.</p>
<p>One gotcha: the Operator does not watch the ConfigMap for edits. After changing <code>replicas</code>, restart the device plugin:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl rollout restart -n gpu-operator daemonset/nvidia-device-plugin-daemonset
</span></span></code></pre></div><h2 id="2-mps-run-side-by-side">2. MPS: run side by side</h2>
<p><strong>MPS (Multi-Process Service)</strong> is NVIDIA&rsquo;s answer to the two biggest time-slicing problems: wasted turns and missing memory limits.</p>
<p>With time-slicing, only one Pod&rsquo;s work runs at any instant. If Pod A uses 20% of the GPU during its turn, the other 80% sits idle until the turn ends.</p>
<p><a href="https://docs.nvidia.com/deploy/mps/latest/architecture.html">MPS uses a control daemon and server</a> to coordinate access to GPU scheduling resources. On modern GPUs such as the H100, clients submit work directly to the GPU using separate address spaces. Their kernels <strong>can run concurrently</strong> when resources are available, so small workloads can overlap.</p>
<figure class="mermaid-figure">
  <div class="mermaid">flowchart TD
    A["Embeddings Pod<br/>cap 20 GB"] m1@--> S["MPS service<br/>coordinates<br/>GPU access"]
    B["Reranker Pod<br/>cap 20 GB"] m2@--> S
    C["Notebook Pod<br/>cap 20 GB"] m3@--> S
    S m4@--> G["H100<br/>can overlap<br/>client kernels"]

    m1@{ animate: true }
    m2@{ animate: true }
    m3@{ animate: true }
    m4@{ animate: true }

    classDef input fill:#13264a,stroke:#38bdf8,color:#e6f6ff,stroke-width:2px;
    classDef router fill:#281d48,stroke:#a78bfa,color:#f1edff,stroke-width:2px;
    classDef gpu fill:#173f59,stroke:#22d3ee,color:#ecfeff,stroke-width:2px;
    class A,B,C input;
    class S router;
    class G gpu;</div>
  <figcaption>MPS coordinates shared GPU access. Client kernels can overlap, and the device plugin configures a memory cap per client.</figcaption>
</figure>

<h3 id="what-changes-compared-to-time-slicing">What changes compared to time-slicing</h3>
<p>The device plugin divides the card evenly. With <code>replicas: 4</code> on an 80 GB H100, each MPS client gets <strong>about 20 GB of allocatable memory and a 25% active-thread limit</strong>. These are software caps, not a reserved quarter of throughput.</p>
<p>The examples assume one CUDA client process per Pod; a Pod resource request is not a general aggregate memory limit across arbitrary child processes.</p>
<p>Replay the walkthrough from earlier. At step 3, the notebook user tries to load a 68 GB model. This time <strong>their own Pod fails</strong> at 20 GB, while the embeddings client keeps its own allocation budget. Shared GPU faults can still affect both.</p>
<p>That is a real improvement. The mistake now hurts the person who made it.</p>
<h3 id="what-mps-still-does-not-give-you">What MPS still does not give you</h3>
<ul>
<li><strong>Weak fault isolation.</strong> All Pods share one MPS server. A fatal GPU error from one client can take the others down with it.</li>
<li><strong>Equal shares only.</strong> You cannot give one Pod 40 GB and another 10 GB. Every replica is the same size.</li>
<li><strong>No MIG combination.</strong> The device plugin does not support MPS on a GPU that has MIG enabled.</li>
<li><strong>Experimental status.</strong> The <a href="https://github.com/NVIDIA/k8s-device-plugin#with-cuda-mps">device plugin README</a> still describes MPS support as experimental (as of v0.15.0), so test it on your own versions before trusting it in production.</li>
</ul>
<h3 id="turn-it-on-1">Turn it on</h3>
<p>The config has the same shape as time-slicing, but <strong>the MPS control daemon must also be deployed and healthy</strong>. A ConfigMap alone does not start that service. Check your Operator version and deployment manifests, or use the <a href="https://github.com/NVIDIA/k8s-device-plugin/tree/main/deployments/helm/nvidia-device-plugin">standalone device-plugin Helm chart</a>, which includes an MPS control daemon. Use only one device-plugin deployment per node.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="c"># mps-config.yaml</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">ConfigMap</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">mps-config</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">namespace</span><span class="p">:</span><span class="w"> </span><span class="l">gpu-operator</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">data</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">any</span><span class="p">:</span><span class="w"> </span><span class="p">|-</span><span class="sd">
</span></span></span><span class="line"><span class="cl"><span class="sd">    version: v1
</span></span></span><span class="line"><span class="cl"><span class="sd">    sharing:
</span></span></span><span class="line"><span class="cl"><span class="sd">      mps:
</span></span></span><span class="line"><span class="cl"><span class="sd">        renameByDefault: false
</span></span></span><span class="line"><span class="cl"><span class="sd">        resources:
</span></span></span><span class="line"><span class="cl"><span class="sd">          - name: nvidia.com/gpu
</span></span></span><span class="line"><span class="cl"><span class="sd">            replicas: 4</span><span class="w">
</span></span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl apply -f mps-config.yaml
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Confirm an MPS control daemon is deployed before selecting this config</span>
</span></span><span class="line"><span class="cl">kubectl get daemonsets -A <span class="p">|</span> grep mps
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl patch clusterpolicies.nvidia.com/cluster-policy <span class="se">\
</span></span></span><span class="line"><span class="cl">  -n gpu-operator --type merge <span class="se">\
</span></span></span><span class="line"><span class="cl">  -p <span class="s1">&#39;{&#34;spec&#34;: {&#34;devicePlugin&#34;: {&#34;config&#34;: {&#34;name&#34;: &#34;mps-config&#34;, &#34;default&#34;: &#34;any&#34;}}}}&#39;</span>
</span></span></code></pre></div><p>The Operator patch above selects the plugin configuration; it does not install a missing MPS daemon. Confirm the daemon is Ready and check its logs before starting CUDA clients.</p>
<p>Time-slicing and MPS are mutually exclusive on a node: the plugin applies one sharing method to every GPU on it. To confirm which one a node uses, read its label:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl get node &lt;node-name&gt; <span class="se">\
</span></span></span><span class="line"><span class="cl">  -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">&#39;{.metadata.labels.nvidia\.com/gpu\.sharing-strategy}{&#34;\n&#34;}&#39;</span>
</span></span></code></pre></div><p>It prints <code>mps</code>, <code>time-slicing</code>, or <code>none</code>.</p>
<h2 id="3-mig-cut-the-gpu-into-smaller-gpus">3. MIG: cut the GPU into smaller GPUs</h2>
<p><strong>MIG (Multi-Instance GPU)</strong> is the only option that changes the hardware layout.</p>
<p>The 80 GB H100 in this example can be split into <strong>up to 7 MIG instances</strong>. Each instance gets its own slice of memory and its own slice of compute. To the software inside a Pod, an instance looks like a small, separate GPU.</p>
<figure class="mermaid-figure">
  <div class="mermaid">flowchart TD
    G["H100<br/>80 GB"] s1@--> I1["3g.40gb<br/>40 GB slice"]
    G s2@--> I2["2g.20gb<br/>20 GB slice"]
    G s3@--> I3["1g.10gb<br/>10 GB slice"]
    G s4@--> I4["1g.10gb<br/>10 GB slice"]
    I1 p1@--> W1["Small LLM<br/>with vLLM"]
    I2 p2@--> W2["Notebook"]
    I3 p3@--> W3["Embeddings"]
    I4 p4@--> W4["Reranker"]

    s1@{ animate: true }
    s2@{ animate: true }
    s3@{ animate: true }
    s4@{ animate: true }
    p1@{ animate: true }
    p2@{ animate: true }
    p3@{ animate: true }
    p4@{ animate: true }

    classDef gpu fill:#173f59,stroke:#22d3ee,color:#ecfeff,stroke-width:2px;
    classDef slice fill:#281d48,stroke:#a78bfa,color:#f1edff,stroke-width:2px;
    classDef input fill:#13264a,stroke:#38bdf8,color:#e6f6ff,stroke-width:2px;
    class G gpu;
    class I1,I2,I3,I4 slice;
    class W1,W2,W3,W4 input;</div>
  <figcaption>One 80 GB H100 cut into four MIG instances. Each instance has its own memory and compute, with hardware isolation between instances.</figcaption>
</figure>

<h3 id="reading-a-mig-profile-name">Reading a MIG profile name</h3>
<p>Profile names look cryptic, but they follow one pattern:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">3g.40gb  =  3 compute slices (out of 7)  +  40 GB of memory
</span></span></code></pre></div><p>On an 80 GB H100, the common profiles are:</p>
<div class="table-scroll">
  <table>
    <thead>
        <tr>
            <th scope="col">Profile</th>
            <th scope="col">Compute slices</th>
            <th scope="col">Memory</th>
            <th scope="col">How many fit on one card</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>1g.10gb</code></td>
            <td>1 of 7</td>
            <td>10 GB</td>
            <td>7</td>
        </tr>
        <tr>
            <td><code>2g.20gb</code></td>
            <td>2 of 7</td>
            <td>20 GB</td>
            <td>3</td>
        </tr>
        <tr>
            <td><code>3g.40gb</code></td>
            <td>3 of 7</td>
            <td>40 GB</td>
            <td>2</td>
        </tr>
        <tr>
            <td><code>7g.80gb</code></td>
            <td>7 of 7</td>
            <td>80 GB</td>
            <td>1</td>
        </tr>
    </tbody>
  </table>
</div>
<p>You can also mix sizes on one card, as in <a href="https://docs.nvidia.com/datacenter/cloud-native/gpu-operator/latest/gpu-operator-mig.html#example-mixed-mig-strategy">NVIDIA&rsquo;s mixed-strategy example</a> and the diagram above. That exact mix (two <code>1g.10gb</code>, one <code>2g.20gb</code>, one <code>3g.40gb</code>) is what the GPU Operator calls <code>all-balanced</code>.</p>
<h3 id="what-mig-costs-you">What MIG costs you</h3>
<ul>
<li><strong>Only some cards support it.</strong> MIG needs data-center GPUs from the Ampere generation onward, such as the A100, A30, H100, and H200. Cards like the T4, L4, and L40S do not have it. Check <code>nvidia-smi</code> or your card&rsquo;s documentation before planning around it.</li>
<li><strong>Fixed sizes.</strong> You pick from a menu of profiles. You cannot create a 13 GB instance.</li>
<li><strong>Hardware-specific instance limits.</strong> This H100 supports up to 7. Other models can differ, and MPS also has client and compatibility limits.</li>
<li><strong>Changing the layout is disruptive.</strong> The MIG Manager needs the GPU to be free of user workloads before it reshapes it, and some environments need a node reboot.</li>
</ul>
<h3 id="turn-it-on-2">Turn it on</h3>
<p>The following commands assume MIG-capable hardware and no software-sharing configuration. If you ran either earlier example, delete the test workloads and clear the shared plugin config before switching:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl patch clusterpolicies.nvidia.com/cluster-policy --type merge <span class="se">\
</span></span></span><span class="line"><span class="cl">  -p <span class="s1">&#39;{&#34;spec&#34;:{&#34;devicePlugin&#34;:{&#34;config&#34;:{&#34;name&#34;:&#34;&#34;,&#34;default&#34;:&#34;&#34;}}}}&#39;</span>
</span></span></code></pre></div><p>Install the GPU Operator with a MIG strategy. For an existing release, preserve its values with <code>helm upgrade gpu-operator nvidia/gpu-operator --reuse-values</code> and add <code>--set mig.strategy=single</code>; use your installed chart version to avoid an unintended upgrade:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">helm repo add nvidia https://helm.ngc.nvidia.com/nvidia
</span></span><span class="line"><span class="cl">helm repo update
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">helm install gpu-operator nvidia/gpu-operator <span class="se">\
</span></span></span><span class="line"><span class="cl">  -n gpu-operator --create-namespace <span class="se">\
</span></span></span><span class="line"><span class="cl">  --set mig.strategy<span class="o">=</span>single
</span></span></code></pre></div><p>The strategy decides how instances are named:</p>
<div class="table-scroll">
  <table>
    <thead>
        <tr>
            <th scope="col">Strategy</th>
            <th scope="col">Use when</th>
            <th scope="col">Pods request</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>single</code></td>
            <td>Every GPU on the node has the same profile</td>
            <td><code>nvidia.com/gpu: 1</code></td>
        </tr>
        <tr>
            <td><code>mixed</code></td>
            <td>Multiple profiles on one GPU or across the node</td>
            <td><code>nvidia.com/mig-1g.10gb: 1</code></td>
        </tr>
    </tbody>
  </table>
</div>
<p>Then label the node with the layout you want. Cordon it first and stop or migrate its GPU workloads during a maintenance window. Cordon only blocks new scheduling; it does not evict running Pods. MIG Manager stops GPU Pods while applying the new geometry:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl cordon &lt;node-name&gt;
</span></span><span class="line"><span class="cl">kubectl label nodes &lt;node-name&gt; nvidia.com/mig.config<span class="o">=</span>all-1g.10gb --overwrite
</span></span></code></pre></div><p>Wait for the MIG Manager to finish. The state label goes from <code>pending</code> to <code>success</code>:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl get node &lt;node-name&gt; <span class="se">\
</span></span></span><span class="line"><span class="cl">  -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">&#39;{.metadata.labels.nvidia\.com/mig\.config\.state}{&#34;\n&#34;}&#39;</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">kubectl <span class="nb">wait</span> node/&lt;node-name&gt; <span class="se">\
</span></span></span><span class="line"><span class="cl">  --for<span class="o">=</span><span class="nv">jsonpath</span><span class="o">=</span><span class="s1">&#39;{.metadata.labels.nvidia\.com/mig\.config\.state}&#39;</span><span class="o">=</span>success <span class="se">\
</span></span></span><span class="line"><span class="cl">  --timeout<span class="o">=</span>600s
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Uncordon only after the wait succeeds</span>
</span></span><span class="line"><span class="cl">kubectl uncordon &lt;node-name&gt;
</span></span></code></pre></div><p>With <code>all-1g.10gb</code> and the <code>single</code> strategy, one H100 now reports <code>nvidia.com/gpu: 7</code>. Each of those seven is a hardware-isolated 10 GB instance.</p>
<h2 id="what-this-means-for-llm-inference">What this means for LLM inference</h2>
<p>Sharing rules that work for notebooks can surprise you with an inference server. Three things matter most.</p>
<h3 id="give-vllm-an-explicit-memory-budget">Give vLLM an explicit memory budget</h3>
<p><a href="https://vishctl.dev/posts/why-vllm-is-dominating-ai-inference-market/">vLLM</a> budgets GPU memory for model execution, including weights, runtime overhead, and KV cache. Set <code>--gpu-memory-utilization</code> explicitly when sharing; defaults and allocation behavior vary by version. The <a href="https://docs.vllm.ai/en/latest/configuration/engine_args/#cacheconfig">engine argument reference</a> documents this per-instance setting.</p>
<p>For a concrete example, use <code>--gpu-memory-utilization 0.9</code> and compare the sharing modes:</p>
<div class="table-scroll">
  <table>
    <thead>
        <tr>
            <th scope="col">Mode</th>
            <th scope="col">Memory boundary</th>
            <th scope="col">Result with an explicit 0.9 budget</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Time-slicing</td>
            <td>All 80 GB</td>
            <td>A 72 GB executor budget leaves too little for another equal server</td>
        </tr>
        <tr>
            <td>MPS, 4 replicas</td>
            <td>About 20 GB per client, not a separate GPU</td>
            <td>Do not assume vLLM detects the cap; configure and test its budget</td>
        </tr>
        <tr>
            <td>MIG <code>3g.40gb</code></td>
            <td>A 40 GB GPU</td>
            <td>About 36 GB for execution, if weights, overhead, and cache fit</td>
        </tr>
    </tbody>
  </table>
</div>
<p>On a time-sliced GPU you must lower the fraction yourself, for example two Pods at <code>--gpu-memory-utilization 0.45</code> each. Nothing enforces it, so one wrong flag still breaks the neighbor.</p>
<h3 id="latency-follows-isolation">Latency follows isolation</h3>
<p>Time-slicing adds waiting: your request&rsquo;s tokens are generated only during your Pod&rsquo;s turns. With four busy Pods, time to first token and tokens per second both get worse, and they get worse unevenly.</p>
<p>MIG dedicates compute and memory resources to each instance, which reduces GPU interference from neighbors. It does not guarantee end-to-end latency: CPU, networking, traffic bursts, and card-wide failures still matter. Benchmark the chosen profile against your latency target.</p>
<h3 id="smaller-gpu-means-smaller-kv-cache">Smaller GPU means smaller KV cache</h3>
<p>Whatever memory is left after loading weights becomes KV cache. A 10 GB slice holding an 8 GB model has very little room for long prompts or many concurrent users.</p>
<p>If a model serves real traffic, size the slice for <strong>weights plus cache</strong>, not for weights alone. Include runtime overhead and leave headroom for allocation spikes. Routers such as <a href="https://vishctl.dev/posts/llm-d-kubernetes-inference-routing/">llm-d</a> and caches such as <a href="https://vishctl.dev/posts/why-lmcache-is-needed/">LMCache</a> help more when each replica has cache to spare.</p>
<h2 id="which-one-should-you-pick">Which one should you pick?</h2>
<figure class="mermaid-figure">
  <div class="mermaid">flowchart TD
    Q1["Who shares<br/>the GPU?"] e1@-->|"Other teams or<br/>strict latency"| Q2["Does the card<br/>support MIG?"]
    Q1 e2@-->|"One team<br/>dev or batch"| Q3["Do Pods need<br/>memory caps?"]
    Q2 e3@-->|"Yes"| M["Pick MIG<br/>hardware isolation"]
    Q2 e4@-->|"No"| W["Give whole GPUs<br/>or accept MPS limits"]
    Q3 e5@-->|"Yes"| P["Pick MPS<br/>equal capped shares"]
    Q3 e6@-->|"No"| T["Pick time-slicing<br/>simplest setup"]

    e1@{ animate: true }
    e2@{ animate: true }
    e3@{ animate: true }
    e4@{ animate: true }
    e5@{ animate: true }
    e6@{ animate: true }

    classDef question fill:#281d48,stroke:#a78bfa,color:#f1edff,stroke-width:2px;
    classDef pick fill:#173f59,stroke:#22d3ee,color:#ecfeff,stroke-width:3px;
    classDef warn fill:#302410,stroke:#fbbf24,color:#fff3cf,stroke-width:2px;
    class Q1,Q2,Q3 question;
    class M,P,T pick;
    class W warn;</div>
  <figcaption>A short decision path. Start with who shares the GPU (other teams and latency-sensitive production on one side, one trusted team on the other), then check what your hardware supports.</figcaption>
</figure>

<h3 id="pick-time-slicing-when">Pick time-slicing when:</h3>
<ul>
<li><strong>Everyone sharing the GPU is on one team</strong> and a crash is an annoyance, not an incident.</li>
<li><strong>Workloads are bursty and mostly idle</strong>, like notebooks, CI jobs, and demos.</li>
<li><strong>Your GPUs do not support MIG</strong> and you want the least moving parts.</li>
</ul>
<h3 id="pick-mps-when">Pick MPS when:</h3>
<ul>
<li><strong>Many small processes each use a fraction of the GPU</strong> and you want them to overlap instead of queue.</li>
<li><strong>You need a memory cap per Pod</strong> but your cards cannot do MIG.</li>
<li><strong>Equal shares are acceptable</strong> and you have tested MPS on your driver and plugin versions.</li>
</ul>
<h3 id="pick-mig-when">Pick MIG when:</h3>
<ul>
<li><strong>Different teams or tenants share a card</strong> and you need stronger GPU memory and compute isolation.</li>
<li><strong>A workload has a latency or throughput target</strong> that noisy neighbors would break.</li>
<li><strong>Your sizes are stable.</strong> If the layout needs to change every hour, the drain-and-reconfigure cycle will hurt.</li>
</ul>
<p>You can also layer them. Time-slicing works on top of MIG instances, so a <code>3g.40gb</code> slice can itself be shared by a few trusted dev Pods while the other slices stay strictly isolated.</p>
<h2 id="where-this-is-heading-dra">Where this is heading: DRA</h2>
<p>All three methods above are workarounds for the &ldquo;GPUs are whole numbers&rdquo; rule.</p>
<p><strong>Dynamic Resource Allocation (DRA)</strong> offers a richer way to request devices. A Pod references a ResourceClaim, and a DRA driver supplies device information and prepares the allocated device. The <a href="https://kubernetes.io/docs/concepts/resource-management/dynamic-resource-allocation/">core DRA API became stable in Kubernetes v1.34</a>; NVIDIA maintains a GPU driver for it.</p>
<p>DRA does not automatically create fractional GPUs or make every sharing mode available. Sharing support depends on the driver, Kubernetes features, and deployed versions.</p>
<p>The ideas in this post do not go away under DRA. Time-slicing, MPS, and MIG are still the mechanisms on the card. DRA changes how you ask for them, not what they isolate.</p>
<h2 id="cheat-sheet">Cheat sheet</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">Extended resource     = a whole-number device count; cannot be split or overcommitted
</span></span><span class="line"><span class="cl">Time-slicing          = advertise one GPU as N replicas; Pods take turns, nothing is isolated
</span></span><span class="line"><span class="cl">replicas              = advertised shared allocations per GPU (or per configured MIG instance)
</span></span><span class="line"><span class="cl">renameByDefault       = expose shared GPUs as nvidia.com/gpu.shared instead of nvidia.com/gpu
</span></span><span class="line"><span class="cl">MPS                   = coordinated concurrent CUDA clients with software memory and compute caps
</span></span><span class="line"><span class="cl">MIG                   = hardware GPU partitions; this H100 supports up to 7 instances
</span></span><span class="line"><span class="cl">MIG profile 3g.40gb   = 3 of 7 compute slices plus 40 GB of memory
</span></span><span class="line"><span class="cl">mig.strategy single   = all GPUs on the node share one profile; Pods still ask for nvidia.com/gpu
</span></span><span class="line"><span class="cl">mig.strategy mixed    = multiple profiles on a node; Pods ask for nvidia.com/mig-&lt;profile&gt;
</span></span><span class="line"><span class="cl">Fault isolation       = containment of GPU faults; MIG is stronger, but card failures still matter
</span></span><span class="line"><span class="cl">DRA                   = claim-based device allocation; sharing still needs driver support
</span></span><span class="line"><span class="cl">Rule of thumb         = trust decides: same team can time-slice, strangers need MIG
</span></span></code></pre></div><p>No GPU to try this on? The <a href="https://vishctl.dev/posts/simulate-gpu-vllm-llm-d-on-laptop/">laptop GPU simulation lab</a> fakes 16 H100s on kind, which is enough to practice requests, limits, and scheduling. For the layers underneath sharing (driver, device plugin, NUMA, RDMA), see the <a href="https://vishctl.dev/posts/kubernetes-gpu-platform-engineering/">Kubernetes GPU platform guide</a>.</p>
]]></content:encoded></item></channel></rss>