<?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: Yanng</title>
    <description>The latest articles on DEV Community by Yanng (@yanng981).</description>
    <link>https://dev.to/yanng981</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%2Fuser%2Fprofile_image%2F4142559%2F54a20e5d-1ced-410b-97c7-95dc67f32f2a.png</url>
      <title>DEV Community: Yanng</title>
      <link>https://dev.to/yanng981</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yanng981"/>
    <language>en</language>
    <item>
      <title>How fast is Laya on a CPU? Reading the 4-core server benchmarks</title>
      <dc:creator>Yanng</dc:creator>
      <pubDate>Fri, 25 Sep 2026 08:56:57 +0000</pubDate>
      <link>https://dev.to/yanng981/how-fast-is-laya-on-a-cpu-reading-the-4-core-server-benchmarks-2mgb</link>
      <guid>https://dev.to/yanng981/how-fast-is-laya-on-a-cpu-reading-the-4-core-server-benchmarks-2mgb</guid>
      <description>&lt;p&gt;Can you run Laya without a GPU? Yes, and the upstream project now publishes enough CPU measurements to say how fast, what it costs per question, and which settings matter. This guide reads those numbers so you can size a CPU deployment before you buy hardware.&lt;/p&gt;

&lt;p&gt;All figures below come from the upstream &lt;a href="https://github.com/NandhaKishorM/laya/blob/main/BENCHMARKS.md" rel="noopener noreferrer"&gt;Laya BENCHMARKS.md&lt;/a&gt;. Each is tied to the hardware and setup it was measured on.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;On a 4-core server CPU, &lt;strong&gt;&lt;code&gt;laya-multilingual&lt;/code&gt; answers one question in about 193 ms&lt;/strong&gt;; the English and typed-decisions checkpoints take about &lt;strong&gt;580 ms&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On CPU, cost grows almost linearly with the number of questions. &lt;strong&gt;Batching questions into one call saves little&lt;/strong&gt;, unlike on a GPU.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thread settings can matter more than the model.&lt;/strong&gt; On one laptop, fixing torch's thread defaults made calls about 12x faster.&lt;/li&gt;
&lt;li&gt;Cold loads take seconds, and several loaded checkpoints can use around 9 GiB of RAM, so &lt;strong&gt;preload what you serve&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The server CPU numbers
&lt;/h2&gt;

&lt;p&gt;Measured in-process on an AWS &lt;code&gt;m7a.xlarge&lt;/code&gt; (AMD EPYC 9R14, 4 physical cores, no SMT, 16 GiB RAM), Laya v0.3.20, fp32, &lt;code&gt;OMP_NUM_THREADS=4&lt;/code&gt;. Each call alternates a 3-option &lt;code&gt;choice&lt;/code&gt; and a &lt;code&gt;noul&lt;/code&gt; question. Values are p50; p95 was within 2% of p50 on every row.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;checkpoint&lt;/th&gt;
&lt;th&gt;1 question&lt;/th&gt;
&lt;th&gt;5&lt;/th&gt;
&lt;th&gt;10&lt;/th&gt;
&lt;th&gt;50&lt;/th&gt;
&lt;th&gt;cold load&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;laya&lt;/code&gt; (English)&lt;/td&gt;
&lt;td&gt;580 ms&lt;/td&gt;
&lt;td&gt;3,072 ms&lt;/td&gt;
&lt;td&gt;6,244 ms&lt;/td&gt;
&lt;td&gt;35,969 ms&lt;/td&gt;
&lt;td&gt;4.4 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;laya-multilingual&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;193 ms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;912 ms&lt;/td&gt;
&lt;td&gt;1,842 ms&lt;/td&gt;
&lt;td&gt;11,157 ms&lt;/td&gt;
&lt;td&gt;2.5 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;laya-typed-decisions&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;584 ms&lt;/td&gt;
&lt;td&gt;2,819 ms&lt;/td&gt;
&lt;td&gt;6,031 ms&lt;/td&gt;
&lt;td&gt;35,653 ms&lt;/td&gt;
&lt;td&gt;0.5 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things stand out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The multilingual checkpoint is about 3x faster on CPU.&lt;/strong&gt; It is built on mmBERT-base (322M parameters) rather than ModernBERT-large (421M). The upstream write-up does not break down where the rest of the gap comes from, so treat 3x as a measured result on this machine, not a rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The p95 is almost the same as the p50.&lt;/strong&gt; On an otherwise idle server, CPU latency was very predictable. In our reading, that makes capacity planning simpler than on a shared GPU.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why batching does not help on CPU
&lt;/h2&gt;

&lt;p&gt;Up to 10 questions per call, each extra question costs about &lt;strong&gt;600 ms&lt;/strong&gt; on the English and typed-decisions checkpoints and about &lt;strong&gt;185 ms&lt;/strong&gt; on multilingual. At 50 questions the cost per question rises by another 15 to 20%. In other words, ten questions in one call take roughly as long as ten separate calls.&lt;/p&gt;

&lt;p&gt;GPUs behave differently:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;hardware&lt;/th&gt;
&lt;th&gt;1 question&lt;/th&gt;
&lt;th&gt;50 questions&lt;/th&gt;
&lt;th&gt;cost per extra question&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tesla T4, &lt;code&gt;laya&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;39.5 ms&lt;/td&gt;
&lt;td&gt;771.3 ms&lt;/td&gt;
&lt;td&gt;about 15 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NVIDIA GB10, &lt;code&gt;laya-typed-decisions&lt;/code&gt; (over HTTP)&lt;/td&gt;
&lt;td&gt;100.2 ms&lt;/td&gt;
&lt;td&gt;443.1 ms&lt;/td&gt;
&lt;td&gt;about 7 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EPYC 4-core CPU, &lt;code&gt;laya&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;580 ms&lt;/td&gt;
&lt;td&gt;35,969 ms&lt;/td&gt;
&lt;td&gt;about 600 ms up to 10 questions, more beyond&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On the GB10, roughly 93 ms of every call is fixed overhead, so packing questions into one call is where the speedup is. On CPU there is almost no fixed overhead to amortize, so the design choice is simpler: ask only the questions you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thread settings: the easiest 12x
&lt;/h2&gt;

&lt;p&gt;The upstream project also reports a laptop measurement (Ryzen 9 6900HX, WSL2) that is worth copying before anything else. With torch's default thread settings on a busy host (10 intra-op and 5 inter-op threads on 10 vCPUs), a three-question call over HTTP took &lt;strong&gt;9,396 ms&lt;/strong&gt; at p50. Setting two lines brought it to &lt;strong&gt;783 ms&lt;/strong&gt;, about 12x faster with no code change:&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="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_num_threads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# about the number of physical cores
&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_num_interop_threads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# one forward pass per call: nothing to overlap
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the same laptop, one question in-process took 910 ms with 1 thread, 374 ms with 4, &lt;strong&gt;329 ms with 8&lt;/strong&gt;, and got worse again at 388 ms when every vCPU was used. The upstream advice is to use the physical core count plus a little, not one thread per vCPU, because SMT siblings contend. If you run the self-hosted server, &lt;code&gt;LAYA_THREADS&lt;/code&gt; caps the same setting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cold starts and memory
&lt;/h2&gt;

&lt;p&gt;A cold load took 4.4 s for the English checkpoint and 2.5 s for multilingual on the EPYC machine. These figures depend on the OS file cache, so treat them as approximate. Two practical consequences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Preload&lt;/strong&gt; the checkpoints you serve (&lt;code&gt;Router(preload=True)&lt;/code&gt;) instead of loading on the first request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget memory.&lt;/strong&gt; The benchmark script peaked at 9.3 GiB with up to five checkpoints loaded at once. Serving fewer checkpoints should need less, but the upstream run does not report a per-checkpoint figure, so measure on your own machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When is a CPU enough?
&lt;/h2&gt;

&lt;p&gt;This table is our interpretation of the numbers above, not a benchmark result. It assumes one question per call:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;your situation&lt;/th&gt;
&lt;th&gt;CPU is fine?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Background jobs, queues, nightly batch classification&lt;/td&gt;
&lt;td&gt;Yes. Latency rarely matters; cost does.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interactive routing or triage in non-English text&lt;/td&gt;
&lt;td&gt;Usually. &lt;code&gt;laya-multilingual&lt;/code&gt; at about 0.2 s is fast enough for many UIs.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interactive English decisions with several questions per request&lt;/td&gt;
&lt;td&gt;Borderline. Five questions on the English checkpoint take about 3 s.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;High-throughput, low-latency serving&lt;/td&gt;
&lt;td&gt;Use a GPU. A T4 answers one question in 32.8 to 39.5 ms.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are single-process, in-process numbers. Real deployments add HTTP, queuing, and concurrency effects, so benchmark your own hardware with your own questions before committing. The upstream script is &lt;code&gt;research/scripts/bench_latency.py&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/NandhaKishorM/laya/blob/main/BENCHMARKS.md" rel="noopener noreferrer"&gt;Laya BENCHMARKS.md&lt;/a&gt;: server CPU, laptop CPU, T4, and GB10 sections&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/NandhaKishorM/laya/blob/main/research/results/latency_cpu_m7a_xlarge_20260924.json" rel="noopener noreferrer"&gt;Raw EPYC results&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://laya-ai.com/benchmarks" rel="noopener noreferrer"&gt;Laya benchmarks tracker&lt;/a&gt;: upstream and independent results with their test conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Last verified: September 25, 2026.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I maintain &lt;a href="https://laya-ai.com" rel="noopener noreferrer"&gt;laya-ai.com&lt;/a&gt;, an independent Laya resource site; this article first appeared there. It was drafted with AI assistance, and every number was checked against the upstream benchmark files linked above.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>performance</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
