<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>John Ciavarella</title>
  <link href="https://johnciavarella.com/ramblings/"/>
  <link rel="self" href="https://johnciavarella.com/ramblings/feed.xml"/>
  <id>https://johnciavarella.com/ramblings/</id>
  <updated>2026-11-16T00:00:00Z</updated>
  <author><name>John Ciavarella</name></author>
  <entry>
    <title>Batch photo tagging with Qwen3-VL &amp; Llama-swap</title>
    <link href="https://johnciavarella.com/ramblings/optimizeQwenVL/"/>
    <id>https://johnciavarella.com/ramblings/optimizeQwenVL/</id>
    <updated>2026-11-16T00:00:00Z</updated>
    <summary>Cutting a Qwen3-VL 8B photo tagging batch from 3.5 s to 1.3 s per photo on a 12 GB card with llama.cpp parallel slots, a unified KV cache and a client that sends requests in parallel.</summary>
    <content type="html">&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; My tool &lt;a href="https://github.com/johnciavarella/ai_img_json_exif"&gt;ai_img_json_exif&lt;/a&gt; was tagging photos with Qwen3-VL 8B one at a time at about 3.5 s each, with the GPU mostly idle between requests. The fix had two halves: a llama-server entry with &lt;code&gt;--parallel 8 --kv-unified&lt;/code&gt;, so eight requests share one 32k context at no extra VRAM, and a batch runner rewritten from a sequential loop into a worker pool. It now takes 1.3 to 1.4 s per photo. That is 2.6 times faster, not 8, and I think the image side is why.&lt;/p&gt;
&lt;h2&gt;One photo at a time&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/johnciavarella/ai_img_json_exif"&gt;ai_img_json_exif&lt;/a&gt; sends each photo to Qwen3-VL 8B Instruct (Q4_K_M) with a short prompt and gets a small JSON answer back. One at a time that took about 3.5 s per photo on a 12 GB RTX 4070 Ti, with the GPU mostly waiting on me.&lt;/p&gt;
&lt;p&gt;Decode is limited by memory bandwidth: every step reads all the weights, and that costs about the same for one sequence as for eight. A short JSON answer per photo is exactly the workload where stacking requests into the same pass is nearly free.&lt;/p&gt;
&lt;h2&gt;Server: slots that share one pool&lt;/h2&gt;
&lt;p&gt;llama-server can run several requests in one batch with &lt;code&gt;--parallel N&lt;/code&gt;, with a catch: by default the context is split between slots. Eight slots on a 32k context is 4k each. A tagging request is 2 to 3k tokens (a 1536 px image is about 1.4k of that), so it fits, but only just. &lt;code&gt;--kv-unified&lt;/code&gt; makes the slots share one pool instead, so VRAM stays exactly the same as the single-slot setup.&lt;/p&gt;
&lt;p&gt;I ended up with two entries in llama-swap pointing at the same files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;qwen3-vl-8b-8batch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Qwen3-VL&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;8B&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Instruct&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;(Q4_K_M,&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;batch:&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;8&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;parallel)"&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;ttl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;300&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p p-Indicator"&gt;|&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;llama-server&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--host 127.0.0.1 --port ${PORT}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--model "${models_dir}/Qwen/Qwen3-VL-8B-Instruct-GGUF/Qwen3VL-8B-Instruct-Q4_K_M.gguf"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--mmproj "${models_dir}/Qwen/Qwen3-VL-8B-Instruct-GGUF/mmproj-Qwen3VL-8B-Instruct-Q8_0.gguf"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--ctx-size 32768&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--cache-type-k q8_0 --cache-type-v q8_0&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--flash-attn on&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--parallel 8&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--kv-unified&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--n-gpu-layers 99&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="no"&gt;--jinja&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The plain &lt;code&gt;qwen3-vl-8b&lt;/code&gt; entry went back to &lt;code&gt;--parallel 1&lt;/code&gt; so a single interactive request gets the whole 32k. My first attempt had been to give the one entry four slots, which sped up batches and shrank everything else. For the record, the batch entry was named &lt;code&gt;-batch&lt;/code&gt;, then &lt;code&gt;-octo-parallel&lt;/code&gt;, then &lt;code&gt;-8batch&lt;/code&gt;, across three commits in two minutes.&lt;/p&gt;
&lt;h2&gt;Loading from a local SSD&lt;/h2&gt;
&lt;p&gt;One fix came before any of the slot work. llama-swap unloads the model after five idle minutes so the card is free for other jobs, which means model loads happen all the time, and mine were reading the GGUF files from the NAS over NFS.&lt;/p&gt;
&lt;p&gt;I added a one-shot pre-flight service to the stack. It rsyncs the models on a short list from the NAS to a local SSD and exits, and llama-swap only starts after it succeeds. The cache is mounted at the old path, so no model paths changed. Unchanged files are skipped, so a normal start takes seconds. llama-swap no longer mounts the NFS share at all, which also means a NAS outage cannot stall a model load.&lt;/p&gt;
&lt;h2&gt;Client: a worker pool&lt;/h2&gt;
&lt;p&gt;Server slots do nothing if the client sends one request and waits. The batch runner in &lt;code&gt;app/static/batch.js&lt;/code&gt; was a &lt;code&gt;for&lt;/code&gt; loop with &lt;code&gt;await&lt;/code&gt; in it, so it became a pool of workers pulling from a shared queue. Trimmed down:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;parallel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;batchParallel&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;queue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;pause&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;AbortController&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;worker&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;stopping&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;runItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;attempt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;===&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"transient"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;attempt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;RETRY_DELAYS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;stopping&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;attempt&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;wait&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;retryDelay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RETRY_DELAYS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastError&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;abortableSleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;waitSignal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;runItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;===&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"transient"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nx"&gt;pausedOn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;??=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nx"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;abort&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nx"&gt;finished&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kr"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;parallel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The parts that took more thought than the pool itself:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;One worker giving up has to stop the rest.&lt;/strong&gt; When a photo exhausts its retries because the server is unreachable, it aborts a shared controller so the other seven stop sleeping and the batch pauses once, not eight times.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Resume cannot assume order.&lt;/strong&gt; The old code resumed from &lt;code&gt;todo.slice(ran)&lt;/code&gt;. With workers finishing out of order, it now keeps a set of finished photos and resumes with whatever is not in it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The ETA lies unless you divide.&lt;/strong&gt; Each photo&amp;rsquo;s own time gets longer in parallel while the batch gets faster. The average is per-photo time divided by the parallel count, and it skips the first photo per slot because those include loading the model.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Results belong to the model, not the endpoint.&lt;/strong&gt; A &lt;code&gt;-8batch&lt;/code&gt; name maps back to its base model for the results cache, so photos tagged in parallel do not get re-run when I switch to the plain entry.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Honour &lt;code&gt;Retry-After&lt;/code&gt;.&lt;/strong&gt; A 429 or 503 with that header now sets the retry wait, capped at five minutes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parallel&lt;/th&gt;
&lt;th&gt;Per photo&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;about 3.5 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;1.85 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;1.3 to 1.4 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;That is 2.6 times faster, not 8 times. I have not profiled where the rest goes. My guess is the image side: every request still pays for its own image encode and a 1.4k-token prefill, and that work does not get cheaper by sharing a pass the way decode does. Going from 4 to 8 slots bought much less than going from 1 to 4, which fits.&lt;/p&gt;
&lt;h2&gt;What I would do again&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Fix the client first.&lt;/strong&gt; Eight server slots behind a sequential loop is one slot.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use a unified KV pool for small, uneven requests.&lt;/strong&gt; Splitting the context evenly wastes it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keep a separate entry for batch work.&lt;/strong&gt; Interactive use and batch use want different slot counts from the same weights.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Remember to consider all steps in a workflow.&lt;/strong&gt; Every swap is a load. Keep model files on local disk if the server swaps models.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Key cached results on the model, not the endpoint name.&lt;/strong&gt; Otherwise a faster route to the same model redoes finished work.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/johnciavarella/ai_img_json_exif"&gt;johnciavarella/ai_img_json_exif&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/mostlygeek/llama-swap/blob/main/docs/config.example.yaml"&gt;llama-swap example config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/Qwen/Qwen3-VL-8B-Instruct-GGUF"&gt;Qwen3-VL-8B-Instruct-GGUF&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  <entry>
    <title>Local LLM throughput is tokens per step times steps per second</title>
    <link href="https://johnciavarella.com/ramblings/localaiopt/"/>
    <id>https://johnciavarella.com/ramblings/localaiopt/</id>
    <updated>2026-11-15T00:00:00Z</updated>
    <summary>How I rethought how to my local AI workflows to double speed.</summary>
    <content type="html">&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; I spent a week tuning two local inference setups: Qwen3.8-27B under vLLM on a Radeon AI PRO R9700, and Qwen3-VL 8B under llama.cpp on a 12 GB RTX 4070 Ti. One went from 52 to 105 tokens/s per request and the other from 3.5 s to 1.3 s per photo. Neither win came from a faster model or a magic flag. Both came from treating decode as a memory-bandwidth problem and asking how many useful tokens each pass over the weights produces.&lt;/p&gt;
&lt;h2&gt;The model in one paragraph&lt;/h2&gt;
&lt;p&gt;Generating a token means reading every weight in the model once. On a GPU that read is limited by memory bandwidth, not compute, and it costs nearly the same whether the pass produces one token or twenty. So throughput is two numbers multiplied together: how many passes per second the card can do, and how many tokens you keep from each pass.&lt;/p&gt;
&lt;p&gt;The ceiling is easy to estimate. The R9700 has about 640 GB/s of memory bandwidth, and a 4-bit 27B model is 18 to 19 GB of weights. That is about 34 passes per second at best and closer to 20 in practice. One token per pass gives 20 to 30 tokens/s, and no flag changes that.&lt;/p&gt;
&lt;h2&gt;Three levers&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;More tokens per pass for one stream.&lt;/strong&gt; Speculative decoding: a small drafter proposes several tokens, and the big model verifies them in a single pass. You keep however many it agrees with.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cheaper passes.&lt;/strong&gt; A quantization format and kernels that suit the card, so each pass reads less or reads it faster.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More streams per pass.&lt;/strong&gt; Batching. Each request keeps its own state in the KV cache, the model itself holds none, so tokens from many requests can be stacked into the same pass.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Which lever matters depends on the workload, and my two were opposites:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;R9700, Qwen3.8-27B&lt;/th&gt;
&lt;th&gt;4070 Ti, Qwen3-VL 8B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Server&lt;/td&gt;
&lt;td&gt;vLLM&lt;/td&gt;
&lt;td&gt;llama.cpp behind llama-swap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requests&lt;/td&gt;
&lt;td&gt;40 to 50k token prompts, two at a time&lt;/td&gt;
&lt;td&gt;2 to 3k tokens each, thousands of them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What I care about&lt;/td&gt;
&lt;td&gt;Speed of one request&lt;/td&gt;
&lt;td&gt;Photos per minute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lever&lt;/td&gt;
&lt;td&gt;Longer draft, then cheaper passes&lt;/td&gt;
&lt;td&gt;More streams per pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Before&lt;/td&gt;
&lt;td&gt;51.8 tok/s per request&lt;/td&gt;
&lt;td&gt;about 3.5 s per photo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After&lt;/td&gt;
&lt;td&gt;105.3 tok/s per request&lt;/td&gt;
&lt;td&gt;1.3 to 1.4 s per photo&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The details are in two companion posts, &amp;ldquo;Doubling decode speed on a Radeon AI PRO R9700 with vLLM&amp;rdquo; and &amp;ldquo;Batch photo tagging with Qwen3-VL: eight slots, one KV pool&amp;rdquo;.&lt;/p&gt;
&lt;h2&gt;Measure the two terms separately&lt;/h2&gt;
&lt;p&gt;The most useful thing I did was stop looking at tokens/s in the log and graph the two terms on their own. vLLM exports what you need to Prometheus:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# decode tokens/s per request&lt;/span&gt;
&lt;span class="kr"&gt;increase&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;vllm&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;generation_tokens_total&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;1h&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;increase&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;vllm&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;request_decode_time_seconds_sum&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;1h&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# accepted draft tokens per verification pass&lt;/span&gt;
&lt;span class="kr"&gt;increase&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;vllm&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;spec_decode_num_accepted_tokens_total&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;1h&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;increase&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;vllm&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;spec_decode_num_drafts_total&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;1h&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This mattered twice. Per-position acceptance showed the drafter was still right about 74% of the time at the last position I allowed it, which meant the draft was too short. And when I switched quantization, acceptance per pass went down (2.99 to 2.74) while passes per second went up 38%. Looking at acceptance alone, I would have called that a regression. The product went from 67 to 97 tokens/s.&lt;/p&gt;
&lt;p&gt;The log, on the other hand, misled me twice. The &lt;code&gt;Avg prompt throughput&lt;/code&gt; line is a 10-second average, not prefill speed. And reasoning tokens count as generation, so a server running flat out at 73 tokens/s looked idle because the answer box was empty.&lt;/p&gt;
&lt;h2&gt;What caps each lever&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Draft length is capped by the drafter.&lt;/strong&gt; Past the point where conditional acceptance falls off, longer drafts cost time per pass and return nothing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batching is capped by the KV cache, not the weights.&lt;/strong&gt; Two 50k-token prompts filled 97% of a 7 GiB pool on the R9700. Eight 3k-token photo requests share a 32k pool on the 4070 Ti with room to spare.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batching does not help prefill the same way.&lt;/strong&gt; Image tokens and long prompts are work per request. Going from one photo at a time to eight gave me 2.6 times the throughput, not 8.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The client is part of the system.&lt;/strong&gt; Eight server slots behind a loop that sends one request and waits is one slot.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What I would tell myself a week ago&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Work out the bandwidth ceiling first.&lt;/strong&gt; If you are already near it, stop tuning flags and change a term in the equation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Graph tokens per pass and passes per second separately.&lt;/strong&gt; A change can move them in opposite directions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Make every experiment an A/B you can undo.&lt;/strong&gt; Same names, same port, separate caches. Switching back should be boring.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write down every default you depend on.&lt;/strong&gt; My longest wait was a 40-minute restart caused by flags I had never set.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Load models from fast local disk.&lt;/strong&gt; I was loading from slow network storage, and added a pre-flight step that pulls the models to a local SSD before the server starts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Know your request shape before choosing a lever.&lt;/strong&gt; Long prompts and short prompts want different servers configured in different ways.&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry>
  <entry>
    <title>Chasing hardware ghosts..RTFM</title>
    <link href="https://johnciavarella.com/ramblings/epyc-mem-issue/"/>
    <id>https://johnciavarella.com/ramblings/epyc-mem-issue/</id>
    <updated>2026-11-13T00:00:00Z</updated>
    <summary>My EPYC server lost memory channels for nine months.</summary>
    <content type="html">&lt;h1&gt;My EPYC server lost memory channels for nine months.&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Since February, my ASRock Rack ROMED8-2T had been disabling two or three DIMMs at every boot, and never quite the same ones. Over nine months I blamed mixed memory, CPU seating, a bad slot, a &amp;ldquo;platform quirk&amp;rdquo; and a dying CPU, and got as far as drafting an RMA. The real cause: my Samsung 32 GB LRDIMMs are built on 4 Gbit DRAM chips, and AMD only lists 8 and 16 Gbit chips as supported on EPYC 7003. Pulling the Samsungs and running only my Micron RDIMMs fixed it on the first boot.&lt;/p&gt;
&lt;h2&gt;The setup&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Board:&lt;/strong&gt; ASRock Rack ROMED8-2T (single socket SP3, eight DIMM slots, one per channel)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CPU:&lt;/strong&gt; AMD EPYC 7443&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Firmware:&lt;/strong&gt; BIOS P4.10, BMC 2.08.00&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory:&lt;/strong&gt; a mix of two used server parts&lt;/li&gt;
&lt;li&gt;Micron MTA36ASF4G72PZ-2G3B1: 32 GB, DDR4-2400, 2Rx4 RDIMM&lt;/li&gt;
&lt;li&gt;Samsung M386A4G40DM0-CPB: 32 GB, DDR4-2133, 4Rx4 LRDIMM&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The symptom&lt;/h2&gt;
&lt;p&gt;All eight slots were full, but the BMC only showed five or six DIMMs. The rest said &lt;code&gt;Absent&lt;/code&gt;. The event log had a fresh batch of these after every power-on:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Sensor: DRAM ECC ErrorA1 (d8h)   Type: memory
Memory Device Disabled - Asserted
Event Data1: a4h   Event Data2: 20h   Event Data3: 00h
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And the POST screen said it in plain English:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;The following Channel memory did not pass CPU memory test.
Please remove the memory then plug again.
Channel F (DDR4_F1)
Channel G (DDR4_G1)
Channel H (DDR4_H1)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The annoying part: the set changed. For months it was mostly channels D and H. Then it was three channels, and after I shuffled sticks it was a different three.&lt;/p&gt;
&lt;h2&gt;Nine months of wrong answers&lt;/h2&gt;
&lt;p&gt;The first &amp;ldquo;Memory Device Disabled&amp;rdquo; entry in my event log is from early February. I came back to it in April, again in August, and finally this month. I leaned on Claude for a lot of it, across four separate sessions, and it&amp;rsquo;s worth being straight about how that went: it was good at decoding logs and bad at knowing when it was guessing. Several confident answers along the way were wrong.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;April: &amp;ldquo;it&amp;rsquo;s the mix&amp;rdquo;, then &amp;ldquo;it&amp;rsquo;s a quirk&amp;rdquo;, then &amp;ldquo;it&amp;rsquo;s the CPU&amp;rdquo;.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I swapped modules around, reseated the CPU, pulled the CMOS battery and confirmed I was on the newest BIOS and BMC available at the time.&lt;/li&gt;
&lt;li&gt;The kernel was logging memory map-outs for &lt;code&gt;P0D0&lt;/code&gt; and &lt;code&gt;P0H0&lt;/code&gt; at every boot, so channels D and H.&lt;/li&gt;
&lt;li&gt;The advice went in circles. First the mixed vendors were &amp;ldquo;almost certainly&amp;rdquo; the problem. Then it was a known ROMED8-2T platform quirk I should learn to live with. Then the CPU&amp;rsquo;s memory controller was failing, and I ended up with a drafted RMA request for the CPU and the board. I never sent it. By that point I was too frustrated and too busy, so the server just kept limping along on whatever channels it felt like giving me.&lt;/li&gt;
&lt;li&gt;Some of the facts I was given were simply wrong: the Samsungs were described as 2Rx4 RDIMMs (they&amp;rsquo;re 4Rx4 LRDIMMs) and the four-DIMM slot layout was wrong too. I didn&amp;rsquo;t catch either at the time, and the first one was the whole answer hiding in plain sight.&lt;/li&gt;
&lt;li&gt;Side quest: after the CMOS clear, my PCIe disks stopped showing up, which for a moment looked like more evidence of a dying CPU. I think that one was unrelated. Clearing CMOS reset the BIOS settings and reshuffled the IOMMU groups, so it was a config problem, not a hardware one.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;August: &amp;ldquo;channel D is confirmed bad&amp;rdquo;.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I tested the six Samsungs one at a time and in sets. Three behaved. Three didn&amp;rsquo;t.&lt;/li&gt;
&lt;li&gt;Good sticks failed in slot D1, so the conclusion was a bad channel: bent socket pin, bad pad, or a board fault. I went looking at CPU pad maps.&lt;/li&gt;
&lt;li&gt;This was the most convincing wrong answer of the lot. The test looked clean. But every stick in it was a Samsung, so &amp;ldquo;a good stick fails in D1&amp;rdquo; really meant &amp;ldquo;a marginal stick fails somewhere&amp;rdquo;, which is what marginal sticks do.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;November: the mix again, then the socket again.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Same two theories, third time around. This is where it finally got settled, because I ran the two tests that should have come first.&lt;/p&gt;
&lt;h2&gt;Killing the &amp;ldquo;mixed memory&amp;rdquo; theory&lt;/h2&gt;
&lt;p&gt;The claim you&amp;rsquo;ll find all over forums is that registered and load-reduced DIMMs can&amp;rsquo;t share a system. AMD&amp;rsquo;s memory population guide for EPYC 7003 says something narrower: the &amp;ldquo;same module type&amp;rdquo; rule applies to DIMMs &lt;em&gt;within a channel&lt;/em&gt;. This board has one slot per channel, so there&amp;rsquo;s nothing to violate. My own machine was proof, with Samsungs and Microns running side by side while other slots were disabled.&lt;/p&gt;
&lt;p&gt;The test: I pulled every Micron and ran six Samsungs by themselves. Three channels still failed.&lt;/p&gt;
&lt;h2&gt;Killing the &amp;ldquo;socket&amp;rdquo; theory&lt;/h2&gt;
&lt;p&gt;If you search for &amp;ldquo;EPYC missing memory channels&amp;rdquo;, the top advice is always to reseat the CPU. SP3 is a huge LGA socket, and uneven clamping pressure or a speck of debris can knock out the pins for a whole channel. I even found a thread from another ROMED8-2T owner whose D1 and H1 slots failed the same POST memory test until they blew lint out of the socket. D1 and H1 were my two long-running failures. I was sure this was it.&lt;/p&gt;
&lt;p&gt;So I pulled the CPU again. The contact pads were clean. I reseated it properly (T20 Torx, screws in 1-2-3 order, 12 to 14 lbf-in) and booted with the RAM untouched.&lt;/p&gt;
&lt;p&gt;Same two channels failed.&lt;/p&gt;
&lt;p&gt;A channel that stays dead across a full reseat, with the same stick in it, isn&amp;rsquo;t a clamping problem.&lt;/p&gt;
&lt;h2&gt;Reading the event log (the BMC lies a little)&lt;/h2&gt;
&lt;p&gt;The log turned out to be useful once I stopped trusting how the BMC decodes it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The &amp;ldquo;Correctable ECC&amp;rdquo; label is wrong.&lt;/strong&gt; Event Data1 &lt;code&gt;a4h&lt;/code&gt; is IPMI&amp;rsquo;s &amp;ldquo;Memory Device Disabled&amp;rdquo;. These are the BIOS switching a channel off during boot, not ECC errors at runtime. That mislabel cost me months of thinking about error thresholds and dying DIMMs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&amp;ldquo;DRAM ECC ErrorA1&amp;rdquo; is not slot A1.&lt;/strong&gt; It&amp;rsquo;s one sensor name reused for every channel.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The printed &amp;ldquo;UMC instance id / DIMM number&amp;rdquo; text is garbage.&lt;/strong&gt; It splits the byte in a way that invents a second DIMM per channel, which this board doesn&amp;rsquo;t have.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The upper nibble of Event Data2 is the memory controller number,&lt;/strong&gt; and AMD&amp;rsquo;s controller-to-channel order on SP3 is not alphabetical.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&amp;rsquo;s the mapping I ended up with. The rows marked &amp;ldquo;yes&amp;rdquo; I confirmed against the POST screen or the inventory. The other three come from AMD&amp;rsquo;s reference table and I haven&amp;rsquo;t seen them fire.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Event Data2&lt;/th&gt;
&lt;th&gt;Channel&lt;/th&gt;
&lt;th&gt;Slot&lt;/th&gt;
&lt;th&gt;Confirmed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;00h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;DDR4_A1&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;10h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;DDR4_B1&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;20h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;DDR4_D1&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;30h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;DDR4_C1&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;40h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;H&lt;/td&gt;
&lt;td&gt;DDR4_H1&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;50h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;G&lt;/td&gt;
&lt;td&gt;DDR4_G1&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;60h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;td&gt;DDR4_E1&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;70h&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;DDR4_F1&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Two more BMC gotchas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The memory inventory page can be stale.&lt;/strong&gt; After I moved sticks, it kept showing the previous night&amp;rsquo;s serial numbers in the old positions. The POST screen and the event log are the truth.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The &amp;ldquo;Device Locator&amp;rdquo; column says &lt;code&gt;DIMM 0&lt;/code&gt; on every row.&lt;/strong&gt; Rows DIMM0 to DIMM7 are slots A1 to H1 in order, but the page won&amp;rsquo;t tell you that.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The final weekend, boot by boot&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Config&lt;/th&gt;
&lt;th&gt;Channels that failed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;8 sticks, mixed&lt;/td&gt;
&lt;td&gt;D, H&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8 sticks, mixed, same layout, next boot&lt;/td&gt;
&lt;td&gt;D, F, H&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8 sticks, mixed, rearranged, CPU pulled and inspected&lt;/td&gt;
&lt;td&gt;F, G, H&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6 Samsungs only (A, C, D, E, G, H)&lt;/td&gt;
&lt;td&gt;A, G, H&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same, after a full CPU reseat&lt;/td&gt;
&lt;td&gt;G, H&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Samsungs in C, D, G, H&lt;/td&gt;
&lt;td&gt;G, H&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;4 Microns in C, D, G, H&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;none&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;That last row is the whole diagnosis. Same slots that had failed three boots running, different sticks, clean POST. It also puts a Micron in D1, the &amp;ldquo;confirmed bad channel&amp;rdquo; from August, and it worked. The slots, the socket and the board were fine all along.&lt;/p&gt;
&lt;h2&gt;The actual cause&lt;/h2&gt;
&lt;p&gt;With the Samsungs identified as the problem, the question was why sticks that mostly pass alone get rejected in a set. The answer is in two documents:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Samsung&amp;rsquo;s product guide lists the M386A4G40DM0-CPB as built from &lt;strong&gt;4 Gbit&lt;/strong&gt; dual-die chips.&lt;/li&gt;
&lt;li&gt;AMD&amp;rsquo;s EPYC 7003 memory guide lists supported device technology as &lt;strong&gt;8 Gbit and 16 Gbit&lt;/strong&gt;. Its table of 4-rank LRDIMMs only has 64 GB and 128 GB modules. There is no 32 GB entry.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the module is the right &lt;em&gt;kind&lt;/em&gt; of thing (4-rank LRDIMMs are supported), which is why the board detects it and some sticks train. It&amp;rsquo;s just built from older, smaller chips than the platform was specified for. This is a first-generation DDR4 part from the Haswell-era Xeon days.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Not on the supported list&amp;rdquo; isn&amp;rsquo;t the same as &amp;ldquo;can&amp;rsquo;t work&amp;rdquo;. The same three of my six Samsungs trained in August and again in November. But a module that only sometimes passes memory training at boot is not something I want holding VMs.&lt;/p&gt;
&lt;h2&gt;The fix&lt;/h2&gt;
&lt;p&gt;Run only supported memory. I put four Micron RDIMMs in C1, D1, G1 and H1, which is the proper balanced four-DIMM layout for this socket, and the problem was gone: clean POST, nothing disabled, nothing in the event log. I ran a memtest on them once they were in and it passed.&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s 128 GB on four of the eight channels. It&amp;rsquo;s stable, but it leaves half the memory channels empty, so I&amp;rsquo;ve ordered four more Microns to match and fill the board.&lt;/p&gt;
&lt;p&gt;Shopping for used server RAM with this whole saga fresh in my mind, here&amp;rsquo;s what I checked on every listing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The letters after &lt;code&gt;2G3B1&lt;/code&gt; don&amp;rsquo;t matter.&lt;/strong&gt; MG, MI, II and friends are suffix variants of the same module.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;2G3D1&lt;/code&gt; is close but not identical.&lt;/strong&gt; Same module family, later revision. Fine as a fallback.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Watch for the 16 GB lookalike.&lt;/strong&gt; MTA36ASF&lt;strong&gt;2G&lt;/strong&gt;72PZ is one character off in a listing title, and a 16 GB 2Rx4 module works out to 4 Gbit chips. That&amp;rsquo;s the exact trap I just climbed out of.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;PZ&lt;/code&gt; is registered, &lt;code&gt;LZ&lt;/code&gt; is load-reduced.&lt;/strong&gt; I wanted PZ.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Read the label photo, not the title.&lt;/strong&gt; It should say &lt;code&gt;32GB 2Rx4 PC4-2400T-R&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Check the return policy.&lt;/strong&gt; A lot of these are &amp;ldquo;pulled from working hardware, untested, no returns&amp;rdquo;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When the new sticks arrive, all eight go in and get the same treatment: a few cold boots and another memtest before the box goes back to real work. I&amp;rsquo;ll update this post with how that goes.&lt;/p&gt;
&lt;h2&gt;What I&amp;rsquo;d do differently&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Boot a known-good matched set before anything else.&lt;/strong&gt; Four identical supported RDIMMs in the recommended slots clears the board, socket and slots in one boot. I had those sticks the whole time. This test would have ended it in February.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don&amp;rsquo;t test a theory using only the suspect parts.&lt;/strong&gt; My August slot tests used nothing but Samsungs, so they could never tell a bad slot from a marginal stick.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Read the POST screen first.&lt;/strong&gt; It names the failed slots in plain text. I spent a long time decoding hex before I looked at it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Write down what&amp;rsquo;s in every slot before moving anything.&lt;/strong&gt; I rearranged RAM without recording it more than once, and those results became unreadable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Swap sticks between a failing slot and a working one before touching the CPU.&lt;/strong&gt; If the fault follows the stick, it&amp;rsquo;s the stick. If it stays put, it&amp;rsquo;s the slot.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Check the DRAM chip density, not just the module type and capacity.&lt;/strong&gt; &amp;ldquo;32 GB DDR4 ECC&amp;rdquo; covers both of my parts. Only one of them is supported.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Make the AI show its sources.&lt;/strong&gt; The sessions that went wrong were the ones answered from memory. The one that worked was the one where I pushed for actual research, and the answer came with AMD&amp;rsquo;s and Samsung&amp;rsquo;s own documents attached.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.amd.com/api/khub/documents/0bglRXRnwmLeDr6L0vSZVA/content"&gt;AMD: Memory Population Guidelines for EPYC 7003 (publication 56873)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://download.gigabyte.com/FileList/Manual/server_manual_Memory_Population_Guidelines_e_A00.pdf"&gt;Gigabyte&amp;rsquo;s copy of the same guideline&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dtsheet.com/doc/1571233/product-selection-guide"&gt;Samsung DDR4 product selection guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://forum.level1techs.com/t/asrock-romed8-2t-not-reading-dimm-d-and-h/200107"&gt;Level1Techs: ROMED8-2T not reading DIMM D and H&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://download.asrock.com/Manual/ROMED8-2T.pdf"&gt;ASRock Rack ROMED8-2T manual&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
</feed>
