<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bhavesh Maheshwari on Medium]]></title>
        <description><![CDATA[Stories by Bhavesh Maheshwari on Medium]]></description>
        <link>https://medium.com/@bhaveshmaheshwari29?source=rss-108370ad0d3e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1FHCWGaaPJ1YEeW-</url>
            <title>Stories by Bhavesh Maheshwari on Medium</title>
            <link>https://medium.com/@bhaveshmaheshwari29?source=rss-108370ad0d3e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:52:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhaveshmaheshwari29/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Our LLM Inference Journey in Production: From Hobby to Enterprise]]></title>
            <link>https://engg.glance.com/from-hobby-to-enterprise-our-llm-inference-journey-in-production-cf88a74451c5?source=rss-108370ad0d3e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf88a74451c5</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[vllm]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[google-gemini]]></category>
            <category><![CDATA[gemma-4]]></category>
            <dc:creator><![CDATA[Bhavesh Maheshwari]]></dc:creator>
            <pubDate>Tue, 05 May 2026 11:52:14 GMT</pubDate>
            <atom:updated>2026-05-05T12:59:46.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RscB3guxHHr-icVoXzCklg.png" /></figure><p><em>We ignored the labels, ran hobby-grade LLM setups in production, and learned exactly why those labels exist.</em></p><h3>Episode 1: The Pipeline</h3><p>At Glance, we run a near real-time content processing pipeline for our lockscreen platform serving ~200M users. Millions of content items flow through daily — each one processed by LLMs before it’s served to users.</p><p>This pipeline handles three tasks for every content:</p><ul><li><strong>Categorization</strong> — Given a piece of content, classify it into the best-suited option from a predefined list (category, sub-category, teams, leagues, etc.)</li><li><strong>Classification</strong> — Based on defined rulesets, assign content to one of several buckets</li><li><strong>Summarization</strong> — Generate headlines and summaries in multiple structured formats</li></ul><p>Each item must be processed within a 2–3 second latency budget. A failed request means a dropped item. A dropped item means a gap in the pipeline. This workload demands predictable latency and near-zero error rate — not peak performance, not lowest cost.</p><p>With that context, here’s the story of how we tried to get away with hobby-grade setups in a production system — and what it taught us.</p><h3>Episode 2: Shared API, Production Traffic</h3><p>We started the way most teams do — with the simplest option. <strong>Gemini 2.5 Flash via Vertex API</strong>. Pay-per-token. No commitments. Spin up and go.</p><p>At low traffic of 20–30 calls/minute, it was excellent. Quality was great, cost was minimal, integration was quick. So we kept scaling. Pay-as-you-go API access is designed for prototyping, low-traffic use cases, and workloads that can tolerate occasional throttling.</p><p>Google is upfront about this — there’s no SLA on throughput, no guaranteed capacity. <strong>It’s a shared resource </strong>with rate limits.</p><p>We understood the tradeoffs. But the quality was good, the cost was right, and we wanted to see how far we could push it before hitting the wall.</p><p><strong><em>We found the wall sooner than expected.</em></strong></p><p>Once our traffic sustained at 3–5 RPS, <strong>429 RESOURCE_EXHAUSTED</strong> errors became a regular occurrence. Our baseline error rate hovered at 5–7%, which was already painful. But at peak, it spiked to <strong>~68%</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*2LY36y2vW02njEfHSrKD_g.png" /><figcaption>Gemini API error rate — 429 errors spiked from near-zero to ~70%, sustained over two days</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-wFY9fnfJV_oUDTZcnF5A.png" /><figcaption><em>Google Cloud Metrics Explorer during the peak of the 429 storm — ~68% of all API calls returned 429 RESOURCE_EXHAUSTED. Only 32% of requests succeeded</em></figcaption></figure><p>To be clear — This wasn’t a platform bug. This was the “<strong>pay-as-you-go</strong>” system working as designed. Shared API capacity has limits. The 429 error was the system telling us we’d outgrown this tier.</p><p><strong>The Professional Option</strong></p><p>Google offers <strong>Provisioned Throughput </strong>for exactly this — reserved capacity with guaranteed tokens/sec on Vertex AI. It’s the professional tier for production workloads that need reliability guarantees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o06bDt6xJEI9lnW6jTT_ug.png" /><figcaption>Current workload profile</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Flv2B7NIHLgKnPFJm2McMg.png" /><figcaption>Cost Comparision for Different Gemini Approaches</figcaption></figure><p>Provisioned Throughput is designed for enterprise-scale workloads with consistently high sustained (20+ QPS). At our 3–5 RPS, we’d be paying for reserved capacity that doesn’t align with our usage pattern. Beyond the cost:</p><ul><li>You pay the fixed rate whether you use it or not</li><li>Commitment terms range from 1 week to 1 year</li><li>Pricing is measured in GSUs — an abstraction that requires calculation to map to your actual workload</li></ul><p><strong><em>Not overpriced for what it delivers — just not the right fit at our scale. We needed reliability, but 5.74x the cost for the same model felt like the wrong direction. So we started exploring a different path.</em></strong></p><h3>Episode 3: Right Model, Wrong Server</h3><p>If shared API capacity was the constraint, the obvious next thought was: what if we owned the inference?</p><p><strong>Gemma 3</strong> was Google’s open-weight model. Ollama made local deployment dead simple — pull a model, start serving. Five minutes from zero to inference on a dev machine.</p><p>Locally, it was impressive. Quality matched what we needed for structured output tasks. No rate limits. Full control. We were optimistic.</p><p>So we deployed it to production.</p><p><strong>Ollama did exactly what Ollama is built to do</strong> — serve a single user running experiments on their local machine. It’s a great developer tool. But it supports only static batching — while it allows parallel request processing via OLLAMA_NUM_PARALLEL (default: 1), it lacks continuous batching. Latency degrades significantly under concurrent load. Even at our modest 1–2 RPS, response times pushed well beyond our budget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z3rHR_JVsD6jIjSlFlKKSQ.png" /><figcaption>Comparison between Gemini API and Ollama</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvzV8L_xaT4xuOeO6bU_Ng.png" /><figcaption>Ollama calls latency — 15.7s</figcaption></figure><p>The reliability problem was solved — zero 429s, zero rate limiting. We got the control we wanted. But <strong>15.7 seconds average latency</strong> on a 2–3 second budget is a different kind of unusable.</p><p>We’d traded one hobby-grade setup (shared API without SLA) for another (local-first inference server in production). The model was right. The serving layer wasn’t.</p><p><strong><em>Scorecard after Episode 3:</em></strong></p><ul><li><strong><em>✅ Reliability — Solved (no external rate limits)</em></strong></li><li><strong><em>✅ Quality — Good (Gemma 3 matched our needs)</em></strong></li><li><strong><em>❌ Latency — 5–8x over budget</em></strong></li><li><strong><em>❌ Throughput — Insufficient for sustained load</em></strong></li></ul><h3>Episode 4: The Production-Grade Setup</h3><p>From past episodes, we had clarity on what we needed: <strong>the control and reliability</strong> of self-hosting, combined with a serving layer actually built for <strong>production concurrency </strong>— continuous batching, efficient memory management, real throughput.</p><p><strong>vLLM</strong> was that serving layer. Not a dev tool, not an experiment runner — a production inference engine.</p><p><strong>The Model: Gemma 4</strong></p><p>In April 2026, Google released <strong>Gemma 4</strong> with a <strong>Mixture-of-Experts (MoE)</strong> architecture. This changed the compute economics entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lVXK3C36eAkS8GLY5QnJMw.png" /><figcaption>Gemma Specifications</figcaption></figure><p>The <strong>26B A4B variant</strong> of Gemma 4 has <strong>25.2 billion total parameters</strong>, but only <strong>3.8 billion activate per token</strong> during inference. This means you get the quality of a 25B-parameter model but only pay the compute cost of a ~4B-parameter model on every token — large-model knowledge at small-model speed.</p><p>We run the AWQ 4-bit quantized variant (<strong>cyankiwi/gemma-4–26B-A4B-it-AWQ-4bit</strong>) on 2x A100 GPU pods.</p><p><strong>Why vLLM Over Ollama</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*CGV94QUWIGgKlYjv6sdVbA.png" /></figure><p>The three features that made the biggest difference:</p><ol><li><strong>Continuous Batching</strong> — vLLM dynamically batches incoming requests without waiting for a full batch to form. This is why throughput jumped from 40 to 450 TPS.</li><li><strong>PagedAttention</strong> — Allocates KV cache memory on-demand, like virtual memory. Near-zero waste. Our cache utilization stays under 25% even during peak hours.</li><li><strong>Prefix Caching</strong> — Our classification tasks share common system prompts and schemas. vLLM caches these shared prefixes automatically. We see a 20–40% prefix cache hit rate in production, which directly reduces time-to-first-token.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*f7qS4gVOSFbmB-0tm5SLrA.png" /><figcaption>KV Cache Usage Over Time</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*TomilTl48ovX775W6JpDIA.png" /><figcaption>Prefix Cache Hit Rate %</figcaption></figure><p><strong>The Results</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O45kRFPUt3csRHnIhAyInA.png" /><figcaption>Metrics For various LLM inference servings</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zvB8VUPNRVzJargoZxxKBQ.png" /><figcaption><em>vLLM latency over 24 hours — stable at ~1.40s. Compared to Ollama’s 13–16s average.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*0obANgHVQC81-p4BG6-66w.png" /><figcaption><em>Daily token volume — 131M input tokens and 9.31M output tokens.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boxrVHgejt6drbnqQOsT5Q.png" /><figcaption>vLLM Gemma success vs failures — 118,914 vs 121</figcaption></figure><p><strong>118,914 successful calls. 121 failures. 99.9% success rate. </strong>Compare that to the 68% failure rate at peak on shared API. Same content, same pipeline, same traffic. Different infrastructure choices.</p><p><strong>Cost Reality</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6HODP1IXJKXt3tvLHOJQEA.png" /><figcaption>Cost comparison between different approaches</figcaption></figure><p>For ~$5,700/month we get <strong>99.9% reliability, 1.4s latency</strong>, full operational control, and no dependency on external rate limits.</p><p><strong>The tradeoff</strong>: you own ops now. GPU monitoring, model updates, scaling, incident response — it’s all yours.</p><p><strong>Circuit Breaker: Belt and Suspenders</strong></p><p>We implemented a circuit breaker pattern with Gemini as the fallback:</p><ul><li><strong>Primary:</strong> vLLM + Gemma 4 (handles all traffic)</li><li><strong>Fallback:</strong> Gemini API (circuit breaker trips if vLLM health check fails)</li></ul><p>The API that couldn’t handle our full sustained traffic works perfectly fine as a safety net handling &lt;1% of requests during rare infrastructure events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DnIzzEyhpF8_10ePZRMWCg.png" /><figcaption>Gemini as a fallback in case of circuit breakers</figcaption></figure><h3>Conclusion: Read the Labels</h3><p>Looking back, every tool we used worked exactly as advertised. Not one of them let us down. We just kept using things outside their intended scope.</p><p><strong>Every tool has a label. We should have read them first.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B9BNDcmW8PXFJcJGaWe9Ag.png" /><figcaption>Capability comparison between different approaches</figcaption></figure><p><strong>The progression, in hindsight:</strong></p><ol><li>Start with the managed API — cheapest, fastest path to production</li><li>Outgrow shared infrastructure limits at scale</li><li>Self-host with dev-grade tooling — learn that inference ≠ serving</li><li>Self-host with production-grade tooling — get reliability, latency, and control</li></ol><p><strong>What we learned:</strong></p><ul><li><strong>No tool is wrong — only mismatched.</strong> Gemini PAYG is excellent for what it’s designed for. Ollama is a fantastic dev tool. Neither failed. We put them in roles they weren’t built for.</li><li><strong>“Hobby” and “enterprise” are scale labels, not quality judgments.</strong> A hobby tool at hobby scale is the right choice. The same tool at enterprise scale will break in exactly the ways you’d expect.</li><li><strong>Self-hosting isn’t free.</strong> You’re trading API costs for ops investment. We run circuit breakers, health checks, and GPU monitoring. You own the SLA now.</li><li><strong>Open-weight models have crossed the threshold.</strong> Gemma 4’s MoE architecture delivers production quality at manageable compute. vLLM makes it servable. Apache 2.0 makes it legal. This is a real option now — not a research project.</li><li><strong>Read the disclaimers. </strong>Every solution publishes its intended use case, its limits, its tradeoffs. Know your system, know your risks and make a wise decision.</li></ul><p><strong>When should you self-host?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DNM6G9CM6p6x1WTWpGREMA.png" /></figure><p><em>Every tool we tried worked as promised. We just kept expecting it to work out of the box for something it wasn’t designed for. If you’re running LLM inference in production — read the label first. It’ll save you a few episodes.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf88a74451c5" width="1" height="1" alt=""><hr><p><a href="https://engg.glance.com/from-hobby-to-enterprise-our-llm-inference-journey-in-production-cf88a74451c5">Our LLM Inference Journey in Production: From Hobby to Enterprise</a> was originally published in <a href="https://engg.glance.com/">Glance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GPU Time Slicing: Maximizing GPU Utilization in Kubernetes]]></title>
            <link>https://engg.glance.com/gpu-time-slicing-maximizing-gpu-utilization-in-kubernetes-1b91a1945a01?source=rss-108370ad0d3e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b91a1945a01</guid>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[computing]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Bhavesh Maheshwari]]></dc:creator>
            <pubDate>Thu, 09 Apr 2026 07:53:22 GMT</pubDate>
            <atom:updated>2026-04-09T07:53:22.630Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i7Tm3q-GSeTKlXbR8aIoJw.png" /></figure><p>If you are part of a team running inference workloads on kubernetes and if you are paying for underutilized GPUs or struggling to justify GPU costs for POC/development workloads, read on.</p><p>I started working with GPUs for production services and POC use cases a few months back. GPUs deliver jet-like speed, but that performance comes with a hefty price tag. When that jet sits idle in the hangar for 80–90% of the time, the cost quickly turns into pure waste.</p><p>That was exactly the situation we found ourselves in — our GPUs were powerful, but vastly underutilized.</p><p>For one of our use cases at Glance, we were running 3 services with ML models, each deployment having 2 pods for high availability. Every pod was allocated 1 full GPU. The GPU utilization? A mere 10–20%. That’s it, a $10 million jet standing in the hangar.</p><h3>Problem Statement</h3><h4>Resource Underutilization</h4><p>We needed to run multiple deployments with a minimum of 2 pods each to ensure high availability. The reality of our setup:</p><ul><li>3 production deployments × 2 pods each = 6 GPUs</li><li>Active POCs requiring 1 pod each but not actively used = 1–2 GPUs</li><li><strong>Total: 7–8 GPUs running continuously</strong></li><li><strong>Average GPU utilization: 10–20%</strong></li></ul><p>Each GPU was dedicated to a single pod, even though most of our workloads were inference-based and didn’t need exclusive access.</p><h4>Cost Impact</h4><p>The numbers were hard to ignore:</p><ul><li><strong>$3.8K per month — $45K annually</strong> in wasted compute capacity</li><li>75% of GPU resources sitting idle while we paid full price</li></ul><h4>Scheduling Constraints</h4><p>The all-or-nothing allocation model created operational problems:</p><ul><li>Teams couldn’t experiment without spinning up new expensive nodes</li><li>No way to pack multiple low-intensity workloads on the same hardware</li></ul><h3>Possible solutions</h3><p>When evaluating GPU sharing solutions, we had three options:</p><p><strong>NVIDIA MIG (Multi-Instance GPU)</strong><br>Physically partitions GPU into dedicated slices with isolated memory. Only supported on expensive hardware (A100, H100, H200+) and limited to 7 slices maximum — overkill and too costly for our inference workloads.</p><p><strong>vGPU (Virtual GPU)</strong><br>Virtual separation with dedicated memory per pod, running simultaneously. Provides strong fault isolation but comes with licensing costs and OOM risk during workload spikes.</p><p><strong>GPU Time Slicing</strong><br>Software-based temporal sharing where pods share GPU memory and execute sequentially through context switching. No specialized hardware or licenses required, unlimited partitions possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tjl1pd5e-06YmVwet7sU4w.png" /><figcaption>Comparison of different GPU optimization Techniques</figcaption></figure><p><em>Time slicing emerged as the pragmatic choice for our inference workloads — no hardware upgrades needed, and flexible enough to pack 4–6 pods per GPU.</em></p><h3>Understanding GPU Time Slicing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*QfYmJGvEpVpcb2cy" /></figure><p>GPU Time Slicing enables multiple workloads to share a single physical GPU through rapid context switching — similar to how a CPU scheduler works. When Pod A finishes its compute cycle or waits for I/O, the GPU immediately switches to Pod B. All pods share the same GPU memory pool and execute sequentially, not in parallel. This works best for workloads with intermittent GPU usage — inference serving, development environments, and batch jobs that don’t continuously saturate the GPU.</p><h3>Benefits of GPU Time Slicing</h3><ul><li><strong>No hardware upgrades needed</strong> — Works on standard NVIDIA GPUs (T4, V100, A10, L4) without expensive A100s or vGPU licenses</li><li><strong>Maximizes utilization</strong> — Pushes GPU usage from 20–25% to 60–80% by packing multiple workloads on a single GPU</li><li><strong>Flexible partitioning</strong> — Configure 4, 8, or more slices per GPU and adjust based on performance without infrastructure changes</li><li><strong>Simple to implement</strong> — ConfigMap-based setup with no kernel modules or driver modifications required</li><li><strong>Unlimited slices</strong> — No hard partition limit unlike MIG’s 7-slice constraint</li></ul><h3>Limitations of GPU Time Slicing</h3><ul><li><strong>Context switching overhead</strong> — Frequent workload switches introduce latency and reduce overall throughput</li><li><strong>Shared memory OOM risk</strong> — All pods share the same VRAM pool; combined usage exceeding capacity causes pod crashes</li><li><strong>No fault isolation</strong> — A misbehaving pod (memory leak, runaway process) degrades performance for all workloads on that GPU</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*JpW587QybYuq0YWh" /></figure><h3>Implementation in Kubernetes</h3><p>Implementing GPU Time Slicing in Kubernetes can be done in two ways: via NVIDIA device plugin ConfigMap (cluster-level) or via GKE node pool configuration (node pool-level).</p><h4>Method 1: GKE Node Pool Configuration (GKE-specific)</h4><p>For Google Kubernetes Engine (GKE), you can configure GPU time slicing directly at the node pool level. This is simpler and applies automatically to all nodes in the pool.</p><h4><strong>Step 1: Create Node Pool with GPU Time Slicing</strong></h4><p>When creating a new node pool, specify the GPU sharing configuration:</p><pre>gcloud container node-pools create gpu-time-slice-pool \<br>  --cluster=&lt;your-cluster-name&gt; \<br>  --zone=&lt;your-zone&gt; \<br>  --machine-type=n1-standard-16 \<br>  --accelerator=type=nvidia-tesla-t4,count=1,gpu-sharing-strategy=time-sharing,max-shared-clients-per-gpu=5 \<br>  --num-nodes=2</pre><p><strong>Key parameters:</strong></p><ul><li>gpu-sharing-strategy=time-sharing — Enables time slicing on the node pool</li><li>max-shared-clients-per-gpu=5 — Allows up to 5 pods to share each GPU</li></ul><h4>Step 2: Verify Configuration</h4><pre># Check node allocatable GPUs<br>kubectl describe node &lt;gpu-node-name&gt; | grep nvidia.com/gpu<br><br># Expected output (for 1 physical GPU with max-shared-clients=5):<br># nvidia.com/gpu: 5</pre><h4>Method 2: NVIDIA Device Plugin ConfigMap (Works on any Kubernetes cluster)</h4><p>This approach uses the NVIDIA device plugin with a custom ConfigMap to define the slicing strategy.</p><p><strong>Prerequisites</strong></p><ul><li>Kubernetes cluster with GPU nodes</li><li>NVIDIA GPU drivers installed on nodes</li><li>NVIDIA device plugin deployed (or ready to deploy)</li></ul><h4>Step 1: Create Time Slicing ConfigMap</h4><p>The ConfigMap defines how many replicas (slices) each GPU should expose to Kubernetes.</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: gpu-time-slicing-config<br>  namespace: kube-system<br>data:<br>  time-slicing-config: |<br>    version: v1<br>    sharing:<br>      timeSlicing:<br>        replicas: 5</pre><p><strong>Key parameters:</strong></p><ul><li>replicas: 5 — Each physical GPU will appear as 5 logical GPUs to the scheduler</li><li>Adjust replicas based on workload memory requirements (5, 10, or 15 are common values)</li></ul><h4>Step 2: Update NVIDIA Device Plugin DaemonSet</h4><p>Modify the existing NVIDIA device plugin DaemonSet to reference the ConfigMap and enable time slicing.</p><pre>apiVersion: apps/v1<br>kind: DaemonSet<br>metadata:<br>  name: nvidia-device-plugin-daemonset<br>  namespace: kube-system<br>spec:<br>  selector:<br>    matchLabels:<br>      name: nvidia-device-plugin-ds<br>  template:<br>    metadata:<br>      labels:<br>        name: nvidia-device-plugin-ds<br>    spec:<br>      tolerations:<br>      - key: nvidia.com/gpu<br>        operator: Exists<br>        effect: NoSchedule<br>      containers:<br>      - image: nvcr.io/nvidia/k8s-device-plugin:v0.14.0<br>        name: nvidia-device-plugin-ctr<br>        args:<br>        - &quot;--config-file=/etc/nvidia/time-slicing-config&quot;<br>        env:<br>        - name: NVIDIA_MIG_MONITOR_DEVICES<br>          value: all<br>        volumeMounts:<br>        - name: device-plugin<br>          mountPath: /var/lib/kubelet/device-plugins<br>        - name: time-slicing-config-volume<br>          mountPath: /etc/nvidia<br>      volumes:<br>      - name: device-plugin<br>        hostPath:<br>          path: /var/lib/kubelet/device-plugins<br>      - name: time-slicing-config-volume<br>        configMap:<br>          name: gpu-time-slicing-config<br>          items:<br>          - key: time-slicing-config<br>            path: time-slicing-config</pre><p><strong>Key changes:</strong></p><ul><li>Mount ConfigMap as volume at /etc/nvidia</li><li>Pass --config-file=/etc/nvidia/time-slicing-config argument to the plugin</li></ul><h4>Step 3: Apply Configuration</h4><pre># Create the ConfigMap<br>kubectl apply -f gpu-time-slicing-configmap.yaml<br><br># Update or deploy the device plugin DaemonSet<br>kubectl apply -f nvidia-device-plugin-daemonset.yaml<br><br># Restart the device plugin pods to pick up new config<br>kubectl rollout restart daemonset/nvidia-device-plugin-daemonset -n kube-system</pre><h4>Step 4: Verify Time Slicing is Active</h4><p>Check that GPUs are now advertised with the replica count:</p><pre>kubectl describe node &lt;gpu-node-name&gt; | grep nvidia.com/gpu<br><br># Expected output (for 1 physical GPU with replicas: 5):<br># nvidia.com/gpu: 5</pre><h4>Update Deployment Manifests (Common to both methods)</h4><p>Your application deployments don’t need major changes — just ensure they request nvidia.com/gpu resources:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: service<br>spec:<br>  replicas: 5<br>  selector:<br>    matchLabels:<br>      app: service<br>  template:<br>    metadata:<br>      labels:<br>        app: service<br>    spec:<br>      containers:<br>      - name: model-server<br>        image: your-inference-image:latest<br>        resources:<br>          limits:<br>            nvidia.com/gpu: 1  # Each pod gets 1 logical GPU slice<br>          requests:<br>            nvidia.com/gpu: 1</pre><p><strong>Important considerations:</strong></p><ul><li>With 5 max shared clients, 5 pods can now share 1 physical GPU</li><li>Each pod still requests nvidia.com/gpu: 1 but gets a time-sliced share</li><li>Monitor memory usage carefully — all 5 pods share the same VRAM</li></ul><h3>Comparison: ConfigMap vs Node Pool Config</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d-shop1QZsOrXzROgu_S4Q.png" /><figcaption>Comparison of diferent approaches</figcaption></figure><p>For GKE users, <strong>Method 2 (node pool config)</strong> is recommended for simplicity. For other Kubernetes platforms, use <strong>Method 1 (ConfigMap)</strong>.</p><h3>Impact</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9AvNuxOkDj4dFjjH" /><figcaption>Multi pods running on Single GPU — Notice two Python processes sharing the same Tesla T4, each using ~630MiB of the 15GB VRAM</figcaption></figure><h4><strong>Before Time Slicing</strong></h4><p>We were running 7–8 GPUs continuously with average utilization of just 10–20%, costing $3.8K per month ($45K annually). Each pod monopolized an entire GPU despite most workloads being inference-based with intermittent compute needs, resulting in 75% wasted capacity.</p><h4>After Time Slicing</h4><p>By configuring 5 slices per GPU, we consolidated all workloads onto 2 physical GPUs (10 logical slots). With 6 production pods and 1–2 POC pods, this configuration provides headroom for traffic spikes while maintaining high availability. GPU utilization jumped to 65–75% (with peaks up to 85%) also, reducing our monthly cost to $1.1K ($13K annually) whopping 70% cost reduction.</p><h3>Key Takeaways</h3><p>The transition to GPU time slicing transformed our infrastructure from a costly, underutilized cluster into an efficient, high-density environment. By moving away from dedicated 1:1 GPU allocations, we unlocked several key improvements:</p><ul><li><strong>Optimized Utilization:</strong> Consolidating workloads from eight physical GPUs down to just two increased our average utilization from a wasteful 10–20% to a healthy 70–85%.</li><li><strong>High-Density Scaling:</strong> We successfully ran five pods per GPU, maintaining high availability for production services while still providing immediate capacity for POC experiments.</li><li><strong>Massive Cost Savings:</strong> We reduced our monthly GPU spend by an impressive 70%.</li></ul><p>Ultimately, time slicing proved to be the most pragmatic choice for our inference-heavy workloads. It enabled us to fully leverage our existing hardware and eliminate 75% of our wasted capacity — without requiring expensive upgrades, or significant code changes.</p><h3>Next Steps</h3><p>Building on this success, we’re expanding GPU time slicing across our ML infrastructure. Our immediate focus is deploying <strong>in-house image segmentation models</strong> and <strong>Gemma language models</strong> on time-sliced GPUs, which will further reduce our inference infrastructure costs. We’re also standardizing time slicing as the default configuration for all new POC deployments, enabling teams to experiment freely without provisioning dedicated GPU nodes. For production services with similar inference patterns, we’re gradually migrating them to time-sliced pools, targeting 80%+ utilization across our GPU fleet. Time slicing has become our primary strategy for maximizing GPU ROI while maintaining deployment flexibility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b91a1945a01" width="1" height="1" alt=""><hr><p><a href="https://engg.glance.com/gpu-time-slicing-maximizing-gpu-utilization-in-kubernetes-1b91a1945a01">GPU Time Slicing: Maximizing GPU Utilization in Kubernetes</a> was originally published in <a href="https://engg.glance.com/">Glance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>