<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Meshy AI</title>
    <description>The latest articles on DEV Community by Meshy AI (meshyai).</description>
    <link>https://dev.to/meshyai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F15862%2F67b7eeda-9315-434f-82b2-d3a06657ba5c.png</url>
      <title>DEV Community: Meshy AI</title>
      <link>https://dev.to/meshyai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meshyai"/>
    <language>en</language>
    <item>
      <title>Overmind: Cut ML Model Loading from 15s to 0.2s</title>
      <dc:creator>Jingya</dc:creator>
      <pubDate>Fri, 06 Nov 2026 04:26:37 +0000</pubDate>
      <link>https://dev.to/meshyai/overmind-cut-ml-model-loading-from-15s-to-02s-3380</link>
      <guid>https://dev.to/meshyai/overmind-cut-ml-model-loading-from-15s-to-02s-3380</guid>
      <description>&lt;p&gt;&lt;em&gt;Based on an article by Bin Wang, Senior Infrastructure Engineer at Meshy. Adapted for DEV from the &lt;a href="https://www.meshy.ai/blog/fast-ml-model-loading-overmind" rel="noopener noreferrer"&gt;original Meshy engineering post&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Your model files are already cached in RAM. Why does loading the model still take seconds?&lt;/p&gt;

&lt;p&gt;At Meshy, switching between models made this question hard to ignore. Keeping every checkpoint in GPU memory was impractical, while repeatedly loading weights interrupted both inference workflows and development.&lt;/p&gt;

&lt;p&gt;We built &lt;strong&gt;Overmind&lt;/strong&gt;, an open-source model-loading cache, to make repeated loads cheaper.&lt;/p&gt;

&lt;h2&gt;
  
  
  A warm disk cache is only part of the solution
&lt;/h2&gt;

&lt;p&gt;The Linux page cache helps avoid disk reads. Reconstructing a model can still involve moving gigabytes of tensor data through deserialization buffers and newly allocated storage.&lt;/p&gt;

&lt;p&gt;Overmind separates tensor metadata from the underlying bytes. Instead of repeatedly copying those bytes, it reconstructs tensor storage over shared memory.&lt;/p&gt;

&lt;p&gt;A separate server keeps the cache available across client-process restarts. The design and implementation are covered in the &lt;a href="https://www.meshy.ai/blog/fast-ml-model-loading-overmind" rel="noopener noreferrer"&gt;original engineering walkthrough&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How shared memory becomes a model
&lt;/h2&gt;

&lt;p&gt;The mechanism connects a few useful building blocks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;memfd_create&lt;/code&gt; provides anonymous memory accessible through a file descriptor.&lt;/li&gt;
&lt;li&gt;Memory mapping exposes that allocation to participating processes.&lt;/li&gt;
&lt;li&gt;A Python &lt;code&gt;memoryview&lt;/code&gt; exposes the mapped buffer.&lt;/li&gt;
&lt;li&gt;A small C++ helper constructs PyTorch &lt;code&gt;UntypedStorage&lt;/code&gt; over that buffer without copying its contents.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Serialization records how to reconstruct the objects around the shared storage. GPU transfer remains a separate operation.&lt;/p&gt;

&lt;p&gt;Real model stacks also require special handling. Overmind restores dynamically loaded &lt;code&gt;diffusers&lt;/code&gt; modules, supplies serialization support for &lt;code&gt;bitsandbytes&lt;/code&gt; parameters, and handles model arguments that reference previously cached components. Quantization runs in a temporary subprocess so the cache server does not retain the CUDA state created during that work. See the &lt;a href="https://huggingface.co/blog/meshy-ai-team/overmind" rel="noopener noreferrer"&gt;technical overview on Hugging Face&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it in an existing loading workflow
&lt;/h2&gt;

&lt;p&gt;Install the package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;overmind-cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable the supported patches before loading models:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;overmind.api&lt;/span&gt;

&lt;span class="n"&gt;overmind&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;monkey_patch_all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;diffusers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;DiffusionPipeline&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DiffusionPipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;stabilityai/stable-diffusion-xl-base-1.0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;torch_dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;float16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cuda&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first load populates the cache. Later loads can reuse it.&lt;/p&gt;

&lt;p&gt;For applications that prefer an explicit call, the library also exposes &lt;code&gt;load&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;diffusers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;DiffusionPipeline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;overmind.api&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;DiffusionPipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;stabilityai/stable-diffusion-xl-base-1.0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;torch_dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;float16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cuda&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These examples illustrate the integration options; they are not the script used for the benchmark below. The &lt;a href="https://github.com/meshy-dev/overmind" rel="noopener noreferrer"&gt;repository README&lt;/a&gt; documents supported loaders and server-management commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the benchmark actually measures
&lt;/h2&gt;

&lt;p&gt;The published benchmark uses a VAE and two ControlNets with a Stable Diffusion pipeline, running on an Intel i9-11900K and an RTX 4090.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Total loading time, including GPU transfer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Without Overmind, across five runs&lt;/td&gt;
&lt;td&gt;5.65–6.27 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First load with Overmind&lt;/td&gt;
&lt;td&gt;24.20 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subsequent loads with Overmind&lt;/td&gt;
&lt;td&gt;1.12–1.15 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The original headline’s &lt;strong&gt;0.2 seconds&lt;/strong&gt; should not be read as the complete loading path. In this benchmark, the cached pipeline-loading step takes approximately 0.20–0.21 seconds; transferring weights to CUDA still takes approximately 0.86–0.90 seconds. &lt;a href="https://www.meshy.ai/blog/fast-ml-model-loading-overmind" rel="noopener noreferrer"&gt;Full benchmark&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That makes the tradeoff concrete: cache initialization is more expensive, and repeated loads recover that cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure the part your application repeats
&lt;/h2&gt;

&lt;p&gt;When evaluating a loading cache, measure three stages separately:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initial cache population.&lt;/li&gt;
&lt;li&gt;Reconstruction from an existing cache.&lt;/li&gt;
&lt;li&gt;Transfer to the target device.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then compare the complete workflow your application actually repeats. A service that loads once and stays running has a different cost profile from a development loop that starts a new process after every edit.&lt;/p&gt;

&lt;p&gt;Overmind is available under Apache 2.0. Explore the implementation and usage details on &lt;a href="https://github.com/meshy-dev/overmind" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When you profile model startup, where does most of the time go: reading weights, reconstructing the model, or moving it to the GPU?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
