<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://thakicloud.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://thakicloud.github.io/" rel="alternate" type="text/html" /><updated>2026-06-24T14:54:21+09:00</updated><id>https://thakicloud.github.io/feed.xml</id><title type="html">Thaki Cloud Tech Blog | ThakiCloud | 다키클라우드 기술 블로그</title><subtitle>Thaki Cloud (ThakiCloud, 다키클라우드, thaki cloud, THAKI CLOUD, ثاكي كلاود)는 AI/ML Engineering, LLMOps, DevOps 분야의 최신 기술과 실무 경험을 공유하는 전문 기술 블로그입니다. 머신러닝 모델 운영, 쿠버네티스, 클라우드 인프라, AI 엔지니어링 커리어, 인공지능 기술 블로그, 다키클라우드 개발 팀의 깊이 있는 인사이트를 제공합니다. مدونة تقنية متخصصة في هندسة الذكاء الاصطناعي والحوسبة السحابية.</subtitle><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><entry xml:lang="ar"><title type="html">محاكيات أندرويد داخل حاويات - بناء مزرعة أجهزة قابلة للتكرار على Kubernetes باستخدام docker-android</title><link href="https://thakicloud.github.io/ar/dev/docker-android-k8s-emulator/" rel="alternate" type="text/html" title="محاكيات أندرويد داخل حاويات - بناء مزرعة أجهزة قابلة للتكرار على Kubernetes باستخدام docker-android" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/dev/docker-android-k8s-emulator</id><content type="html" xml:base="https://thakicloud.github.io/ar/dev/docker-android-k8s-emulator/"><![CDATA[<pre><code class="language-mermaid">flowchart LR
    subgraph NODE["عقدة K8s مع KVM / Pod"]
      EMU["محاكي Android (QEMU + KVM، اختياري CUDA)"]
      KVM["/dev/kvm"]
    end
    KVM --&gt;|passthrough| EMU
    EMU --&gt; SVC["خدمة ADB"]
    SVC --&gt; CI["مزرعة CI"]
    SVC --&gt; SCRCPY["تحكم scrcpy عن بُعد"]
</code></pre>
<h2 id="نظرة-عامة">نظرة عامة</h2>

<p>اختبار تطبيق موبايل يستلزم أجهزة أندرويد. إدارة أسطول من الأجهزة الحقيقية عبء صيانة مُضنٍ، وتثبيت محاكٍ ثقيل على كل جهاز مطوّر يُفضي إلى اختلاف البيئات وضعف قابلية التكرار. تتضاعف هذه المشكلة حين تُريد إدراج اختبارات أندرويد في خط CI، إذ يحتاج كل عقدة بناء إلى إعداد محاكٍ متسق.</p>

<p>يحل <code class="language-plaintext highlighter-rouge">docker-android</code> (إصدار HQarroum) هذه المشكلة بالحاويات. يُغلّف محاكي أندرويد بتهيئة بسيطة، ويُشغّله بلا واجهة رسومية، ويُتيح ADB والتحكم بالشاشة عبر الشبكة. حاوية واحدة توفر بيئة أندرويد نظيفة ومتسقة في ثوانٍ، مما يجعلها مناسبة تماماً لـ CI/CD والاختبارات الآلية.</p>

<p>يتحقق هذا المقال من بنية docker-android ومتطلباته الفعلية وفق التوثيق، ثم يستعرض كيف تتعامل منصة Kubernetes مثل ThakiCloud مع هذا النوع من أحمال عمل الأجهزة. محاكاة أندرويد ليست في صميم منصتنا للذكاء الاصطناعي، لكن السؤال حول عزل الحاويات ذات الامتيازات التي تحتاج KVM passthrough وتسريع GPU يتقاطع مباشرة مع قدرات بنيتنا التحتية.</p>

<hr />

<h2 id="ما-هو-docker-android">ما هو docker-android</h2>

<p>يجمع docker-android الخاص بـ HQarroum بين محاكي أندرويد ودعم KVM و JRE 11 في صورة مدمجة مبنية على Alpine (الإصدار الحالي 1.1.0). النية التصميمية واضحة: كشف محاكي أندرويد كامل يمكن التحكم به عن بُعد بأقل بصمة برمجية ممكنة. تحتوي الصورة على المحاكي نفسه، وخادم ADB للوصول الخارجي، وQEMU مع libvirt.</p>

<p>الخصائص الرئيسية:</p>

<ul>
  <li><strong>بصمة بسيطة</strong>: مبنية على Alpine لتحسين الحجم. البناء بدون SDK أو محاكٍ ينتج صورة أصغر بكثير.</li>
  <li><strong>قابلية التخصيص</strong>: إصدار أندرويد ونوع الجهاز ونوع الصورة كلها قابلة للاختيار.</li>
  <li><strong>توجيه المنافذ مدمج</strong>: يُكشف المحاكي و ADB عبر واجهة شبكة الحاوية.</li>
  <li><strong>بلا واجهة رسومية</strong>: لا تحتاج إلى GUI، مما يجعلها مناسبة لمزارع CI. يمكن الوصول إلى الشاشة عن بُعد عبر <a href="https://github.com/Genymobile/scrcpy">scrcpy</a>.</li>
  <li><strong>قابلية التكرار</strong>: تُعاد صورة المحاكي إلى حالتها الأصلية عند كل إعادة تشغيل، فكل تشغيل يبدأ من حالة متطابقة.</li>
</ul>

<p>يُوضح الرسم البياني أعلاه نشراً افتراضياً لهذه الحاوية على ThakiCloud Kubernetes. يعمل المحاكي في pod على عقدة مُفعَّل فيها KVM مع تمرير <code class="language-plaintext highlighter-rouge">/dev/kvm</code>، ويُستخدم المتغير cuda حين يُحتاج تسريع GPU. يُكشف ADB كـ Service ليصل إليه مزرعة CI و scrcpy.</p>

<hr />

<h2 id="التثبيت-والتكامل">التثبيت والتكامل</h2>

<p>يجمع البناء الافتراضي Android SDK وأدوات المنصة والمحاكي في الصورة. تشغيل كل شيء باستخدام docker-compose:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># المحاكي الأساسي</span>
docker compose up android-emulator

<span class="c"># تسريع GPU</span>
docker compose up android-emulator-cuda

<span class="c"># تسريع GPU + Google Play Store</span>
docker compose up android-emulator-cuda-store
</code></pre></div></div>

<p>يمكن البناء مباشرة باستخدام Docker:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker build <span class="nt">-t</span> android-emulator <span class="nb">.</span>
</code></pre></div></div>

<p>بعد بناء الصورة، شغّل الحاوية مع تثبيت محرك KVM. استخدام صورة Play Store يستلزم مشاركة المحاكي والعميل لنفس <code class="language-plaintext highlighter-rouge">adbkey</code>؛ أنشئه بـ <code class="language-plaintext highlighter-rouge">adb keygen adbkey</code> وضعه في مجلد <code class="language-plaintext highlighter-rouge">./keys</code>.</p>

<p>يتباين حجم الصورة تبايناً كبيراً حسب متغير البناء. جدول المقارنة من توثيق المستودع:</p>

<table>
  <thead>
    <tr>
      <th>متغير البناء</th>
      <th>غير مضغوط</th>
      <th>مضغوط</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>API 33 + المحاكي</td>
      <td>5.84 GB</td>
      <td>1.97 GB</td>
    </tr>
    <tr>
      <td>API 32 + المحاكي</td>
      <td>5.89 GB</td>
      <td>1.93 GB</td>
    </tr>
    <tr>
      <td>API 28 + المحاكي</td>
      <td>4.29 GB</td>
      <td>1.46 GB</td>
    </tr>
    <tr>
      <td>بدون SDK أو محاكٍ</td>
      <td>414 MB</td>
      <td>138 MB</td>
    </tr>
  </tbody>
</table>

<p>الصور التي تتضمن المحاكي تتجاوز 1.5 GB حتى بعد الضغط. عند التوزيع على عقد كثيرة، يجب مراعاة عرض نطاق السجل وسعة قرص العقد.</p>

<hr />

<h2 id="التحقق-من-السلوك-الفعلي">التحقق من السلوك الفعلي</h2>

<p>لم يشمل هذا المقال التحقق من إقلاع الحاوية فعلياً. تسجيل أمين: فشل التحقق هنا (لا يوجد Docker daemon على المضيف، وmacOS لا يوفر <code class="language-plaintext highlighter-rouge">/dev/kvm</code>). يتطلب docker-android تسريع KVM للأجهزة، لذا التشغيل الفعلي ممكن فقط على مضيف Linux أو عقدة KVM تدعم المحاكاة الافتراضية المتداخلة.</p>

<p>ما أمكن التحقق منه استُقي مباشرة من توثيق المستودع. جدول مقارنة أحجام الصور أعلاه يعكس أرقاماً مُصرَّحاً بها في التوثيق؛ متغيرات البناء وأسماء خدمات compose ومتطلبات تثبيت KVM كلها مستندة إلى التوثيق. أرقام كوقت الإقلاع أو معدل معالجة الاختبارات التي لم نقسها لم نُدرجها. عند النشر الفعلي، بعد توفير عقد KVM، الإجراء الصحيح هو قياس وقت إقلاع الحاوية وزمن استجابة ADB والحد الأقصى لعدد المحاكيات المتزامنة مباشرة.</p>

<hr />

<h2 id="الآثار-على-منصة-thakicloud-k8s-aiml-saas">الآثار على منصة ThakiCloud K8s AI/ML SaaS</h2>

<p>docker-android ليس أداة ذكاء اصطناعي في حد ذاتها. لكن المتطلبات التشغيلية التي يكشف عنها تتقاطع بدقة مع ما تُتقنه ThakiCloud.</p>

<p>أولاً، <strong>عزل أحمال عمل مرور الأجهزة</strong>. المحاكي حاوية ذات امتيازات في جوهرها تتطلب <code class="language-plaintext highlighter-rouge">/dev/kvm</code>. تشغيل هذا النوع من أحمال العمل بأمان في بيئة Kubernetes متعددة المستأجرين يستلزم اختيار العقد بعناية والمكوّنات الإضافية للأجهزة وسياقات الأمان. تُجهّز ThakiCloud بالفعل وحدات GPU عبر مكوّنات الأجهزة الإضافية وKueue؛ يمكن التعامل مع KVM passthrough بالنمط ذاته.</p>

<p>ثانياً، <strong>مزارع الاختبار القابلة للتكرار</strong>. تغليف المحاكيات عديمة الواجهة الرسومية كحاويات يتيح توسيع البيئات النظيفة أفقياً عبر عدد العقد المطلوب. تشغيل اختبارات Appium UI متوازية كثيرة من خط CI/CD حالة استخدام نموذجية لجدولة وظائف Kubernetes.</p>

<p>ثالثاً، ونظرة إلى الأمد البعيد، يمتد هذا بشكل طبيعي نحو <strong>التحقق من أداء الذكاء الاصطناعي على الجهاز</strong>. التحقق من سلوك النماذج الخفيفة أو العوامل العاملة على أجهزة الموبايل على نطاق واسع يتطلب مزرعة أجهزة تنشئ بيئات أندرويد معزولة كثيرة وتُشغّل اختبارات الانحدار آلياً. هذا ليس اهتماماً محورياً لمنصتنا اليوم، لكن مع نضج قدرات تنظيم GPU والأجهزة متعددة المستأجرين لدينا، تغدو مزرعة QA للذكاء الاصطناعي على الموبايل من هذا النوع شيئاً يمكن تقديمه على البنية التحتية ذاتها.</p>

<p>باختصار، docker-android ليس منتجاً نبنيه، لكنه دراسة حالة جيدة في ترويض أحمال عمل الحاويات الثقيلة التي تجمع بين الامتياز ومرور الأجهزة وتسريع GPU على Kubernetes. هذه صورة ملموسة لقدرات تنظيم Kubernetes للأغراض العامة التي تُؤكد عليها ThakiCloud.</p>

<hr />

<h2 id="القيود-والاعتراضات">القيود والاعتراضات</h2>

<ul>
  <li><strong>اعتماديات ثقيلة</strong>: تسريع KVM للأجهزة غير قابل للتفاوض. في البيئات التي لا تدعم المحاكاة الافتراضية المتداخلة، يتدهور الأداء بشكل حاد أو لا يُقلع المحاكي أصلاً. اختيار عقدة السحابة يصبح قيداً صارماً.</li>
  <li><strong>تضخم الصورة</strong>: الصور التي تتضمن المحاكي تبلغ عدة GB حتى بعد الضغط. التوزيع عبر عقد كثيرة يُراكم تكاليف السجل والقرص.</li>
  <li><strong>البُعد عن صلة الذكاء الاصطناعي</strong>: بصراحة، هذه الأداة بعيدة عن أحمال عمل التدريب والاستدلال التي تمثل صميم منصتنا. للمؤسسات التي ليس لديها طلب اختبار موبايل، القيمة المباشرة محدودة. قيمة هذا المقال ليست في “المحاكي بحد ذاته” بل في “أنماط تشغيل حاويات مرور الأجهزة”.</li>
  <li><strong>أمن الحاويات ذات الامتيازات</strong>: الوصول إلى <code class="language-plaintext highlighter-rouge">/dev/kvm</code> وإعدادات الامتياز تُعقّد حدود أمان المستأجرين المتعددين. الحفاظ على عزل المستأجرين يستلزم مجمّعات عقد مخصصة وسياسات صارمة.</li>
</ul>

<p>docker-android أداة قوية لأتمتة اختبارات الموبايل، ومرجع مفيد لكيفية التعامل مع أحمال عمل الأجهزة على Kubernetes. حتى قبل اللحظة التي نحتاجها فيها مباشرة، أنماط التشغيل تستحق الإلمام بها مسبقاً.</p>

<hr />

<h2 id="المصادر">المصادر</h2>

<ul>
  <li>docker-android (HQarroum): <a href="https://github.com/HQarroum/docker-android">https://github.com/HQarroum/docker-android</a></li>
  <li>صورة Docker Hub: <code class="language-plaintext highlighter-rouge">halimqarroum/docker-android</code></li>
  <li>scrcpy (التحكم بالشاشة عن بُعد): <a href="https://github.com/Genymobile/scrcpy">https://github.com/Genymobile/scrcpy</a></li>
  <li>التغريدة الأصلية: <a href="https://x.com/hjguyhan/status/2069427245295493446">https://x.com/hjguyhan/status/2069427245295493446</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="dev" /><category term="docker" /><category term="android" /><category term="kubernetes" /><category term="kvm" /><category term="ci-cd" /><summary type="html"><![CDATA[يُغلّف docker-android محاكي أندرويد في حاوية واحدة ويُشغّله بلا واجهة رسومية. نتحقق من أحجام الصور ومتطلبات KVM وفق التوثيق الرسمي، ونستعرض كيفية تشغيل أحمال عمل مرور الأجهزة على منصة ThakiCloud Kubernetes.]]></summary></entry><entry xml:lang="ar"><title type="html">توجيه Claude Code إلى نماذجك الخاصة — بنية برمجة فعّالة التكلفة باستخدام claude-code-router</title><link href="https://thakicloud.github.io/ar/llmops/claude-code-router-onprem-routing/" rel="alternate" type="text/html" title="توجيه Claude Code إلى نماذجك الخاصة — بنية برمجة فعّالة التكلفة باستخدام claude-code-router" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/llmops/claude-code-router-onprem-routing</id><content type="html" xml:base="https://thakicloud.github.io/ar/llmops/claude-code-router-onprem-routing/"><![CDATA[<pre><code class="language-mermaid">flowchart LR
    CC["Claude Code"] --&gt; CCR["وسيط claude-code-router"]
    CCR --&gt;|default / background| GLM["Ollama Cloud · glm-5.2"]
    CCR --&gt;|think / longContext| MM["MiniMax-M2.7 (نقطة Anthropic)"]
    CCR -.-&gt;|وسم الوكيل الفرعي للبرمجة| KIMI["Ollama Cloud · kimi-k2.7-code"]
    CCR -.-&gt;|خيار محلي| VLLM["vLLM داخلي (GLM-air)"]
    AUDIT["حلقة قياس التكلفة اليومية"] --&gt;|تتحقق مقابل Sonnet| CCR
</code></pre>

<h2 id="نظرة-عامة">نظرة عامة</h2>

<p>‏Claude Code أداة برمجة وكيلية تعمل في الطرفية. افتراضياً تُرسِل الطلبات إلى واجهة Anthropic، لكن ليست كل الطلبات بالوزن نفسه. فالتلخيص الخلفي، والإكمال القصير، وتحليل السياق الطويل، والاستدلال العميق لإعادة الهيكلة تتطلب جميعها مستويات نماذج مختلفة. إذا أرسلت كل شيء إلى أغلى نموذج تتراكم التكلفة، وإذا أرسلت كل شيء إلى أرخصها تنهار الجودة.</p>

<p>يحل <code class="language-plaintext highlighter-rouge">claude-code-router</code> (واختصاراً CCR) هذه المشكلة عبر طبقة توجيه. يقف كوسيط بين Claude Code وخلفيات النماذج ويفرّع الحركة حسب نوع الطلب. هذا المقال ليس مجرد جولة مفاهيمية، بل سجل لاستدعاء ثلاثة نماذج خارجية للتحقق من سلوكها، وإصلاح المشكلات المكتشفة في الطريق (مفتاح API ميت، وتسرّب وسوم التفكير)، وأخيراً إرفاق حلقة تقيس باستمرار ما إذا كان التوجيه أرخص فعلاً من Sonnet.</p>

<p>المبدأ الحاكم، نذكره مقدّماً: <strong>كل نموذج يُوجَّه عبر CCR لا قيمة له إلا إذا كان أكثر كفاءة في التكلفة من Claude Sonnet.</strong> وإلا فإنك تخفض الجودة بينما يستمر صرف المال. لذلك لا نؤكّد، بل نقيس.</p>

<hr />

<h2 id="ما-هو-claude-code-router">ما هو claude-code-router</h2>

<p>‏CCR وسيط يتلقى طلبات بصيغة Anthropic، ويحوّلها إلى صيغة متوافقة مع OpenAI (أو غيرها)، ثم يمرّرها إلى المزوّد المُعَدّ. لا يعدّل عميل Claude Code. شغّل جلسة بـ <code class="language-plaintext highlighter-rouge">ccr code</code> فتُوجَّه حركة تلك الجلسة عبر الوسيط على <code class="language-plaintext highlighter-rouge">localhost:3456</code>.</p>

<p>أبرز الميزات:</p>

<ul>
  <li><strong>التوجيه حسب نوع الطلب</strong>: <code class="language-plaintext highlighter-rouge">default</code> و<code class="language-plaintext highlighter-rouge">background</code> و<code class="language-plaintext highlighter-rouge">think</code> و<code class="language-plaintext highlighter-rouge">longContext</code> و<code class="language-plaintext highlighter-rouge">webSearch</code>، لكلٍّ نموذج مختلف.</li>
  <li><strong>تعدّد المزوّدين</strong>: أي نقطة متوافقة مع OpenAI يمكن تسجيلها. نستخدم هنا Ollama Cloud وMiniMax.</li>
  <li><strong>المحوّلات (transformers)</strong>: يمتص المحوّل خصوصيات كل مزوّد. ومحوّل التمرير <code class="language-plaintext highlighter-rouge">Anthropic</code> لنقاط Anthropic الأصلية هو الأداة المحورية في هذا المقال.</li>
  <li><strong>التبديل الديناميكي</strong>: غيّر النموذج أثناء الجلسة بـ <code class="language-plaintext highlighter-rouge">/model provider,model</code>.</li>
</ul>

<p>إصدار CCR المُتحقَّق منه هو <code class="language-plaintext highlighter-rouge">1.0.62</code>. يقع الإعداد في <code class="language-plaintext highlighter-rouge">~/.claude-code-router/config.json</code>، ومحوره مصفوفة <code class="language-plaintext highlighter-rouge">Providers</code> وكائن <code class="language-plaintext highlighter-rouge">Router</code>.</p>

<hr />

<h2 id="ماذا-يُوجَّه--مثبَّت-على-ثلاثة-نماذج">ماذا يُوجَّه — مثبَّت على ثلاثة نماذج</h2>

<p>مجموعة النماذج ثلاثة بالضبط. فزيادة النماذج تعقّد جدول التوجيه وترفع كلفة التحقق، لذا ضيّقناها عمداً.</p>

<table>
  <thead>
    <tr>
      <th>الدور</th>
      <th>النموذج</th>
      <th>المزوّد</th>
      <th>ملاحظة</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>الأساسي (default/background)</td>
      <td><code class="language-plaintext highlighter-rouge">glm-5.2</code></td>
      <td>Ollama Cloud</td>
      <td>برمجة يومية، قوي ورخيص</td>
    </tr>
    <tr>
      <td>الاستدلال (think/longContext)</td>
      <td><code class="language-plaintext highlighter-rouge">MiniMax-M2.7</code></td>
      <td>MiniMax</td>
      <td>تفكير منفصل، كلفة منخفضة جداً لكل رمز</td>
    </tr>
    <tr>
      <td>الوكيل الفرعي للبرمجة</td>
      <td><code class="language-plaintext highlighter-rouge">kimi-k2.7-code</code></td>
      <td>Ollama Cloud</td>
      <td>للأدوار البرمجية الصعبة فقط</td>
    </tr>
  </tbody>
</table>

<p>‏<code class="language-plaintext highlighter-rouge">glm-5.2</code> هو حصان العمل؛ والاستدلال العميق والسياق الطويل فقط يذهبان إلى MiniMax، والدور البرمجي الصعب إلى Kimi.</p>

<hr />

<h2 id="التحقق--استدعينا-ولم-نفترض">التحقق — استدعينا ولم نفترض</h2>

<p>قبل كتابة أي إعداد، استدعينا النماذج الثلاثة مباشرةً. ولتجنّب اختلاق الأرقام فحصنا الاستجابات الفعلية، فظهرت ثلاث حقائق.</p>

<p><strong>أولاً، مفتاح Ollama Cloud واحد يغطي GLM وKimi معاً.</strong> أرجع كلٌّ من <code class="language-plaintext highlighter-rouge">glm-5.2</code> و<code class="language-plaintext highlighter-rouge">kimi-k2.7-code</code> رمز HTTP 200 من <code class="language-plaintext highlighter-rouge">https://ollama.com/v1</code>. فـ Ollama Cloud يجمع عائلات GLM وKimi وDeepSeek وQwen خلف مفتاح واحد.</p>

<p><strong>ثانياً، مفتاح Kimi المنفرد كان ميتاً.</strong> أرجع مفتاح Moonshot المنفرد في <code class="language-plaintext highlighter-rouge">.env</code> رمز 401 (مصادقة غير صالحة) على moonshot.ai وmoonshot.cn ونقطة Anthropic المتوافقة على حدٍّ سواء. لحسن الحظ يمكن الوصول إلى Kimi K2 عبر <code class="language-plaintext highlighter-rouge">kimi-k2.7-code</code> في Ollama Cloud، فلم يكن المفتاح الميت طريقاً مسدوداً.</p>

<p><strong>ثالثاً، اختيار نقطة MiniMax يحسم الجودة.</strong> عند الاستدعاء عبر النقطة المتوافقة مع OpenAI (<code class="language-plaintext highlighter-rouge">/v1/chat/completions</code>) يضمّن النموذج استدلاله داخل المتن بوسوم <code class="language-plaintext highlighter-rouge">&lt;think&gt;...&lt;/think&gt;</code>، وتعجز طبقة التحويل في CCR عن إزالتها فتتسرب إلى المستخدم (musistudio/claude-code-router#964). أما عند الاستدعاء عبر نقطة Anthropic الأصلية (<code class="language-plaintext highlighter-rouge">/anthropic/v1/messages</code>) فيُرجع النموذج نفسه كتلتي <code class="language-plaintext highlighter-rouge">thinking</code> و<code class="language-plaintext highlighter-rouge">text</code> نظيفتين.</p>

<p>البند الأخير علّة وجب إصلاحها لا سبباً لإسقاط MiniMax. والإصلاح مُضمَّن في الإعداد أدناه.</p>

<hr />

<h2 id="الإعداد--الأسرار-خارج-المستودع-والإعداد-كشيفرة">الإعداد — الأسرار خارج المستودع، والإعداد كشيفرة</h2>

<p>لا تُكتب المفاتيح مباشرةً في ملف الإعداد. سكربت مولِّد يقرأ <code class="language-plaintext highlighter-rouge">.env</code> في المستودع ويكتب <code class="language-plaintext highlighter-rouge">~/.claude-code-router/config.json</code>. فلا تبقى مفاتيح في المستودع، وتدوير المفتاح يعني فقط إعادة تشغيل السكربت.</p>

<p>الإعداد المُولَّد الأساسي:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"LOG"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
  </span><span class="nl">"HOST"</span><span class="p">:</span><span class="w"> </span><span class="s2">"127.0.0.1"</span><span class="p">,</span><span class="w">
  </span><span class="nl">"PORT"</span><span class="p">:</span><span class="w"> </span><span class="mi">3456</span><span class="p">,</span><span class="w">
  </span><span class="nl">"API_TIMEOUT_MS"</span><span class="p">:</span><span class="w"> </span><span class="mi">1800000</span><span class="p">,</span><span class="w">
  </span><span class="nl">"Providers"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
    </span><span class="p">{</span><span class="w">
      </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_base_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://ollama.com/v1/chat/completions"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_key"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;OLLAMA_GLM_API_KEY&gt;"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"models"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"glm-5.2"</span><span class="p">,</span><span class="w"> </span><span class="s2">"kimi-k2.7-code"</span><span class="p">],</span><span class="w">
      </span><span class="nl">"transformer"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"use"</span><span class="p">:</span><span class="w"> </span><span class="p">[[</span><span class="s2">"maxtoken"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"max_tokens"</span><span class="p">:</span><span class="w"> </span><span class="mi">16000</span><span class="w"> </span><span class="p">}]]</span><span class="w"> </span><span class="p">}</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="p">{</span><span class="w">
      </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"minimax"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_base_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://api.minimax.io/anthropic/v1/messages"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_key"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;MINIMAX_API_KEY&gt;"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"models"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"MiniMax-M2.7"</span><span class="p">],</span><span class="w">
      </span><span class="nl">"transformer"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"use"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Anthropic"</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w">
    </span><span class="p">}</span><span class="w">
  </span><span class="p">],</span><span class="w">
  </span><span class="nl">"Router"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"default"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama,glm-5.2"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"background"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama,glm-5.2"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"think"</span><span class="p">:</span><span class="w"> </span><span class="s2">"minimax,MiniMax-M2.7"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"longContext"</span><span class="p">:</span><span class="w"> </span><span class="s2">"minimax,MiniMax-M2.7"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"longContextThreshold"</span><span class="p">:</span><span class="w"> </span><span class="mi">60000</span><span class="p">,</span><span class="w">
    </span><span class="nl">"webSearch"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama,glm-5.2"</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>السطران في مزوّد MiniMax هما ما يُصلِح تسرّب التفكير. وجِّه <code class="language-plaintext highlighter-rouge">api_base_url</code> إلى مسار Anthropic الأصلي واستخدم محوّل التمرير <code class="language-plaintext highlighter-rouge">Anthropic</code>، فيستجيب MiniMax بصيغة رسائل Anthropic (كتلتا <code class="language-plaintext highlighter-rouge">thinking</code> و<code class="language-plaintext highlighter-rouge">text</code>) منذ البداية. وعند إعادة الفحص عبر الوسيط كانت كتل الاستجابة <code class="language-plaintext highlighter-rouge">["thinking", "text"]</code> بلا أي تسرّب لـ <code class="language-plaintext highlighter-rouge">&lt;think&gt;</code>.</p>

<p>نماذج الاستدلال بطيئة الإخراج، لذا جُعِلت المهلة سخية (<code class="language-plaintext highlighter-rouge">1800000ms</code>)، ويحجز <code class="language-plaintext highlighter-rouge">maxtoken</code> مساحة إخراج كي لا تستنفد نماذج مثل GLM وKimi — التي تُخرِج الاستدلال أولاً — الميزانية قبل الإجابة.</p>

<p>تُوجَّه الوكلاء الفرعيون لا بالإعداد بل بوسم في مقدمة المُوجّه. لتفويض مهمة برمجية صعبة، أضِف في مقدمة المُوجّه <code class="language-plaintext highlighter-rouge">&lt;CCR-SUBAGENT-MODEL&gt;ollama,kimi-k2.7-code&lt;/CCR-SUBAGENT-MODEL&gt;</code>.</p>

<hr />

<h2 id="أين-وكيف-تتصل">أين وكيف تتصل</h2>

<p>نقطة الاتصال واحدة. ابدأ جلسة بـ <code class="language-plaintext highlighter-rouge">ccr code</code> في مستودع عملك، فتُوجَّه حركة تلك الجلسة الرئيسية والفرعية كلها عبر الوسيط وفق الجدول أعلاه. أما <code class="language-plaintext highlighter-rouge">claude</code> الأصلي فيتصل مباشرةً بـ Anthropic، فلا يتأثر.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># توليد الإعداد ثم تشغيل الموجِّه</span>
python3 scripts/ccr/gen_ccr_config.py <span class="o">&amp;&amp;</span> ccr restart

<span class="c"># بدء جلسة موجَّهة للتكلفة (هذه هي نقطة الاتصال)</span>
ccr code

<span class="c"># بدّل النماذج حسب المهمة داخل الجلسة</span>
/model ollama,kimi-k2.7-code     <span class="c"># دور برمجي صعب</span>
/model minimax,MiniMax-M2.7      <span class="c"># دور استدلال عميق</span>
/model ollama,glm-5.2            <span class="c"># برمجة يومية</span>
</code></pre></div></div>

<p>من حيث كفاءة التكلفة، النمط المُوصى به هجين. شغّل الأعمال الكثيفة والمتكررة وغير التفاعلية (توليد الاختبارات، إعادة الهيكلة الجماعية، تحليل السجلات، الترجمة، استكشاف الكود) تحت <code class="language-plaintext highlighter-rouge">ccr code</code> لخفض التكلفة، وأبقِ الأعمال التي تتطلب حكماً (قرارات معمارية، تصحيح دقيق) على جلسة <code class="language-plaintext highlighter-rouge">claude</code> الاشتراكية الأصلية. فنقل كل شيء إلى الجلسة الموجَّهة يجعل GLM حلقتك الرئيسية، وقد يخفض الجودة في المهام الصعبة.</p>

<hr />

<h2 id="كفاءة-التكلفة--قياس-مستمر-مقابل-sonnet">كفاءة التكلفة — قياس مستمر مقابل Sonnet</h2>

<p>سبب وجود هذا الإعداد هو التكلفة. لذا بدل أن ندّعي أنه “أرخص”، نقيس.</p>

<p>الأسعار المُتحقَّق منها في 2026-06-24 (بالدولار لكل مليون رمز):</p>

<table>
  <thead>
    <tr>
      <th>النموذج</th>
      <th>الإدخال</th>
      <th>الإخراج</th>
      <th>نمط الفوترة</th>
      <th>مقابل Sonnet</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Claude Sonnet 4.6 (المرجع)</td>
      <td>$3.00</td>
      <td>$15.00</td>
      <td>لكل رمز</td>
      <td>1.0×</td>
    </tr>
    <tr>
      <td>MiniMax-M2.7</td>
      <td>$0.24</td>
      <td>$0.96</td>
      <td>لكل رمز</td>
      <td>~0.07×</td>
    </tr>
    <tr>
      <td>glm-5.2 / kimi-k2.7-code</td>
      <td>—</td>
      <td>—</td>
      <td>اشتراك $20/شهر (Pro)</td>
      <td>يعتمد على الاستخدام</td>
    </tr>
  </tbody>
</table>

<p>‏MiniMax-M2.7 نحو 7-8% من سعر Sonnet لكل رمز، فهو دوماً أرخص بفارق كبير. أما Ollama Cloud فاشتراك شهري ثابت لا تسعير لكل رمز. سعره الفعلي = <code class="language-plaintext highlighter-rouge">الرسم الشهري ÷ الرموز المستخدمة شهرياً</code>، وعند الاستخدام المنخفض يكون الرسم الثابت $20 خسارة. وبمعدل مخلوط $9/M، عليك تجاوز <strong>نحو 2.2 مليون رمز شهرياً</strong> قبل أن يتفوق على Sonnet.</p>

<p>نقطة التعادل هذه هدف قياس لا تخمين. تسجّل سجلات CCR النموذج المُوجَّه ورموز الإدخال/الإخراج لكل طلب. وسكربت قياس يجمعها، فيحسب نسبة التكلفة الفعلية إلى تكلفة Sonnet المكافئة للنماذج بالرمز، والتكلفة الشهرية المتوقّعة لـ Sonnet مقابل رسم الاشتراك للنماذج بالاشتراك. وتتراكم النتائج في ملف تاريخي لتتبّع الاتجاه، والتحسّن يعني انخفاض النسبة مع الوقت.</p>

<p>تعمل الحلقة مرة يومياً عبر launchd. ولا يكون Claude داخل الحلقة؛ بل يعمل سكربت بسيط فقط على cron، فتكون كلفة القياس نفسها صفراً. وإذا وُجِد نموذج بالرمز أغلى من Sonnet يُطلَق تنبيه إلى Slack. أما النموذج بالاشتراك دون نقطة التعادل (استخدام ناقص) فيُسجَّل دون تنبيه، تفادياً للضجيج في مرحلة الانطلاق.</p>

<p>قواعد الإجراء مرتبطة بالقياس. إذا بلغت نسبة نموذج بالرمز 1.0 أو أكثر (أغلى من Sonnet) يُزال فوراً من التوجيه. وإذا بقي نموذج بالاشتراك دون الاستخدام أشهراً، خفّض الخطة أو انقل ذلك المسار إلى نموذج رخيص بالرمز. وعند تغيّر الأسعار يكفي تحديث ملف جدول الأسعار لينعكس في التشغيل التالي.</p>

<hr />

<h2 id="منظور-منصة-thakicloud">منظور منصة ThakiCloud</h2>

<p>ينسجم نموذج التوجيه هذا طبيعياً مع البنية التي تشغّلها ThakiCloud فعلاً.</p>

<p><strong>أمن الكود.</strong> في البيئات التي لا يمكن أن يغادر فيها الكود المصدري (المالية، القطاع العام، الرعاية الصحية)، يكفي تبديل <code class="language-plaintext highlighter-rouge">default</code> في الإعداد أعلاه إلى نقطة vLLM داخلية. فتحتفظ بقابلية استخدام Claude Code بينما لا تغادر المُوجّهات والكود قط. وإعداد النماذج الخارجية هنا للتحقق من التكلفة؛ ضع خدمة GPU الداخلية في الهيكل نفسه فتحصل على النسخة المحلية.</p>

<p><strong>التحكم في التكلفة.</strong> التوجيه حسب المهمة هو توجيه حسب التكلفة. أرسِل الطلبات عالية التكرار منخفضة الصعوبة إلى نماذج رخيصة واحتفظ بالنماذج العليا للاستدلال الصعب، فتضيّق الاستخدام المكلف إلى حيث يلزم فعلاً، وتثبت حلقة القياس الأثر بالأرقام.</p>

<p><strong>السياسة كشيفرة.</strong> المزوّدون وقواعد التوجيه وجدول الأسعار ومعايير القياس كلها مُدارة كملفات نصية مُودَعة في المستودع. وتبقى المفاتيح وحدها في <code class="language-plaintext highlighter-rouge">.env</code> ويُعاد إنتاج الإعداد بمولِّد، فيُستعاد الإعداد نفسه على أي جهاز.</p>

<hr />

<h2 id="الحدود-والاعتراضات">الحدود والاعتراضات</h2>

<p>الموجِّه لا يحل كل شيء. عدة نقاط تستحق نظرة باردة.</p>

<ul>
  <li><strong>فجوة الجودة</strong>: قيمة التوجيه تتبع جودة النموذج الخلفي. فالنماذج المفتوحة لا تجاري دوماً النماذج المغلقة العليا في إعادة الهيكلة المعقدة متعددة الخطوات أو التصحيح الدقيق. ومن هنا توصية النمط الهجين.</li>
  <li><strong>موثوقية استدعاء الأدوات</strong>: يعتمد Claude Code كثيراً على استدعاء الأدوات. وقد تهتز صيغ استدعاء الأدوات عبر طبقة التحويل المتوافقة مع OpenAI، فهي آمنة لوكلاء الاستكشاف/التلخيص لكنها تستدعي توسعاً تدريجياً لوكلاء التحرير/التنفيذ.</li>
  <li><strong>فخ الاشتراك</strong>: Ollama Cloud بسعر ثابت، فالاستخدام المنخفض خسارة. ودون نقطة التعادل يكون Sonnet أرخص ببساطة. وحلقة القياس تراقب هذه النقطة بالضبط.</li>
  <li><strong>الوسيط نقطة فشل واحدة</strong>: تمر الحركة الرئيسية أيضاً عبر CCR، فإذا مات الوسيط تتوقف الجلسة. والبديل هو <code class="language-plaintext highlighter-rouge">claude</code> الأصلي.</li>
  <li><strong>فخ تأطير “المجاني”</strong>: تروّج بعض النسخ المعدّلة لإزالة القياس عن بُعد أو حواجز الأمان بوصفها “مجانية”. وهذا اتجاه لا تستطيع شركة تأييده. والقيمة التي نأخذها ليست المجانية بل التحكم — نحن من يقرّر أي طلب يذهب إلى أي نموذج، ونحن من يقيس التكلفة.</li>
</ul>

<p>في الخلاصة، CCR ليس حيلة سحرية لخفض التكلفة بل أداة تحكم في التوجيه. وحين يُدمَج مع مجموعة نماذج مُتحقَّق منها، وإصلاحات لعلل حقيقية مثل تسرّب التفكير، وقياس مستمر مقابل Sonnet، يصبح مكسباً حقيقياً على محوري الأمان والتكلفة.</p>

<hr />

<h2 id="المصادر">المصادر</h2>

<ul>
  <li>claude-code-router (musistudio): <a href="https://github.com/musistudio/claude-code-router">https://github.com/musistudio/claude-code-router</a></li>
  <li>مشكلة تسرّب تفكير MiniMax: <a href="https://github.com/musistudio/claude-code-router/issues/964">claude-code-router#964</a></li>
  <li>سعر MiniMax M2.7: <a href="https://openrouter.ai/minimax/minimax-m2.7">openrouter.ai/minimax/minimax-m2.7</a></li>
  <li>أسعار Ollama Cloud: <a href="https://ollama.com/pricing">ollama.com/pricing</a></li>
  <li>أسعار Claude API: <a href="https://platform.claude.com/docs/en/about-claude/pricing">platform.claude.com/docs pricing</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="claude-code" /><category term="model-routing" /><category term="cost-optimization" /><category term="ollama" /><category term="minimax" /><category term="on-premise" /><summary type="html"><![CDATA[توجيه حركة Claude Code عبر glm-5.2 وMiniMax-M2.7 وKimi K2 باستخدام claude-code-router. سجل عملي للتحقق من النماذج الثلاثة مباشرةً، وإصلاح تسرّب تفكير MiniMax، وبناء حلقة تتحقق باستمرار من أن كل نموذج موجَّه أرخص من Sonnet.]]></summary></entry><entry xml:lang="ar"><title type="html">ربط Claude Code بالنماذج المستضافة ذاتياً باستخدام free-claude-code: اختبار ميداني لبروكسي التوجيه بين 17 مزوداً</title><link href="https://thakicloud.github.io/ar/llmops/free-claude-code-router/" rel="alternate" type="text/html" title="ربط Claude Code بالنماذج المستضافة ذاتياً باستخدام free-claude-code: اختبار ميداني لبروكسي التوجيه بين 17 مزوداً" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/llmops/free-claude-code-router</id><content type="html" xml:base="https://thakicloud.github.io/ar/llmops/free-claude-code-router/"><![CDATA[<h2 id="نظرة-عامة">نظرة عامة</h2>

<p>Claude Code عميل برمجي قوي. غير أن بنيته القائمة على توجيه كل طلب مباشرةً إلى Anthropic API تُقيّد المؤسسات الراغبة في ضبط التكاليف أو إبقاء البيانات داخل حدودها. يعالج مشروع <code class="language-plaintext highlighter-rouge">free-claude-code</code> الذي شهد انتشاراً واسعاً مؤخراً هذه النقطة بالذات؛ إذ يُمثّل طبقة بروكسي تعترض حركة مرور Claude Code وتعيد توجيهها إلى 17 مزوداً مختلفاً. وهو مشروع مرخص بـ MIT يحمل 36.7k نجمة على GitHub و5.7k تفرع و712 إيداعاً.</p>

<p>شعار المشروع التسويقي هو “Claude Code مجاناً إلى الأبد.” يعمل النهج عبر تحويل حركة المرور نحو مزودين ذوي فئة مجانية أو منخفضة التكلفة، وهذا الإطار مبالغ فيه إلى حد ما وينطوي على منطقة رمادية من حيث شروط الخدمة. لذا يركز هذا المقال لا على زاوية “المجاني”، بل على ما يعنيه هذا الأداة للمؤسسات كـ ThakiCloud التي <strong>تخدم نماذجها الخاصة على Kubernetes وتريد ربط Claude Code ببنيتها التحتية الخاصة</strong>. النقاط الجوهرية هي أن الكود والمطالبات لا تغادر حدود المستأجر، وتختفي فواتير السحابة المحسوبة لكل رمز، ولا حاجة لتعديل جانب العميل لأن نقطة النهاية متوافقة مع Anthropic.</p>

<blockquote>
  <p>ملاحظة: ركّز المقال السابق “توجيه Claude Code إلى النماذج الداخلية - claude-code-router” على <strong>المراجحة في التكاليف</strong> بين نماذج السحابة (glm وMiniMax وKimi). يتناول هذا المقال أداةً مختلفة (<code class="language-plaintext highlighter-rouge">free-claude-code</code>)، ويعالج الاتصال بـ <strong>الخلفيات المستضافة ذاتياً (Ollama وvLLM)</strong> لا بالسحابة، إلى جانب مخاطر النشر التي كشفها هذا المسار.</p>
</blockquote>

<h2 id="ما-الذي-يفعله-هذا-الأداة">ما الذي يفعله هذا الأداة</h2>

<p><code class="language-plaintext highlighter-rouge">free-claude-code</code> خادم بروكسي محلي يستقبل الطلبات التي يرسلها Claude Code (وCodex). ميزته الجوهرية أنه <strong>يحاكي نقطة نهاية متوافقة مع Anthropic بشكل كامل</strong>. من منظور العميل، لا يمكن تمييزه عن Anthropic API الحقيقية، مما يتيح تبديل الخلفية دون تغيير سطر واحد في Claude Code.</p>

<p>الخادم مكتوب بـ FastAPI ويكشف نقاط النهاية التالية:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">/v1/messages</code> - متوافق مع Anthropic Messages API (المسار الرئيسي لـ Claude Code)</li>
  <li><code class="language-plaintext highlighter-rouge">/v1/models</code> - قائمة النماذج</li>
  <li><code class="language-plaintext highlighter-rouge">/v1/responses</code> - متوافق مع OpenAI Responses API (لـ Codex؛ يُحوَّل داخلياً إلى Messages)</li>
</ul>

<p>عند وصول طلب، يقرر <strong>موجّه النماذج</strong> أي مزود يرسل إليه الطلب، ثم يحوّل <strong>المُوحِّد</strong> كتل التفكير وأدوات الاستدعاء واستجابات الخطأ إلى الشكل الذي يتوقعه كل عميل. نظراً لاختلاف صيغ الاستجابة بين المزودين، تكمن في طبقة التوحيد هذه الصعوبة الحقيقية.</p>

<p>لنتوسع قليلاً في سبب صعوبة التوحيد: يفترض Claude Code بنية استجابة خاصة بـ Anthropic؛ فخطوات الاستدلال تأتي ككتل <code class="language-plaintext highlighter-rouge">thinking</code>، واستدعاءات الأدوات ككتل محتوى <code class="language-plaintext highlighter-rouge">tool_use</code>. لكن DeepSeek يُصدر الاستدلال كحقل منفصل، في حين تُعيد المزودين المتوافقين مع OpenAI استدعاءات الأدوات كمصفوفة <code class="language-plaintext highlighter-rouge">tool_calls</code>. المعنى واحد وهو “استُدعيت أداة”، لكن صيغة السلك تختلف في كل حالة. يجب على المُوحِّد استيعاب هذه الفوارق وضمان حصول Claude Code على استجابات بشكل متطابق بغض النظر عن الخلفية المستخدمة. يذهب مسار Codex (<code class="language-plaintext highlighter-rouge">/v1/responses</code>) خطوة أبعد بتحويل طلبات OpenAI Responses داخلياً إلى Anthropic Messages قبل مشاركة الموجّه والمُوحِّد ومحوّلات المزودين ذاتها. أي أن تحويل البروتوكول يجري في الاتجاهين — وهذا هو الفارق الجوهري بين البروكسي العكسي البسيط وبروكسي التوجيه.</p>

<p><img src="/assets/images/free-claude-code-router-diagram.png" alt="بنية توجيه free-claude-code" />
<em>الشكل 1. يستقبل بروكسي FastAPI حركة المرور المتوافقة مع Anthropic من Claude Code ويوزعها على 17 مزوداً. من منظور ThakiCloud، المسارات الجوهرية هي الخلفيات المستضافة ذاتياً على اليمين (Ollama وLM Studio وvLLM).</em></p>

<p>المزودون المدعومون 17 مزوداً. على الجانب السحابي: NVIDIA NIM وOpenRouter وGoogle AI Studio (Gemini) وDeepSeek وMistral La Plateforme وMistral Codestral وOpenCode Zen وOpenCode Go وWafer وKimi وCerebras وGroq وFireworks وZ.ai. على <strong>جانب الاستضافة الذاتية: LM Studio وllama.cpp وOllama</strong>. الثلاثة الأخيرة هي ذات الأهمية من منظور ThakiCloud. إذ يكشف Ollama وllama.cpp نقاط نهاية متوافقة مع OpenAI، مما يعني أن خادم vLLM المنشور بالطريقة ذاتها على Kubernetes يمكن ربطه بنفس الأسلوب.</p>

<p>يتحكم في توجيه الفئات عبر متغيرات البيئة. يحدد كل من <code class="language-plaintext highlighter-rouge">MODEL_OPUS</code> و<code class="language-plaintext highlighter-rouge">MODEL_SONNET</code> و<code class="language-plaintext highlighter-rouge">MODEL_HAIKU</code> أي نموذج يُوجَّه إليه كل فئة من فئات Claude الثلاث؛ وعند غياب التحديد يُستخدم النموذج الاحتياطي <code class="language-plaintext highlighter-rouge">MODEL</code>. يتيح هذا نشراً متدرجاً، كتوجيه حركة مرور Haiku الخفيفة إلى نماذج صغيرة والحركة الثقيلة من Opus إلى نماذج أكبر.</p>

<h2 id="التثبيت-والتكامل">التثبيت والتكامل</h2>

<p>مسار التثبيت الرسمي هو سطر أوامر واحد:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># macOS / Linux</span>
curl <span class="nt">-fsSL</span> <span class="s2">"https://github.com/Alishahryar1/free-claude-code/blob/main/scripts/install.sh?raw=1"</span> | sh

<span class="c"># Windows PowerShell</span>
irm <span class="s2">"https://github.com/Alishahryar1/free-claude-code/blob/main/scripts/install.ps1?raw=1"</span> | iex
</code></pre></div></div>

<p>بدلاً من سطر الأوامر، تحققت من الحزمة بتثبيتها مباشرةً في بيئة اختبار معزولة، حفاظاً على سلامة البيئة الافتراضية المشتركة وفق قواعد وقت تشغيل Python في ThakiCloud.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># شجرة عمل معزولة + venv مؤقت (البيئة المشتركة .venv على 3.12.8 وستتعارض)</span>
uv venv <span class="nt">--python</span> 3.14 .expenv
<span class="nv">VIRTUAL_ENV</span><span class="o">=</span>.expenv uv pip <span class="nb">install</span> <span class="s2">"git+https://github.com/Alishahryar1/free-claude-code.git"</span>
</code></pre></div></div>

<p>تُثبَّت الحزمة ذاتها بنظافة. تُحلّ التبعيات مثل fastapi وuvicorn وhttpx وpydantic وopenai وloguru بنجاح، وتُنشأ سكريبتات وحدة التحكم مثل <code class="language-plaintext highlighter-rouge">fcc-server</code> و<code class="language-plaintext highlighter-rouge">fcc-init</code> و<code class="language-plaintext highlighter-rouge">fcc-claude</code>. بعد تشغيل الخادم، يُوجَّه Claude Code نحو البروكسي على النحو الآتي:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>fcc-server            <span class="c"># تشغيل بروكسي FastAPI (الافتراضي http://127.0.0.1:8082)</span>
<span class="c"># مثال على خلفية مستضافة ذاتياً (Ollama):</span>
<span class="c">#   MODEL_HAIKU=ollama/llama3.2:3b</span>
<span class="c">#   MODEL_SONNET=ollama/qwen2.5:7b</span>
<span class="c"># حدد عنوان URL الأساسي لتوجيه Claude Code نحو البروكسي ثم استخدمه كالمعتاد</span>
</code></pre></div></div>

<p>واجهة الإدارة متاحة على <code class="language-plaintext highlighter-rouge">http://127.0.0.1:8082/admin</code> وتكون محدودة بحلقة الاسترداد فقط. تُدار هنا مفاتيح المزودين وتوجيه النماذج وإعدادات الرسائل والصوت.</p>

<h2 id="نتائج-التجربة-الفعلية">نتائج التجربة الفعلية</h2>

<p>خلال عملية التحقق، واجهت <strong>نقطة أعاقت إعادة الإنتاج</strong>، وأسجلها كما هي. عدم اختلاق الأرقام مبدأ راسخ في هذا التقرير.</p>

<h3 id="حاجز-التشغيل-الاشتراط-الصارم-بـ-python-314">حاجز التشغيل: الاشتراط الصارم بـ Python 3.14</h3>

<p>يُثبّت <code class="language-plaintext highlighter-rouge">free-claude-code</code> الإصدار v2.3.14 اشتراط <code class="language-plaintext highlighter-rouge">requires-python = "&gt;=3.14.0"</code> بشكل صارم. Python 3.14 هو الإصدار الأحدث الذي صدر رسمياً في أكتوبر 2025 فحسب. المشكلة أن الإصدار 3.14 الوحيد المتاح في بيئة الاختبار كان بناء ألفا (3.14.0a7). تشغيل <code class="language-plaintext highlighter-rouge">fcc-server</code> على هذا الإصدار الألفا يفشل بالخطأ التالي:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ImportError: cannot import name 'get_annotate_from_class_namespace'
from 'annotationlib'
</code></pre></div></div>

<p>يحدث هذا التعارض لأن pydantic المثبّت يتوقع واجهة <code class="language-plaintext highlighter-rouge">annotationlib</code> الخاصة بالإصدار النهائي 3.14، لكن الرمز المطلوب غير موجود بعد في الإصدار الألفا المبكر. حاولت عندئذٍ التشغيل قسراً على الإصدار المستقر الأدنى (3.13)، لكن التثبيت ذاته يُرفض بسبب الاشتراط الصارم في بيانات الحزمة:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>free-claude-code==2.3.14 cannot be used ... your requirements are unsatisfiable.
</code></pre></div></div>

<p>الخلاصة واضحة: <strong>في البيئات التي تفتقر إلى Python 3.14 المستقر، لن يعمل هذا البروكسي أبداً.</strong> فشل محاولة إعادة الإنتاج: الحزمة تشترط Python 3.14 الصادر حديثاً، لكن الإصدار 3.14 الوحيد المتاح ألفا يتعارض مع pydantic المثبّت. هذه ليست عيباً في الأداة بقدر ما هي مشكلة <strong>تثبيت إصدار متعجّل</strong> يتعارض مع واقع بيئات الإنتاج التي تبقى في الغالب على 3.11–3.12.</p>

<h3 id="القياس-المباشر-لمسار-التوجيه-المستضاف-ذاتياً">القياس المباشر لمسار التوجيه المستضاف ذاتياً</h3>

<p>رغم أن البروكسي نفسه لم يُشغَّل، فإن <strong>الآلية</strong> التي تستخدمها هذه الأداة لاستدعاء مزود <code class="language-plaintext highlighter-rouge">ollama</code> هي نقطة النهاية المتوافقة مع OpenAI. لذا قست هذا المسار باستدعاء Ollama المحلي مباشرةً. هذه أرقام أداء التوجيه للخلفية ذاتها دون تضمين الحمل الإضافي للبروكسي الذي ستضيفه fcc. نتائج تعيين فئات Claude الثلاث لنماذج محلية كالآتي (Apple Silicon، مطالبة متطابقة، حد 64 رمزاً):</p>

<p><img src="/assets/images/free-claude-code-router-results.png" alt="نتائج قياس التوجيه المستضاف ذاتياً" />
<em>الشكل 2. التأخر ومعدل المعالجة عند توجيه فئات Claude إلى نماذج Ollama المحلية. qwen3:8b المُدرج في مسار opus نموذج تفكير يُصدر رموز استدلال مطوّلة مما يزيد الوقت بشكل ملحوظ.</em></p>

<table>
  <thead>
    <tr>
      <th>التوجيه</th>
      <th>النموذج</th>
      <th>التأخر</th>
      <th>رموز الإكمال</th>
      <th>معدل المعالجة</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>haiku</td>
      <td>llama3.2:3b</td>
      <td>0.49s</td>
      <td>33</td>
      <td>67.3 tok/s</td>
    </tr>
    <tr>
      <td>sonnet</td>
      <td>qwen2.5:7b</td>
      <td>0.56s</td>
      <td>20</td>
      <td>35.7 tok/s</td>
    </tr>
    <tr>
      <td>opus</td>
      <td>qwen3:8b</td>
      <td>8.12s</td>
      <td>281</td>
      <td>34.6 tok/s</td>
    </tr>
  </tbody>
</table>

<p>النموذج الصغير (llama3.2:3b) ينهي استجابته في أقل من 0.5 ثانية، وهو سرعة كافية لحركة مرور بديلة عن Haiku. كذلك qwen2.5:7b عند 0.56 ثانية عملي للاستخدام. في المقابل، استغرق qwen3:8b المُدرج في مسار opus 8.12 ثانية، لأن نموذج التفكير يُصدر أولاً 281 رمز استدلال. معدل المعالجة (34.6 tok/s) طبيعي في حد ذاته، لكن القياس أكد أن <strong>توظيف نموذج استدلالي في فئة ثقيلة يُفجّر عدد الرموز ويزيد التأخر المُدرَك بشكل كبير</strong>. درس عملي: عند تصميم تعيينات الفئات، ينبغي مراعاة ميل النموذج لتوليد رموز الاستدلال.</p>

<h2 id="التطبيق-والدلالات-لمنصة-thakicloud-saas-للذكاء-الاصطناعيتعلم-الآلة-على-kubernetes">التطبيق والدلالات لمنصة ThakiCloud SaaS للذكاء الاصطناعي/تعلم الآلة على Kubernetes</h2>

<p>القيمة الحقيقية لهذه الأداة ليست في “المجانية” بل في <strong>نمط الاتصال</strong>. بمجرد إدراج بروكسي متوافق مع Anthropic كطبقة وسيطة، يمكن إرفاق عملاء تجاريين كـ Claude Code مباشرةً ببنيتنا التحتية.</p>

<p>تُجدول ThakiCloud وحدات GPU باستخدام Kueue وتُقدّم النماذج عبر vLLM على Kubernetes. نظراً لأن vLLM يوفر نقطة نهاية متوافقة مع OpenAI (<code class="language-plaintext highlighter-rouge">/v1/chat/completions</code>)، يمكن ربطها بمسار المزود المستضاف ذاتياً في <code class="language-plaintext highlighter-rouge">free-claude-code</code> بنفس الطريقة المتبعة مع Ollama أو llama.cpp. أسلوب الاتصال مشترك بين المزودين المستضافين ذاتياً: يُحدَّد عنوان URL الأساسي بنقطة نهاية خدمة vLLM في الكتلة، ويُضاف بادئة المزود إلى معرّف النموذج. تماماً كما تُكتب Ollama بالصيغة <code class="language-plaintext highlighter-rouge">ollama/llama3.2:3b</code>، يُضاف النموذج المُقدَّم على vLLM الداخلي لأهداف التوجيه باتباع قاعدة البادئة ذاتها. يُتيح ذلك:</p>

<ul>
  <li><strong>سيادة البيانات</strong>: لا يغادر الكود والمطالبات حدود المستأجر. هذا أمر جوهري في البيئات التنظيمية مثل النشر داخل المنشأة ومتطلبات الامتثال للأجهزة الحكومية.</li>
  <li><strong>تحوّل هيكل التكلفة</strong>: تتحوّل فوترة القياس لكل رمز إلى تكاليف GPU ثابتة. كلما ارتفع الاستخدام، تسارعت نقطة التعادل للتقديم الذاتي.</li>
  <li><strong>النشر المتدرج حسب الفئة</strong>: يمكن توجيه حركة مرور Haiku الخفيفة إلى نماذج صغيرة والأعمال الثقيلة إلى نماذج أكبر، مما يُحسّن الاستفادة من وحدات GPU. تُقدّم القياسات أعلاه الأرقام المرجعية لهذا النشر المتدرج.</li>
</ul>

<p>غير أن الأنسب بدلاً من اعتماد هذه الأداة كما هي هو <strong>استعارة نمط التوجيه المُتحقَّق منه فحسب</strong>. في بيئة متعددة المستأجرين، يجب أن يمتلك البروكسي مصادقة وعزلاً ومراقبةً لكل مستأجر، في حين تفترض واجهة إدارة <code class="language-plaintext highlighter-rouge">free-claude-code</code> مستخدماً واحداً في حلقة الاسترداد وهي قاصرة كما هي. الفكرة الكامنة في طبقة التوحيد المتوافقة مع Anthropic تستحق الاستعارة، لكن المصادقة والحصص والتسجيل يجب إعادة تطبيقها وفق معايير بوابتنا.</p>

<h2 id="القيود-والاعتراضات">القيود والاعتراضات</h2>

<p>أولاً، <strong>المنطقة الرمادية لشروط الخدمة</strong>. يعتمد إطار “Claude Code مجاناً” على التوجيه عبر مزودين ذوي فئة مجانية، مما قد يتعارض مع شروط خدمة كل منصة. في البيئات المؤسسية، الاستخدام المشروع والمستدام هو حصراً <strong>التوجيه إلى الخلفيات المملوكة (النماذج المُقدَّمة ذاتياً)</strong>. هذا هو سبب تأكيد هذا المقال على مسار الاستضافة الذاتية فحسب.</p>

<p>ثانياً، <strong>تثبيت الإصدار المتعجّل</strong>. يمنع الاشتراط الصارم بـ Python 3.14 التشغيلَ فوراً في البيئات التي تفتقر إلى وقت تشغيل مستقر كما رأينا. مع الأخذ بعين الاعتبار تكلفة ومخاطر ترقية صور حاويات الإنتاج إلى 3.14، فإن إدراج هذه الأداة مباشرةً في خط أنابيب النشر في الوقت الراهن ينطوي على عبء مفرط.</p>

<p>ثالثاً، <strong>لا يُضمن تكافؤ الجودة</strong>. استبدال Opus أو Sonnet من Claude بنماذج مختلفة لا يُبقي جودة البرمجة على حالها. التوجيه خيار يكسب فيه تكاليف أقل وسيادة بيانات مقابل التنازل عن جودة الاستجابة؛ وأي حركة مرور تُوجَّه إلى أي مكان يجب تحديده بالقياس وفق درجة صعوبة المهمة.</p>

<p>رابعاً، قياسات هذا التقرير هي <strong>أرقام استدعاء مباشر للخلفية دون المرور بالبروكسي</strong>. لا يشمل ذلك الحمل الإضافي للتوحيد والتوجيه في fcc. متى توافرت بيئة Python 3.14 المستقرة، أخطط لإعادة قياس التأخر ذهاباً وإياباً عبر البروكسي وإضافته تكملةً لهذه النتائج.</p>

<p>خلاصة القول، <code class="language-plaintext highlighter-rouge">free-claude-code</code> محفوف بالمخاطر إذا استُهلك بوصفه “اختراقاً مجانياً”، لكنه نقطة انطلاق ممتازة <strong>كمرجع مفتوح المصدر لأنماط التوجيه المتوافقة مع Anthropic</strong> عند تصميم ربط العملاء التجاريين ببنية الاستدلال المستضافة ذاتياً.</p>

<h2 id="المصادر">المصادر</h2>

<ul>
  <li>GitHub: <a href="https://github.com/Alishahryar1/free-claude-code">Alishahryar1/free-claude-code</a> (MIT, 36.7k stars, v2.3.14)</li>
  <li>بيانات القياس: استدعاءات مباشرة لنقطة النهاية المتوافقة مع OpenAI في Ollama المحلي (llama3.2:3b وqwen2.5:7b وqwen3:8b، Apple Silicon)</li>
  <li>مقال ذو صلة: مدونة ThakiCloud التقنية “توجيه Claude Code إلى النماذج الداخلية - claude-code-router”</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="free-claude-code" /><category term="Claude Code" /><category term="LLM Gateway" /><category term="Model Routing" /><category term="Ollama" /><category term="vLLM" /><category term="Self-Hosting" /><category term="FastAPI" /><category term="LLM Ops" /><summary type="html"><![CDATA[يعترض free-claude-code (36.7k نجمة) حركة مرور Claude Code عبر بروكسي FastAPI متوافق مع Anthropic ويوجهها إلى 17 مزوداً. يوثق هذا التقرير التوجيه المباشر إلى خلفية Ollama محلية مع قياسات للتأخر، ويسجل بصدق مخاطر النشر الناجمة عن اشتراط Python 3.14 بشكل صارم.]]></summary></entry><entry xml:lang="ar"><title type="html">تشغيل Gemma 4 26B بتوازي 16 ضعفاً على جهاز DGX Spark واحد: مراجعة صريحة لتقنية NVFP4 والقيمة مقابل التكلفة</title><link href="https://thakicloud.github.io/ar/owm/gemma-4-26b-nvfp4-dgx-spark/" rel="alternate" type="text/html" title="تشغيل Gemma 4 26B بتوازي 16 ضعفاً على جهاز DGX Spark واحد: مراجعة صريحة لتقنية NVFP4 والقيمة مقابل التكلفة" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/owm/gemma-4-26b-nvfp4-dgx-spark</id><content type="html" xml:base="https://thakicloud.github.io/ar/owm/gemma-4-26b-nvfp4-dgx-spark/"><![CDATA[<p>⏱️ <strong>وقت القراءة المتوقع</strong>: 12 دقيقة</p>

<p><img src="/assets/images/gemma-4-26b-nvfp4-dgx-spark-hero.png" alt="مخطط مفاهيمي للاستدلال المتوازي لـ Gemma 4 26B NVFP4" /></p>

<h2 id="نظرة-عامة">نظرة عامة</h2>

<p>أثار اهتماماً واسعاً عرضٌ تجريبي يُظهر تشغيل نموذج MoE كبير في 16 جلسة متزامنة على جهاز صغير يُوضع على المكتب. يتعلق الأمر بنموذج <code class="language-plaintext highlighter-rouge">Gemma-4-26B-A4B-NVFP4</code> الذي أصدرته NVIDIA، إذ يعمل على جهاز DGX Spark واحد (128 جيجابايت من الذاكرة الموحدة) بتوازي 16 ضعفاً، محققاً نحو 18 رمزاً في الثانية لكل تدفق وما يزيد على 300 رمز في الثانية إجمالاً. وقد أشار صاحب العرض إلى أن التزامن العالي جداً جعل من الصعب إظهاره بصرياً فاضطر إلى تقديمه برمجياً، مؤكداً إمكانية الوصول إلى 32 ضعفاً وأن flashinfer لم تُطبق بعد في هذه المرحلة.</p>

<p>ثمة نقطتان جوهريتان نود تسليط الضوء عليهما. الأولى: هذا ليس نموذجاً خفيف الوزن من نوع E2B أو E4B يعمل على الحواسيب المحمولة، بل هو <strong>نموذج Gemma MoE كبير</strong> يبلغ مجموع معاملاته 25.2 مليار معامل. الثانية: ما يجعل هذا ممكناً هو التقاء ثلاثة عوامل: <strong>تكميم NVFP4 رباعي البت، وصغر المعاملات النشطة في MoE، وسعة الذاكرة الموحدة الكبيرة في DGX Spark</strong>.</p>

<p>تُدير ThakiCloud منصة لتقديم نماذج اللغة الكبيرة بصورة متعددة المستأجرين فوق Kubernetes. لذا فإن سؤال “كم طلباً متزامناً يمكن استقباله على جهاز خاص صغير واحد؟” ليس مجرد عرض مثير للاهتمام، بل هو سؤال مباشر يتعلق بنموذج التكلفة. يُرتب هذا المقال الحقائق التقنية للنموذج، ويفصل بين أداء التدفق المفرد والتزامن، ويناقش بصدق ما إذا كان DGX Spark يوفر قيمة حقيقية مقارنة بوحدات Blackwell الأخرى، فضلاً عن تحديد مدى صلاحية هذا النموذج لمنظومة المهارات لدينا.</p>

<h2 id="ما-الذي-قدمه-العرض-التجريبي">ما الذي قدمه العرض التجريبي؟</h2>

<p>يمكن تلخيص ادعاءات العرض الأصلي (<a href="https://x.com/googlegemma/status/2069452783523401804">تغريدة فريق Google Gemma</a>) على النحو التالي:</p>

<ul>
  <li>الجهاز: <strong>جهاز DGX Spark واحد، ذاكرة موحدة 128 جيجابايت (GB10 Grace-Blackwell)</strong></li>
  <li>النموذج: <a href="https://huggingface.co/nvidia/Gemma-4-26B-A4B-NVFP4"><code class="language-plaintext highlighter-rouge">nvidia/Gemma-4-26B-A4B-NVFP4</code></a></li>
  <li>التزامن: <strong>16 ضعفاً متوازياً</strong>، بمعدل <strong>نحو 18 رمزاً/ثانية</strong> لكل تدفق و<strong>نحو 300 رمز/ثانية</strong> إجمالاً</li>
  <li>قابلية التوسع: ممكنة حتى <strong>32 ضعفاً</strong>، لكنه عُرض بـ 16 ضعفاً لاعتبارات وضوح الشاشة</li>
  <li>هامش التحسين: <strong>flashinfer لم تُطبق بعد</strong>، مما يعني إمكانية تحسين الأداء لاحقاً</li>
</ul>

<p>نوضح هنا نقطة يسهل إساءة فهمها: “18 رمزاً/ثانية لكل تدفق” هي القيمة عند تشغيل 16 تدفقاً متزامناً، وتدفق واحد وحيد يعطي أداءً أسرع. سيتم تناول المقايضة بين التزامن والتأخير المفرد بالأرقام الفعلية في قسم لاحق.</p>

<h2 id="الحقائق-التقنية-لنموذج-gemma-4-26b-a4b-nvfp4">الحقائق التقنية لنموذج Gemma-4-26B-A4B-NVFP4</h2>

<p>النموذج الذي رفعته NVIDIA هو نسخة مُكممة بتقنية NVFP4 من نموذج <code class="language-plaintext highlighter-rouge">gemma-4-26B-A4B-it</code> الخاص بـ Google DeepMind، وذلك باستخدام NVIDIA Model Optimizer. المواصفات الرئيسية وفقاً لبطاقة النموذج:</p>

<table>
  <thead>
    <tr>
      <th>العنصر</th>
      <th>القيمة</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>النموذج الأساسي</td>
      <td>google/gemma-4-26B-A4B-it</td>
    </tr>
    <tr>
      <td>البنية</td>
      <td>Mixture-of-Experts (Transformer)</td>
    </tr>
    <tr>
      <td>إجمالي المعاملات</td>
      <td>25.2 مليار</td>
    </tr>
    <tr>
      <td>المعاملات النشطة</td>
      <td>3.8 مليار (لكل رمز)</td>
    </tr>
    <tr>
      <td>تكوين الخبراء</td>
      <td>8 من أصل 128 نشطون + خبير مشترك واحد</td>
    </tr>
    <tr>
      <td>عدد الطبقات</td>
      <td>30</td>
    </tr>
    <tr>
      <td>طول السياق</td>
      <td>256 ألف رمز</td>
    </tr>
    <tr>
      <td>نافذة الانزلاق</td>
      <td>1024 رمز</td>
    </tr>
    <tr>
      <td>أنماط الإدخال</td>
      <td>نص + صورة</td>
    </tr>
    <tr>
      <td>التكميم</td>
      <td>NVFP4 (Model Optimizer v0.43.0)</td>
    </tr>
    <tr>
      <td>الجهاز المستهدف</td>
      <td>NVIDIA Blackwell</td>
    </tr>
    <tr>
      <td>الرخصة</td>
      <td>Apache 2.0</td>
    </tr>
  </tbody>
</table>

<h3 id="ما-هو-nvfp4-ولماذا-يستلزم-blackwell">ما هو NVFP4 ولماذا يستلزم Blackwell؟</h3>

<p>NVFP4 هو تنسيق نقطة عائمة رباعي البت تُعجله NVIDIA بالجهاز في جيل Blackwell. خلافاً لتكميم INT4 الذي يقطع الأوزان إلى أعداد صحيحة رباعية البت فحسب، يعتمد NVFP4 على مقياس FP8 لكل كتلة صغيرة (micro-scaling)، مما يتيح تقليص الذاكرة المعادل لأربعة بتات مع الحفاظ على دقة عالية.</p>

<p>يظهر الأثر بوضوح في متطلبات الذاكرة: تحميل 25.2 مليار معامل بتنسيق BF16 يتطلب نحو 50 جيجابايت، بينما يُقلص NVFP4 الأوزان إلى <strong>14-16 جيجابايت</strong> تقريباً. في DGX Spark بذاكرته الموحدة البالغة 128 جيجابايت، يعني الاحتفاظ بالأوزان في 16 جيجابايت أن ما يزيد على 100 جيجابايت تبقى متاحة بالكامل لذاكرة التخزين المؤقت KV Cache. هذا الهامش الواسع هو ما يتيح التزامن من 16 إلى 32 ضعفاً واستيعاب سياقات طويلة تصل إلى 256 ألف رمز.</p>

<p>غير أن تسريع جهاز NVFP4 مقصور على Blackwell حصراً. الأجيال السابقة كـ Hopper (H100) وAda (RTX 4090) تفتقر إلى مسار Tensor Core الخاص بـ NVFP4، مما يعني عدم الاستفادة الكاملة من هذا التنسيق. بمعنى آخر، هذا النموذج مبني عملياً “للتشغيل على Blackwell”.</p>

<h3 id="المعايير-القياسية-هل-خسارة-الدقة-في-nvfp4-مقبولة">المعايير القياسية: هل خسارة الدقة في NVFP4 مقبولة؟</h3>

<p>تقدم بطاقة النموذج مقارنة جنباً إلى جنب بين نسخة NVFP4 والنموذج الأساسي غير المُكمم:</p>

<table>
  <thead>
    <tr>
      <th>المعيار</th>
      <th>NVFP4</th>
      <th>الأساس</th>
      <th>المجال</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>AIME 2025</td>
      <td>90.00%</td>
      <td>88.95%</td>
      <td>الرياضيات التنافسية</td>
    </tr>
    <tr>
      <td>MMLU Pro</td>
      <td>84.80%</td>
      <td>85.00%</td>
      <td>المعرفة العامة والاستدلال</td>
    </tr>
    <tr>
      <td>IFBench</td>
      <td>78.1%</td>
      <td>77.77%</td>
      <td>اتباع التعليمات</td>
    </tr>
    <tr>
      <td>GPQA Diamond</td>
      <td>79.90%</td>
      <td>80.30%</td>
      <td>الاستدلال العلمي</td>
    </tr>
  </tbody>
</table>

<p>جميع المعايير الأربعة في فارق أقل من 1% مقارنة بالأساس. تتفوق نسخة NVFP4 قليلاً في AIME وIFBench، لكن يُفضل قراءة هذا الفارق باعتباره ضمن نطاق التشتت القياسي. الخلاصة: “ضغط الأوزان إلى أربعة بتات يحافظ على الجودة فعلياً”، وهذا ما يُميز NVFP4 عن INT4. مع ذلك، يُنصح بإجراء تقييم مستقل على مجموعات بيانات المهام العربية وغيرها من اللغات، إذ لا تظهر هذه في المعايير العامة المنشورة.</p>

<h2 id="الأداء-الفعلي-التدفق-المفرد-مقابل-التزامن">الأداء الفعلي: التدفق المفرد مقابل التزامن</h2>

<p>قد تُوهم “18 رمزاً/ثانية لكل تدفق” في العرض بالبطء. الفصل بين التدفق المفرد والتزامن ضروري. بالاستناد إلى تقارير المجتمع من قياسات على DGX Spark:</p>

<ul>
  <li><strong>التدفق المفرد الأساسي</strong>: نحو 32 رمزاً/ثانية (بدون MTP، بإعداد 64 ألف رمز)</li>
  <li><strong>التدفق المفرد + MTP (التنبؤ بعدة رموز)</strong>: نحو <strong>55-61 رمزاً/ثانية</strong> (بإعداد 32 ألف رمز، أعلى أداء للاستجابات القصيرة إلى المتوسطة و JSON المنظم)</li>
  <li><strong>16 تدفقاً متزامناً</strong>: نحو 18 رمزاً/ثانية لكل تدفق و<strong>نحو 300 رمز/ثانية</strong> إجمالاً</li>
  <li><strong>معالجة السياق الطويل</strong>: نحو 11.9 ثانية لمدخل 25 ألف رمز، ونحو 28.6 ثانية لمدخل 50 ألف رمز (بإعداد 64 ألف رمز)</li>
</ul>

<p>تبرز هنا حقيقتان:</p>

<p>الأولى: <strong>فك ترميز MoE محدود بالنطاق الترددي للذاكرة</strong>. صحيح أن المعاملات النشطة لكل رمز تبلغ 3.8 مليار فقط مما يُقلل العمليات الحسابية (FLOPs)، لكن كل رمز يتطلب قراءة أوزان الخبراء النشطين من الذاكرة. النطاق الترددي لذاكرة LPDDR5X الموحدة في DGX Spark أدنى من HBM في مراكز البيانات، وهذا ما يُفسر سبب كون سرعة التدفق المفرد “متحفظة لجهاز Blackwell”. فائض قدرة FP4 الحسابية يصطدم بسقف النطاق الترددي.</p>

<p>الثانية: <strong>القوة الحقيقية لهذا الجهاز ليست في التأخير المفرد بل في الإنتاجية المتزامنة</strong>. الحصول على 300 رمز/ثانية إجمالاً مع تشغيل 16 ضعفاً يعني أن طلبات متعددة تتشارك النطاق الترددي معاً لرفع الكفاءة. الهامش الواسع للذاكرة الموحدة يتيح KV Cache سخياً، وهذا ما يُمكن هذا السيناريو. باختصار: الجهاز مُصمم لـ “استجابات كافية لعدة وكلاء ومستخدمين في آن واحد” لا لـ “استجابة سريعة لشخص واحد”.</p>

<pre><code class="language-mermaid">flowchart LR
    subgraph Spark["DGX Spark · 128GB Unified Memory"]
      W["NVFP4 Weights&lt;br/&gt;~16GB"]
      KV["KV Cache Pool&lt;br/&gt;~100GB+ headroom"]
    end
    R1["Request 1"] --&gt; Spark
    R2["Request 2"] --&gt; Spark
    R3["..."] --&gt; Spark
    R16["Request 16"] --&gt; Spark
    Spark --&gt; O["~18 tok/s per stream&lt;br/&gt;~300 tok/s total"]
</code></pre>

<h2 id="مراجعة-صريحة-1-هل-يوفر-dgx-spark-قيمة-حقيقية-مقابل-التكلفة">مراجعة صريحة 1: هل يوفر DGX Spark قيمة حقيقية مقابل التكلفة؟</h2>

<p>الخلاصة المباشرة: <strong>“قيمة استثنائية من حيث السعة التخزينية للجيجابايت، وقيمة متوسطة من حيث التأخير لكل رمز”</strong>. حتى ضمن جيل Blackwell الواحد، تتباين طبيعة كل شريحة.</p>

<table>
  <thead>
    <tr>
      <th>الشريحة</th>
      <th>السعر (دولار)</th>
      <th>الذاكرة</th>
      <th>النطاق الترددي</th>
      <th>حالة NVFP4 MoE (يونيو 2026)</th>
      <th>الطابع</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>DGX Spark</strong> (GB10, SM121)</td>
      <td>نحو $4,699</td>
      <td>128 جيجابايت LPDDR5X موحدة</td>
      <td>273 جيجابايت/ث</td>
      <td>✅ يعمل (vLLM Marlin backend)</td>
      <td>ذاكرة كبيرة وتزامن عالٍ، نطاق ترددي أدنى</td>
    </tr>
    <tr>
      <td><strong>RTX 5090</strong> (SM120)</td>
      <td>نحو $2,000 [تقديري]</td>
      <td>32 جيجابايت GDDR7</td>
      <td>1,792 جيجابايت/ث</td>
      <td>⚠️ غير مستقر حالياً (flashinfer #2577)</td>
      <td>أعلى إمكانية لتكلفة الرمز، ذاكرة VRAM محدودة</td>
    </tr>
    <tr>
      <td><strong>RTX PRO 6000</strong> Blackwell (SM120)</td>
      <td>نحو $8,500</td>
      <td>96 جيجابايت GDDR7</td>
      <td>1,792 جيجابايت/ث</td>
      <td>⚠️ نفس مشكلة SM120</td>
      <td>ذاكرة VRAM كبيرة، مبالغ فيه لهذا النموذج</td>
    </tr>
    <tr>
      <td><strong>B200</strong> (SM100، مراكز البيانات)</td>
      <td>سحابة نحو $3-10/ساعة [تقديري]</td>
      <td>192 جيجابايت HBM3e</td>
      <td>8,000 جيجابايت/ث</td>
      <td>✅ دعم كامل (TRT-LLM/flashinfer)</td>
      <td>أعلى أداء، فارق كبير في التكلفة</td>
    </tr>
  </tbody>
</table>

<p>أهم خانة في هذا الجدول ليست السعر بل <strong>“حالة NVFP4 MoE”</strong>، لأنها حيث تنفصل الحسابات النظرية عن الواقع.</p>

<ul>
  <li><strong>نظرياً، RTX 5090 هو الأكثر كفاءة من حيث التكلفة لكل رمز.</strong> نطاقه الترددي يبلغ 6.6 أضعاف DGX Spark (1,792 مقابل 273 جيجابايت/ث)، وفك ترميز MoE يعتمد على النطاق الترددي، مما يعني أن السقف النظري يتبع هذه النسبة مباشرة. قراءة 16 جيجابايت من الأوزان بـ 273 جيجابايت/ث تُعطي نظرياً نحو 170 رمزاً/ثانية، بينما بـ 1,792 جيجابايت/ث تصل إلى نحو 1,100 رمز/ثانية. والسعر هو نصف الثمن، فالحساب البسيط يُرجح الـ 5090 بمقدار 5 إلى 6 أضعاف.</li>
  <li><strong>لكن في الواقع، نواة NVFP4 MoE معطوبة حالياً على شرائح Blackwell الاستهلاكية والمهنية (SM120).</strong> مشكلة NVFP4 GEMM في flashinfer على SM120 (<a href="https://github.com/flashinfer-ai/flashinfer/issues/2577">#2577</a>) مفتوحة، مما يجعل تشغيل هذا النموذج رباعي البت على RTX 5090 وRTX PRO 6000 أمراً صعباً حالياً. الأفضل على الورق هو عملياً “لا يعمل الآن”.</li>
  <li><strong>لذا يبقى DGX Spark (SM121) الجهاز الاستهلاكي الوحيد الذي يعمل عليه NVFP4 MoE فعلاً.</strong> النطاق الترددي أدنى والسرعة متحفظة، لكن “صندوق MoE رباعي البت يعمل اليوم” هو السبب الحقيقي لصدور العرض من DGX Spark.</li>
  <li><strong>Blackwell لمراكز البيانات (B200, SM100)</strong> مدعوم بالكامل عبر TRT-LLM وflashinfer NVFP4، لكن فارق التكلفة شاسع. للاستضافة الذاتية المستمرة يُفضل امتلاك الجهاز، أما لتحميل الأعباء المتفرقة ومتعددة المستأجرين فـ B200 سحابياً أجدى.</li>
</ul>

<p>خلاصة: DGX Spark ليس “آلة شراء أداء الطليعة”، بل هو <strong>“آلة شراء ذاكرة كبيرة وتزامن عالٍ بشكل يعمل اليوم، للتطوير والنمذجة الأولية والخدمة المتزامنة الصغيرة”</strong>. حين تُصلح مشكلة SM120، ستنزل الكفاءة النظرية لـ RTX 5090 إلى الواقع، لكن حتى ذلك الحين موقع DGX Spark واضح. العرض المبهر بتوازي 16 ضعفاً مبني بالضبط على هذه الميزة.</p>

<h2 id="مراجعة-صريحة-2-ما-المهام-الملائمة-لهذا-النموذج">مراجعة صريحة 2: ما المهام الملائمة لهذا النموذج؟</h2>

<p>حين يتضح طابع الكفاءة، تتضح المهام الملائمة.</p>

<p><strong>المهام الأنسب</strong></p>

<ul>
  <li>تشغيل عدة وكلاء متزامنين: نمط 16 إلى 32 عاملاً يعملون معاً بسرعة معقولة. الإنتاجية الإجمالية هي نقطة القوة.</li>
  <li>أعباء المخرجات المنظمة: تدعم بطاقة النموذج استدعاء الدوال ومخرجات JSON المنظمة، و MTP يُحقق أعلى سرعة للاستجابات القصيرة إلى المتوسطة والـ JSON التحكمي. مناسب للتصنيف والتسمية والاستخراج المنظم.</li>
  <li>معالجة السياق الطويل: سياق 256 ألف رمز مع KV Cache واسع يمنح مرونة في تلخيص الوثائق الطويلة وحقن سياق RAG.</li>
  <li>النمذجة الأولية في البيئات الخاصة: تجربة خدمة نماذج MoE الكبيرة دون وحدات GPU لمراكز البيانات.</li>
</ul>

<p><strong>المهام الأقل ملاءمة</strong></p>

<ul>
  <li>محادثة فردية منخفضة التأخير: سرعة التدفق لكل مستخدم واحد أبطأ من بطاقات GDDR7. إن كان الهدف “أسرع استجابة لشخص واحد”، فهذا الجهاز ليس المناسب.</li>
  <li>استدلال أحادي عالي الصعوبة: المهام التي تتطلب أعلى دقة ممكنة تستفيد من نماذج أكثر كثافة أو أكبر حجماً. 26 ملياراً هي فئة الإنتاجية لا الدقة القصوى.</li>
</ul>

<h2 id="دليل-التشغيل">دليل التشغيل</h2>

<p>الطريق الموصى به في بطاقة النموذج هو vLLM. ثمة قيود موثقة حالياً:</p>

<ul>
  <li><strong>vLLM TP=1 فقط</strong>: البنية الحالية تدعم التوازي التنسوري 1 فقط (GPU واحد/جهاز واحد).</li>
  <li><strong>محلل Gemma 4 مخصص</strong>: يلزم تحديد <code class="language-plaintext highlighter-rouge">--tool-call-parser gemma4</code> و<code class="language-plaintext highlighter-rouge">--reasoning-parser gemma4</code> عند التشغيل لتحليل مخرجات استدعاء الدوال والاستدلال بشكل صحيح.</li>
  <li><strong>flashinfer غير مُطبقة</strong>: كما أشار صاحب العرض، لم تُستخدم flashinfer بعد. تطبيق تحسينات نواة الانتباه سيضيف هامشاً إضافياً من الأداء.</li>
</ul>

<p>يستلزم التشغيل نظام Linux وجهاز Blackwell (Tensor Cores لـ NVFP4). الأجيال السابقة لا تستفيد من ميزة التسريع رباعي البت.</p>

<h2 id="دلالات-التطبيق-على-منصة-thakicloud-k8s-للذكاء-الاصطناعي">دلالات التطبيق على منصة ThakiCloud K8s للذكاء الاصطناعي</h2>

<p>تُدير ThakiCloud منصة متعددة المستأجرين تستخدم Kueue لإدارة حصص GPU وvLLM لخدمة النماذج. ثمة ثلاثة دلالات رئيسية يمنحها هذا العرض لنموذج تشغيلنا:</p>

<p><strong>مرشح للاستضافة الذاتية في طبقة العمال.</strong> انضباطنا في التكاليف يتبع قاعدة “العمال بالرخيص، والبوابات بالغالي”. مهام العمال كالاستكشاف والتصنيف والتلخيص والاستخراج المنظم لا تستلزم النماذج الأعلى رتبة. NVFP4 26B بإنتاجيته الإجمالية البالغة 300 رمز/ثانية ودعمه لاستدعاء الدوال ومخرجات JSON، مرشح مناسب لتشغيل عمال متعددين محلياً في آن واحد. إبقاء مراحل التحقق والتوليف والأحكام المعمارية للنماذج الأعلى رتبة يُقلص تكلفة الرموز هيكلياً.</p>

<p><strong>الذاكرة الموحدة الكبيرة تُبسط ميزانية KV لمتعدد المستأجرين.</strong> مع أوزان تبلغ 16 جيجابايت في ذاكرة موحدة 128 جيجابايت، يتجاوز هامش KV Cache 100 جيجابايت. في البيئات متعددة المستأجرين، KV Cache هو أول مورد ينضب، وهذا الهامش يتيح تحديد حدود تزامن سخية لكل مستأجر.</p>

<p><strong>مرجع لاقتراحات الخوادم الخاصة والامتثال.</strong> رخصة Apache 2.0 والتشغيل على جهاز واحد تكوين قابل للاقتراح مباشرة على عملاء القطاع العام والمالي الذين يشترطون الاستضافة الذاتية. إمكانية تشغيل MoE كبيرة على صندوق صغير دون GPU لمراكز البيانات توفر مساراً عملياً للبيئات التي تحظر نقل البيانات خارجياً أو تستلزم امتثالاً أمنياً صارماً.</p>

<h2 id="مراجعة-صريحة-3-ما-حدود-استخدام-هذا-النموذج-في-منظومة-مهاراتنا">مراجعة صريحة 3: ما حدود استخدام هذا النموذج في منظومة مهاراتنا؟</h2>

<p>معظم مهارات ThakiCloud ووكلائها تعتمد النماذج الأعلى رتبة كـ Opus/Sonnet أساساً. إذن أين يمكن إدراج NVFP4 26B؟ بصدق:</p>

<ul>
  <li><strong>قابل للاستبدال فوراً (طبقة العمال)</strong>: قراءة الملفات وتلخيص Grep، التصنيف وتطبيع Enum (عمال حتمية التنسيق)، توليد المسودات الأولى، استخراج الأخبار والوثائق. مهام read-only والمهام المنظمة التي يتولاها حالياً haiku/sonnet كعمال فرعيين يمكن نقل جزء كبير منها إلى 26B محلياً.</li>
  <li><strong>ممكن بشروط (مع تعزيز التحقق)</strong>: عمال استدعاء أدوات الوكيل. دعم استدعاء الدوال ومخرجات JSON يجعله صالحاً كعامل طرفي في حلقات استدعاء الأدوات. لكن نتائج fan-out يجب دائماً إغلاقها بـ adversarial verify من نموذج أعلى (منع تراكم هلوسات العمال).</li>
  <li><strong>غير موصى به (طبقة البوابات)</strong>: الاستدلال المعماري متعدد الخطوات، وأحكام التوليف والتحقق، وتوليد المحتوى عالي المخاطر. المراحل التي تتطلب أعلى دقة ممكنة تبقى على Opus.</li>
</ul>

<p>الجوهر هو مطابقة رتبة النموذج مع رتبة المهمة. رؤية NVFP4 26B كـ “بديل لـ Opus” تُخيب الآمال، لكن رؤيته كـ “مرشح للاستضافة الذاتية في طبقة عمال haiku/sonnet” تجعله بطاقة قادرة على تغيير هيكل التكاليف. هذا بالضبط ما تقوله قاعدة توجيهنا: الاستكشاف بالرخيص، والبوابات بالغالي.</p>

<h2 id="القيود-والنقد">القيود والنقد</h2>

<p>للتوازن، نذكر الجوانب التي تستحق المراجعة:</p>

<ul>
  <li><strong>سرعة التدفق المفرد متحفظة.</strong> بطء النطاق الترددي يجعله أبطأ من بطاقات GDDR7. أعباء العمل الحساسة للتأخير تستلزم إعادة النظر في اختيار الجهاز.</li>
  <li><strong>أرقام العرض مرتبطة بالإعداد.</strong> 18 رمزاً/ثانية و300 رمز/ثانية هي قيم لتزامن 16 ضعفاً وإعداد محدد، وتتفاوت حسب طول المدخل والمخرج وتطبيق MTP. يجب إعادة القياس على أعباء العمل الخاصة بك.</li>
  <li><strong>vLLM TP=1 وغياب flashinfer قيود اللحظة الحالية.</strong> إضافة التحسينات قد تُغير الأرقام، لذا يُقرأ هذا المقال كـ “لقطة الحال”.</li>
  <li><strong>تعقيد تشغيل MoE.</strong> رغم أن المعاملات النشطة 3.8 مليار، تبقى الأوزان الكاملة في الذاكرة، وتوجيه الخبراء يؤثر على كفاءة الدفعات. “صغير الحجم” تفسير مبسط.</li>
  <li><strong>يلزم التحقق من الاستخدام الفعلي بالعربية والكورية.</strong> المعايير العامة تُركز على اللغة الإنجليزية. دقة RAG واستدعاء الأدوات بالعربية تستلزم تقييماً داخلياً منفصلاً.</li>
</ul>

<p>مع ذلك، يبقى الجمع بين رخصة Apache 2.0 وخدمة MoE كبيرة على جهاز واحد وتزامن مبني على ذاكرة واسعة خياراً جذاباً حقاً للمؤسسات التي تدرس الاستضافة الذاتية. بالنظر إليه من زاوية “شراء ذاكرة رخيصة وتزامن” لا “شراء سرعة الطليعة”، يُقدم DGX Spark + NVFP4 26B قيمة واضحة.</p>

<h2 id="روابط-مرجعية">روابط مرجعية</h2>

<ul>
  <li><a href="https://huggingface.co/nvidia/Gemma-4-26B-A4B-NVFP4">بطاقة نموذج Gemma-4-26B-A4B-NVFP4 (Hugging Face)</a></li>
  <li><a href="https://x.com/googlegemma/status/2069452783523401804">تغريدة العرض الأصلي (Google Gemma)</a></li>
  <li><a href="https://thakicloud.github.io/owm/gemma-4-open-weight-lineup/">ملخص تشكيلة Gemma 4 الكاملة (مدونة ThakiCloud)</a></li>
  <li><a href="https://github.com/NVIDIA/TensorRT-Model-Optimizer">NVIDIA TensorRT Model Optimizer</a></li>
  <li><a href="https://developer.nvidia.com/blog/introducing-nvfp4-for-efficient-and-accurate-low-precision-inference/">مقدمة NVFP4 (NVIDIA Developer)</a></li>
  <li><a href="https://github.com/flashinfer-ai/flashinfer/issues/2577">مشكلة NVFP4 GEMM على SM120 في flashinfer #2577</a></li>
  <li><a href="https://ai-muninn.com/en/blog/dgx-spark-gemma4-26b-nvfp4-52-toks">معايير DGX Spark مع Gemma 4 26B NVFP4 (ai-muninn)</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="owm" /><category term="gemma-4" /><category term="nvfp4" /><category term="dgx-spark" /><category term="blackwell" /><category term="mixture-of-experts" /><category term="quantization" /><category term="vllm" /><category term="on-premise" /><category term="inference" /><summary type="html"><![CDATA[نموذج Gemma-4-26B-A4B-NVFP4 الذي أصدرته NVIDIA يعمل على جهاز DGX Spark واحد (128 جيجابايت من الذاكرة الموحدة) بتوازي 16 ضعفاً، محققاً نحو 18 رمزاً في الثانية لكل تدفق وما يزيد على 300 رمز في الثانية إجمالاً. نستعرض في هذا المقال آلية NVFP4 التي تضغط 25.2 مليار معامل MoE إلى نحو 14 جيجابايت، والمقايضة بين التدفق المفرد والتزامن، ومدى تفوق DGX Spark فعلاً من حيث القيمة مقابل التكلفة مقارنة بوحدات Blackwell الأخرى.]]></summary></entry><entry xml:lang="ar"><title type="html">تشكيلة Gemma 4 الكاملة: خمسة نماذج مفتوحة الأوزان برخصة Apache 2.0 ودليل التشغيل المحلي</title><link href="https://thakicloud.github.io/ar/owm/gemma-4-open-weight-lineup/" rel="alternate" type="text/html" title="تشكيلة Gemma 4 الكاملة: خمسة نماذج مفتوحة الأوزان برخصة Apache 2.0 ودليل التشغيل المحلي" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/owm/gemma-4-open-weight-lineup</id><content type="html" xml:base="https://thakicloud.github.io/ar/owm/gemma-4-open-weight-lineup/"><![CDATA[<p>⏱️ <strong>وقت القراءة المقدر</strong>: 10 دقائق</p>

<p><img src="/assets/images/gemma-4-open-weight-lineup-hero.png" alt="مخطط مفاهيمي لتشكيلة Gemma 4" /></p>

<h2 id="نظرة-عامة-على-gemma-4">نظرة عامة على Gemma 4</h2>

<p>أصدرت Google DeepMind نموذج Gemma 4 في الثاني من أبريل 2026، وهو أذكى عائلة نماذج مفتوحة الأوزان أطلقتها Gemma حتى الآن. وتذكر Google أنه بُني على نفس الأبحاث والتقنيات التي يقوم عليها Gemini 3. بعبارة أخرى، يمكن اعتباره وصفة التدريب وراء نموذج رائد مغلق، مقطّرة إلى تشكيلة مفتوحة الأوزان.</p>

<p>من منظور ThakiCloud، يبرز تغييران في هذا الجيل. أولًا، انتقلت الرخصة إلى <strong>Apache 2.0</strong>. فخلافًا للأجيال السابقة من Gemma التي كانت تحمل سياسة استخدام منفصلة، يتبنى Gemma 4 رخصة مفتوحة المصدر قياسية ومتساهلة تجاريًا. ثانيًا، لا يُطرح بحجم واحد بل كتشكيلة من خمسة نماذج تمتد من <strong>الحافة (الهواتف) إلى وحدة معالجة رسومية واحدة على الخادم</strong>. أي أنه يمكنك اختيار هدف النشر حسب فئة الجهاز ضمن نفس عائلة النماذج.</p>

<p>بدلًا من التعمق في نموذج واحد، يهدف هذا المقال إلى <strong>مقارنة النماذج الخمسة دفعة واحدة وتوضيح أيها يُختار لكل حالة</strong>.</p>

<h2 id="تشكيلة-gemma-4-النماذج-الخمسة-كاملة">تشكيلة Gemma 4: النماذج الخمسة كاملة</h2>

<p>يتكوّن Gemma 4 من النماذج الخمسة التالية، منظمة حسب المعاملات والسياق والوسائط والبنية وفق بطاقة النموذج:</p>

<table>
  <thead>
    <tr>
      <th>النموذج</th>
      <th>المعاملات</th>
      <th>السياق</th>
      <th>وسائط الإدخال</th>
      <th>البنية</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>E2B</strong></td>
      <td>2.3B فعّالة (5.1B مع التضمينات)</td>
      <td>128K</td>
      <td>نص + صورة + صوت</td>
      <td>Dense</td>
    </tr>
    <tr>
      <td><strong>E4B</strong></td>
      <td>4.5B فعّالة (8B مع التضمينات)</td>
      <td>128K</td>
      <td>نص + صورة + صوت</td>
      <td>Dense</td>
    </tr>
    <tr>
      <td><strong>12B Unified</strong></td>
      <td>11.95B</td>
      <td>256K</td>
      <td>نص + صورة + صوت</td>
      <td>Dense</td>
    </tr>
    <tr>
      <td><strong>26B A4B</strong></td>
      <td>25.2B إجمالًا / 3.8B نشطة</td>
      <td>256K</td>
      <td>نص + صورة</td>
      <td>MoE (8 خبراء نشطون من 128)</td>
    </tr>
    <tr>
      <td><strong>31B Dense</strong></td>
      <td>30.7B</td>
      <td>256K</td>
      <td>نص + صورة</td>
      <td>Dense</td>
    </tr>
  </tbody>
</table>

<p>تُخرج النماذج الخمسة جميعها نصًا. ودعم إدخال الصوت متاح فقط في نماذج E2B وE4B و12B، بينما يتعامل 26B و31B مع النص والصورة.</p>

<p>يرمز حرف “E” في <code class="language-plaintext highlighter-rouge">E2B</code> و<code class="language-plaintext highlighter-rouge">E4B</code> إلى المعاملات الفعّالة (effective). وهو الحجم المبني على معاملات الحوسبة الفعلية باستثناء جدول التضمينات، والقيم الفعّالة هي الرقم الأكثر واقعية عند تقدير ميزانيات الذاكرة والحوسبة. ويستهدف هذان النموذجان مباشرةً الأجهزة الطرفية كالهواتف والحواسيب المحمولة.</p>

<p>جوهر التشكيلة هو <strong>تقسيم العمل بين النموذجين الأعلى: 26B A4B (MoE) و31B (Dense)</strong>.</p>

<ul>
  <li><strong>26B A4B</strong> هو نموذج Mixture-of-Experts. يضم 25.2B معاملًا إجماليًا لكنه يُفعّل نحو 3.8B فقط لكل رمز. ولا تزال الأوزان الكاملة بحاجة إلى الوجود في ذاكرة VRAM، لكن حوسبة كل رمز (FLOPs) تُحسب على أساس المعاملات النشطة، وهو ما <strong>يصب في صالح زمن الاستجابة والإنتاجية</strong>. ويناسب الخدمة التي تتطلب تمرير أعداد كبيرة من الطلبات بسرعة.</li>
  <li><strong>31B Dense</strong> نموذج كثيف قياسي يشارك فيه كل معامل في كل رمز. وهو موجّه نحو تعظيم الجودة وملاءمة الضبط الدقيق، وتضع Google نموذج 31B كسقف الجودة في التشكيلة.</li>
</ul>

<p>ووفقًا لـ Google، احتل 31B المركز الثالث بين النماذج المفتوحة عالميًا على لوحة Arena AI النصية، وحل 26B في المركز السادس، ووصفت التشكيلة بأنها “تنافس نماذج أكبر منها بعشرين ضعفًا”. وتتغير مثل هذه الترتيبات بمرور الوقت، لذا يُفضّل قراءتها كاتجاه (“كثافة ذكاء عالية مقارنة بفئتها”) لا كأرقام مطلقة.</p>

<h3 id="مسار-اختيار-النموذج">مسار اختيار النموذج</h3>

<pre><code class="language-mermaid">flowchart TD
    A[اختر نموذج Gemma 4] --&gt; B{هدف النشر؟}
    B --&gt;|هاتف/جهاز طرفي| C[E2B / E4B&lt;br/&gt;128K، دعم الصوت]
    B --&gt;|تشغيل محلي بوحدة واحدة| D{الأولوية؟}
    D --&gt;|الإنتاجية/زمن الاستجابة| E[26B A4B MoE&lt;br/&gt;نشطة 3.8B]
    D --&gt;|أعلى جودة/ضبط دقيق| F[31B Dense]
    D --&gt;|متعدد الوسائط + صوت + توازن| G[12B Unified&lt;br/&gt;256K، دعم الصوت]
</code></pre>

<h2 id="البنية-الانتباه-الهجين-وتعدد-الوسائط">البنية: الانتباه الهجين وتعدد الوسائط</h2>

<p>تتشارك نماذج Gemma 4 الخمسة آلية <strong>انتباه هجين</strong>. فهي تتناوب بين انتباه النافذة المنزلقة المحلية والانتباه العالمي الكامل. تُعالَج النطاقات القصيرة بثمن زهيد عبر النافذة المنزلقة، بينما يُدرَج الانتباه العالمي دوريًا لالتقاط ترابطات السياق الكامل، بهدف كبح كلفة الذاكرة والحوسبة في السياقات الطويلة. وهذا التصميم هو الخلفية وراء قدرة النماذج العليا (12B/26B/31B) على التعامل مع سياق 256K.</p>

<p>تعدد الوسائط هو الإعداد الافتراضي في هذا الجيل. تستقبل النماذج الخمسة جميعها النص والصورة كمدخل، وتتعامل الفئات الطرفية والمتوسطة (E2B/E4B/12B) مع إدخال الصوت أيضًا. كما أن الميزات الموجهة لسير عمل الوكلاء مدمجة أيضًا. فاستدعاء الدوال، وإخراج JSON المنظّم، وتعليمات النظام الأصلية مدعومة رسميًا، وتؤكد التشكيلة تحسينات في التخطيط متعدد الخطوات والاستدلال المنطقي مقارنة بالجيل السابق. وتاريخ قطع بيانات التدريب هو يناير 2025.</p>

<p>ودعم اللغات واسع: أكثر من 35 لغة جاهزة، وأكثر من 140 لغة على مستوى التدريب المسبق. وتتطلب الجودة الفعلية في التشغيل بالكورية تقييمًا مباشرًا، لكن التغطية متعددة اللغات نفسها واسعة.</p>

<h2 id="المعايير">المعايير</h2>

<p>فيما يلي المعايير التمثيلية التي نشرتها Google لنموذج 31B المضبوط على التعليمات، وفق بطاقة النموذج.</p>

<table>
  <thead>
    <tr>
      <th>المعيار</th>
      <th>31B (IT)</th>
      <th>المجال المقيس</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>MMLU-Pro</td>
      <td>85.2%</td>
      <td>المعرفة العامة والاستدلال</td>
    </tr>
    <tr>
      <td>GPQA Diamond</td>
      <td>84.3%</td>
      <td>الاستدلال العلمي بمستوى الدراسات العليا</td>
    </tr>
    <tr>
      <td>LiveCodeBench v6</td>
      <td>80.0%</td>
      <td>توليد الشيفرة</td>
    </tr>
    <tr>
      <td>MATH-Vision</td>
      <td>85.6%</td>
      <td>الرياضيات المعتمدة على الرؤية</td>
    </tr>
    <tr>
      <td>Codeforces (ELO)</td>
      <td>2150</td>
      <td>البرمجة التنافسية</td>
    </tr>
  </tbody>
</table>

<p>عند حجم 31B بعقدة واحدة، يُعد GPQA Diamond بنسبة 84.3% وMMLU-Pro بنسبة 85.2% في الصدارة بين النماذج المفتوحة الأوزان المماثلة. ومع ذلك، فالمعايير خاصة بالنسخة المضبوطة على التعليمات، ويجب التحقق من الأداء في المهام الواقعية بشكل منفصل. وعلى وجه الخصوص، لا تنعكس مهام الاستدلال والبرمجة بالكورية مباشرةً في المعايير العامة، لذا يُنصح بقياسها بمجموعة تقييم داخلية.</p>

<h2 id="الخدمة-والنشر">الخدمة والنشر</h2>

<p>أمّن Gemma 4 دعمًا واسعًا من منظومة الخدمة منذ الإطلاق. والمسارات الرسمية هي:</p>

<ul>
  <li><strong>خوادم الاستدلال</strong>: vLLM، SGLang، llama.cpp، Ollama، LM Studio، NVIDIA NIM</li>
  <li><strong>الأطر</strong>: Hugging Face Transformers / TRL / Transformers.js / Candle، Keras، MaxText، NeMo</li>
  <li><strong>الحافة/على الجهاز</strong>: LiteRT-LM، Cactus</li>
  <li><strong>الضبط الدقيق/التكميم</strong>: Unsloth، Tunix</li>
  <li><strong>بنية النشر</strong>: Docker، Baseten، Google Cloud (Vertex AI)</li>
</ul>

<p>يمكن تنزيل الأوزان من <a href="https://huggingface.co/collections/google/gemma-4">مجموعة google/gemma-4 على Hugging Face</a> وKaggle وOllama.</p>

<h3 id="متطلبات-وحدة-المعالجة-الرسومية-للتشغيل-المحلي-تقديري">متطلبات وحدة المعالجة الرسومية للتشغيل المحلي (تقديري)</h3>

<p>دليل تقريبي للنشر المحلي مبني على ذاكرة أوزان BF16 لكل نموذج. هذه تقديرات للأوزان تستثني ذاكرة KV وأعباء وقت التشغيل، لذا اترك هامشًا لطول السياق وعدد الطلبات المتزامنة في النشر الفعلي.</p>

<table>
  <thead>
    <tr>
      <th>النموذج</th>
      <th>أوزان BF16 (تقديري)</th>
      <th>نقطة بداية واقعية للتشغيل المحلي</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>E2B / E4B</td>
      <td>نحو 5–16GB [تقديري]</td>
      <td>وحدة استهلاكية، حاسوب محمول، هاتف (LiteRT)</td>
    </tr>
    <tr>
      <td>12B Unified</td>
      <td>نحو 24GB [تقديري]</td>
      <td>وحدة 24GB واحدة (فئة RTX 4090/L4)، هامش عند التكميم</td>
    </tr>
    <tr>
      <td>26B A4B (MoE)</td>
      <td>نحو 50GB [تقديري]</td>
      <td>وحدة H100/A100 80GB واحدة</td>
    </tr>
    <tr>
      <td>31B Dense</td>
      <td>نحو 62GB [تقديري]</td>
      <td>وحدة H100/A100 80GB واحدة</td>
    </tr>
  </tbody>
</table>

<p>تكمن القوة العملية للتشكيلة في أن النموذجين الأعلى (26B و31B) يتسعان في <strong>وحدة معالجة رسومية واحدة بسعة 80GB</strong> بدقة BF16. أي أنه يمكنك تشغيل استدلال بمستوى متقدم على خادم واحد دون توازي موترات متعدد العقد، وهو ما يخفض كثيرًا حاجز التبني المحلي. وبميزانية وحدة أصغر، انزل إلى نموذج 12B أو إلى مسار مكمَّم (GGUF Q4/Q8). وبفضل طبيعته MoE التي تحسب فقط 3.8B النشطة، يتمتع 26B بأفضلية في الإنتاجية لكل رمز مقارنة بـ31B Dense عند نفس سعة VRAM.</p>

<h2 id="دلالات-للتطبيق-على-منصة-thakicloud-k8s-aiml-saas">دلالات للتطبيق على منصة ThakiCloud K8s AI/ML SaaS</h2>

<p>تتناغم تشكيلة Gemma 4 جيدًا مع استراتيجية الخدمة متعددة المستأجرين لدى ThakiCloud. وهي مهمة على ثلاث جبهات.</p>

<p><strong>Apache 2.0 يفتح حاجز التبني.</strong> إن إطلاق عائلة مفتوحة الأوزان بمستوى متقدم تحت رخصة Apache 2.0 القياسية أمر بالغ الأهمية للتبني المؤسسي والمحلي. إذ يمكنك دمجها في خدمات تجارية دون عبء مراجعة سياسة استخدام منفصلة، وتوزيع نواتج الضبط الدقيق بحرية. وهي عائلة نماذج يمكن اقتراحها مباشرةً على البيئات ذات الامتثال الصارم للترخيص، كالقطاع العام والمالي محليًا، وعلى العملاء المحليين الذين يشترطون الاستضافة الذاتية.</p>

<p><strong>التشكيلة نفسها تتوافق مع توجيه وحدات المعالجة الرسومية متعدد المستأجرين.</strong> تدير ThakiCloud حصص وحدات المعالجة الرسومية عبر Kueue وتخدم النماذج عبر vLLM. وتشكيلة Gemma 4 المكوّنة من خمسة نماذج بنية تتيح توجيه فئات النماذج ضمن عائلة واحدة لتلائم احتياجات المستأجرين (حساسية زمن الاستجابة، أولوية الجودة، استدلال الحافة). وجّه المحادثة/التلخيص الخفيف إلى 12B، والدفعات الحرجة للإنتاجية إلى 26B MoE، والاستدلال/البرمجة عالية الصعوبة إلى 31B، فتتمكن من تحسين ميزانية الوحدات حسب فئة المهمة مع الحفاظ على نفس المُرمِّز وصيغة المُوجِّه.</p>

<p><strong>الخدمة بوحدة 80GB واحدة تبسّط نموذج الكلفة.</strong> كون 26B و31B يتسعان في وحدة H100/A100 واحدة يبسّط تقدير كلفة مهام وحدات المعالجة الرسومية في Kueue. إذ تختفي أعباء الاتصال وتعقيد الجدولة في توازي الموترات متعدد العقد، فيمكنك التسعير بوضوح بنموذج وحدة مخصصة لكل مستأجر. وميزة 26B MoE بتفعيل 3.8B تعني أنه يستطيع استقبال طلبات متزامنة أكثر على نفس الوحدة، وهو ما يصب أيضًا في صالح كلفة الوحدة لكل طلب.</p>

<p>باختصار، يصلح Gemma 4 كعائلة نماذج مرجعية حين تقترح ThakiCloud نمط تشغيل “تشغيل محلي بوحدة واحدة + توجيه نماذج متعدد المستأجرين” على العملاء.</p>

<h2 id="القيود-والاعتراضات">القيود والاعتراضات</h2>

<p>من باب التوازن، تستحق بضع ملاحظات الذكر.</p>

<ul>
  <li><strong>الفجوة بين المعايير والاستخدام الواقعي.</strong> تتركز الأرقام المنشورة على المعايير المضبوطة على التعليمات وباللغة الإنجليزية. ويجب إعادة قياس المهام الكورية، خصوصًا دقة RAG واستدعاء أدوات الوكلاء، بمجموعة تقييم خاصة بك.</li>
  <li><strong>صعوبة تشغيل MoE.</strong> نموذج 26B A4B منخفض الحوسبة لكل رمز لكنه يجب أن يُبقي الأوزان الكاملة مقيمة في VRAM، ويؤثر توجيه الخبراء في كفاءة الدُفعات وأنماط الذاكرة. والقراءة المبسطة “إنه صغير لأن النشط 3.8B” قراءة محفوفة بالمخاطر.</li>
  <li><strong>عدم تماثل دعم الصوت.</strong> إدخال الصوت موجود فقط في E2B/E4B/12B. وإن أردت أعلى جودة (26B/31B) والصوت معًا، تنشأ مقايضة ضمن التشكيلة.</li>
  <li><strong>قطع التدريب في يناير 2025.</strong> المهام التي تحتاج أحدث المعلومات يجب تعزيزها بـRAG وتكامل الأدوات.</li>
</ul>

<p>ومع ذلك، فإن رخصة Apache 2.0، وجدوى الخدمة بوحدة واحدة، وتشكيلة تصل الحافة بالخادم، أسباب كافية لوضع Gemma 4 على رأس قائمة التقييم لأي مؤسسة تفكر في التشغيل المحلي والاستضافة الذاتية.</p>

<h2 id="المراجع">المراجع</h2>

<ul>
  <li><a href="https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/">مدونة الإعلان الرسمي عن Gemma 4 (Google)</a></li>
  <li><a href="https://ai.google.dev/gemma/docs/core/model_card_4">بطاقة نموذج Gemma 4 (Google AI for Developers)</a></li>
  <li><a href="https://ai.google.dev/gemma/docs/core">وثائق نظرة عامة على نموذج Gemma 4</a></li>
  <li><a href="https://huggingface.co/collections/google/gemma-4">مجموعة google/gemma-4 على Hugging Face</a></li>
  <li><a href="https://github.com/google-deepmind/gemma">مكتبة Gemma على GitHub من Google DeepMind</a></li>
  <li><a href="https://cloud.google.com/blog/products/ai-machine-learning/gemma-4-available-on-google-cloud">توفّر Gemma 4 على Google Cloud</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="owm" /><category term="gemma-4" /><category term="google-deepmind" /><category term="open-weight" /><category term="apache-2.0" /><category term="mixture-of-experts" /><category term="multimodal" /><category term="edge-ai" /><category term="vllm" /><category term="sglang" /><category term="on-premise" /><summary type="html"><![CDATA[أصدرت Google DeepMind نموذج Gemma 4 في أبريل 2026، وهو عائلة متعددة الوسائط مفتوحة الأوزان مكوّنة من خمسة نماذج تمتد من E2B إلى 31B. نشرح رخصة Apache 2.0، وسياق 256 ألف رمز، والفرق بين 26B MoE و31B Dense، وكيفية اختيار كل نموذج من منظور التشغيل المحلي.]]></summary></entry><entry xml:lang="en"><title type="html">Android Emulators in Containers - Building a Reproducible Device Farm on K8s with docker-android</title><link href="https://thakicloud.github.io/en/dev/docker-android-k8s-emulator/" rel="alternate" type="text/html" title="Android Emulators in Containers - Building a Reproducible Device Farm on K8s with docker-android" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/dev/docker-android-k8s-emulator</id><content type="html" xml:base="https://thakicloud.github.io/en/dev/docker-android-k8s-emulator/"><![CDATA[<pre><code class="language-mermaid">flowchart LR
    subgraph NODE["KVM-enabled K8s node / Pod"]
      EMU["Android emulator (QEMU + KVM, optional CUDA)"]
      KVM["/dev/kvm"]
    end
    KVM --&gt;|passthrough| EMU
    EMU --&gt; SVC["ADB Service"]
    SVC --&gt; CI["CI farm"]
    SVC --&gt; SCRCPY["scrcpy remote control"]
</code></pre>
<h2 id="overview">Overview</h2>

<p>Testing a mobile app requires Android devices. Managing a fleet of physical handsets is a maintenance burden, and installing a heavy emulator locally on every developer’s machine leads to environment drift and poor reproducibility. Those problems multiply when you try to include Android tests in a CI pipeline, because every build node needs a consistent emulator setup.</p>

<p><code class="language-plaintext highlighter-rouge">docker-android</code> (the HQarroum edition) solves this with containers. It packages an Android emulator in a minimal configuration, runs it headlessly, and exposes ADB and screen control over the network. A single container gives you a clean, consistent Android environment in seconds, making it a natural fit for CI/CD and automated testing.</p>

<p>This post verifies docker-android’s architecture and real requirements against the project documentation, then examines how a Kubernetes platform like ThakiCloud can handle this class of device workload. Android emulation is not central to our AI/ML platform, but the question of how to isolate and run privileged containers that need KVM device passthrough and GPU acceleration maps directly onto our infrastructure capabilities.</p>

<hr />

<h2 id="what-docker-android-is">What docker-android Is</h2>

<p>HQarroum’s docker-android bundles an Android emulator, KVM support, and JRE 11 into a compact Alpine-based image (current version 1.1.0). The design intent is clear: expose a fully functional, remotely controllable Android emulator with the smallest possible software footprint. Inside the image live the emulator itself, an ADB server for external access, and QEMU with libvirt.</p>

<p>Key characteristics:</p>

<ul>
  <li><strong>Minimal footprint</strong>: Alpine-based for size optimization. Building without the SDK and emulator produces a much smaller image.</li>
  <li><strong>Configurable</strong>: Android version, device type, and image variant are all selectable.</li>
  <li><strong>Built-in port forwarding</strong>: Emulator and ADB are exposed through the container network interface.</li>
  <li><strong>Headless</strong>: No GUI required, making it suitable for CI farms. Screens can be accessed remotely via <a href="https://github.com/Genymobile/scrcpy">scrcpy</a>.</li>
  <li><strong>Reproducibility</strong>: The emulator image resets on every restart, so each run starts from an identical state.</li>
</ul>

<p>The diagram above shows a hypothetical deployment of this container on ThakiCloud Kubernetes. The emulator runs in a pod on a KVM-enabled node with <code class="language-plaintext highlighter-rouge">/dev/kvm</code> passed through; the cuda variant is used when GPU acceleration is needed. ADB is exposed as a Service so CI farms and scrcpy clients can reach it.</p>

<hr />

<h2 id="installation-and-integration">Installation and Integration</h2>

<p>The default build bundles the Android SDK, platform tools, and emulator into the image. Bringing everything up with docker-compose looks like this:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Basic emulator</span>
docker compose up android-emulator

<span class="c"># GPU acceleration</span>
docker compose up android-emulator-cuda

<span class="c"># GPU acceleration + Google Play Store</span>
docker compose up android-emulator-cuda-store
</code></pre></div></div>

<p>You can also build directly with Docker:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker build <span class="nt">-t</span> android-emulator <span class="nb">.</span>
</code></pre></div></div>

<p>After building the image, run the container with the KVM device mounted. Using a Play Store image requires the emulator and client to share the same <code class="language-plaintext highlighter-rouge">adbkey</code>; generate it with <code class="language-plaintext highlighter-rouge">adb keygen adbkey</code> and place it in the <code class="language-plaintext highlighter-rouge">./keys</code> directory.</p>

<p>Image size varies considerably by build variant. The comparison table from the repository documentation:</p>

<table>
  <thead>
    <tr>
      <th>Build variant</th>
      <th>Uncompressed</th>
      <th>Compressed</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>API 33 + emulator</td>
      <td>5.84 GB</td>
      <td>1.97 GB</td>
    </tr>
    <tr>
      <td>API 32 + emulator</td>
      <td>5.89 GB</td>
      <td>1.93 GB</td>
    </tr>
    <tr>
      <td>API 28 + emulator</td>
      <td>4.29 GB</td>
      <td>1.46 GB</td>
    </tr>
    <tr>
      <td>Without SDK/emulator</td>
      <td>414 MB</td>
      <td>138 MB</td>
    </tr>
  </tbody>
</table>

<p>Images that include the emulator are over 1.5 GB even compressed. When distributing across many nodes, registry bandwidth and node disk capacity both need to be factored in.</p>

<hr />

<h2 id="verifying-actual-behavior">Verifying Actual Behavior</h2>

<p>This post does not include a verified container boot. Honest record: could not boot here (no Docker daemon on the work host, and macOS provides no <code class="language-plaintext highlighter-rouge">/dev/kvm</code>). docker-android requires KVM hardware acceleration, so real operation is only possible on a Linux host or a KVM node with nested virtualization enabled.</p>

<p>What we could verify came directly from the repository documentation. The image size comparison table above reflects numbers stated in the docs; build variants, compose service names, and KVM mount requirements are all documentation-based. Figures such as boot time or test throughput that we could not measure are not included. In an actual deployment, once KVM nodes are available, the right procedure is to measure container boot time, ADB connection latency, and maximum concurrent emulator count directly.</p>

<hr />

<h2 id="implications-for-the-thakicloud-k8s-aiml-saas-platform">Implications for the ThakiCloud K8s AI/ML SaaS Platform</h2>

<p>docker-android is not an AI/ML tool in itself. But the operational requirements it surfaces overlap precisely with what ThakiCloud does well.</p>

<p>First, <strong>isolation of device-passthrough workloads</strong>. An emulator is essentially a privileged container that requires <code class="language-plaintext highlighter-rouge">/dev/kvm</code>. Running this class of workload safely in a multi-tenant Kubernetes environment demands careful node selection, device plugins, and security contexts. ThakiCloud already queues GPUs through device plugins and Kueue; KVM passthrough can be handled with the same pattern.</p>

<p>Second, <strong>reproducible test farms</strong>. Packaging headless emulators as containers lets you scale clean environments horizontally across as many nodes as you need. Running many parallel Appium UI tests from a CI/CD pipeline is a textbook use case for Kubernetes job scheduling.</p>

<p>Third, looking further ahead, this extends naturally to <strong>on-device AI validation</strong>. Verifying the behavior of lightweight models or agents running on mobile devices at scale requires a device farm that can spin up many isolated Android environments and run regression tests automatically. This is not a core concern for our platform today, but as our multi-tenant GPU and device orchestration capabilities mature, a mobile AI QA farm of this kind becomes something we could offer on the same infrastructure.</p>

<p>In short, docker-android is not a product we are building, but it is a good case study in taming heavy container workloads that mix privilege, device passthrough, and GPU acceleration on Kubernetes. That is a concrete illustration of the general-purpose K8s orchestration capabilities ThakiCloud emphasizes.</p>

<hr />

<h2 id="limitations-and-counterarguments">Limitations and Counterarguments</h2>

<ul>
  <li><strong>Heavy dependencies</strong>: KVM hardware acceleration is non-negotiable. In environments without nested virtualization support, performance degrades sharply or the emulator does not boot at all. Cloud node selection becomes a hard constraint.</li>
  <li><strong>Image bloat</strong>: Emulator-inclusive images are several GB even compressed. Distributing across many nodes accumulates real registry and disk costs.</li>
  <li><strong>Distance from AI/ML relevance</strong>: Honestly, this tool is far from the training and inference workloads at the core of our platform. For organizations with no mobile testing demand, the direct value is limited. The value of this post lies not in “the emulator itself” but in “the operational patterns for device-passthrough containers.”</li>
  <li><strong>Security of privileged containers</strong>: <code class="language-plaintext highlighter-rouge">/dev/kvm</code> access and privileged settings complicate multi-tenant security boundaries. Preserving tenant isolation requires dedicated node pools and strict policies.</li>
</ul>

<p>docker-android is a powerful tool for mobile test automation and a useful reference for how to handle device-class workloads on Kubernetes. Even before the moment we need it directly, the operational patterns are worth understanding in advance.</p>

<hr />

<h2 id="sources">Sources</h2>

<ul>
  <li>docker-android (HQarroum): <a href="https://github.com/HQarroum/docker-android">https://github.com/HQarroum/docker-android</a></li>
  <li>Docker Hub image: <code class="language-plaintext highlighter-rouge">halimqarroum/docker-android</code></li>
  <li>scrcpy (remote screen control): <a href="https://github.com/Genymobile/scrcpy">https://github.com/Genymobile/scrcpy</a></li>
  <li>Original tweet (RT): <a href="https://x.com/hjguyhan/status/2069427245295493446">https://x.com/hjguyhan/status/2069427245295493446</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="dev" /><category term="docker" /><category term="android" /><category term="kubernetes" /><category term="kvm" /><category term="ci-cd" /><summary type="html"><![CDATA[docker-android packages an Android emulator into a single container and runs it headlessly. We verify image sizes and KVM requirements against the official documentation, and explore what running device-passthrough workloads looks like on the ThakiCloud Kubernetes platform.]]></summary></entry><entry xml:lang="en"><title type="html">Routing Claude Code to Your Own Models - Cost-Efficient Coding Infra with claude-code-router</title><link href="https://thakicloud.github.io/en/llmops/claude-code-router-onprem-routing/" rel="alternate" type="text/html" title="Routing Claude Code to Your Own Models - Cost-Efficient Coding Infra with claude-code-router" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/llmops/claude-code-router-onprem-routing</id><content type="html" xml:base="https://thakicloud.github.io/en/llmops/claude-code-router-onprem-routing/"><![CDATA[<pre><code class="language-mermaid">flowchart LR
    CC["Claude Code"] --&gt; CCR["claude-code-router proxy"]
    CCR --&gt;|default / background| GLM["Ollama Cloud · glm-5.2"]
    CCR --&gt;|think / longContext| MM["MiniMax-M2.7 (Anthropic endpoint)"]
    CCR -.-&gt;|coding subagent tag| KIMI["Ollama Cloud · kimi-k2.7-code"]
    CCR -.-&gt;|onprem option| VLLM["internal vLLM (GLM-air)"]
    AUDIT["daily cost-audit loop"] --&gt;|checks vs Sonnet| CCR
</code></pre>

<h2 id="overview">Overview</h2>

<p>Claude Code is a terminal-based agentic coding tool. By default it sends requests to the Anthropic API, but not every request carries the same weight. Background summaries, short completions, long-context analysis, and deep refactoring reasoning all demand different model tiers. Push everything to the most expensive model and cost piles up; push everything to the cheapest and quality collapses.</p>

<p><code class="language-plaintext highlighter-rouge">claude-code-router</code> (CCR) solves this with a routing layer. It sits as a proxy between Claude Code and the model backends and forks traffic by request type. This post is not just a concept tour. It is a record of calling three external models to verify behavior, fixing the problems found along the way (a dead API key, thinking-tag leakage), and finally attaching a loop that continuously measures whether the routing is actually cheaper than Anthropic Sonnet.</p>

<p>The governing principle, stated up front: <strong>every model routed through CCR is only worthwhile if it is more cost-efficient than Claude Sonnet.</strong> Otherwise you lower quality while the money still flows. So we don’t assert. We measure.</p>

<hr />

<h2 id="what-claude-code-router-is">What claude-code-router is</h2>

<p>CCR is a proxy that receives Anthropic-format requests, converts them to OpenAI-compatible (or other) formats, and forwards them to the configured provider. It does not modify the Claude Code client. Launch a session with <code class="language-plaintext highlighter-rouge">ccr code</code> and that session’s traffic routes through the <code class="language-plaintext highlighter-rouge">localhost:3456</code> proxy.</p>

<p>Key features:</p>

<ul>
  <li><strong>Per-request-type routing</strong>: <code class="language-plaintext highlighter-rouge">default</code>, <code class="language-plaintext highlighter-rouge">background</code>, <code class="language-plaintext highlighter-rouge">think</code>, <code class="language-plaintext highlighter-rouge">longContext</code>, <code class="language-plaintext highlighter-rouge">webSearch</code>, each mapped to a different model.</li>
  <li><strong>Multi-provider</strong>: any OpenAI-compatible endpoint can be registered. Here we use Ollama Cloud and MiniMax.</li>
  <li><strong>Transformers</strong>: a converter absorbs each provider’s API quirks. The <code class="language-plaintext highlighter-rouge">Anthropic</code> passthrough transformer for native Anthropic endpoints is the key tool in this post.</li>
  <li><strong>Dynamic switching</strong>: change models mid-session with <code class="language-plaintext highlighter-rouge">/model provider,model</code>.</li>
</ul>

<p>The verified CCR version is <code class="language-plaintext highlighter-rouge">1.0.62</code>. The config lives at <code class="language-plaintext highlighter-rouge">~/.claude-code-router/config.json</code>, centered on a <code class="language-plaintext highlighter-rouge">Providers</code> array and a <code class="language-plaintext highlighter-rouge">Router</code> object.</p>

<hr />

<h2 id="what-gets-routed---fixed-to-three-models">What gets routed - fixed to three models</h2>

<p>The model pool is exactly three. Adding more models complicates the routing table and inflates verification cost, so we deliberately narrowed it.</p>

<table>
  <thead>
    <tr>
      <th>Role</th>
      <th>Model</th>
      <th>Provider</th>
      <th>Note</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Primary (default/background)</td>
      <td><code class="language-plaintext highlighter-rouge">glm-5.2</code></td>
      <td>Ollama Cloud</td>
      <td>everyday coding, strong and cheap</td>
    </tr>
    <tr>
      <td>Reasoning (think/longContext)</td>
      <td><code class="language-plaintext highlighter-rouge">MiniMax-M2.7</code></td>
      <td>MiniMax</td>
      <td>thinking separated, very low per-token cost</td>
    </tr>
    <tr>
      <td>Coding subagent</td>
      <td><code class="language-plaintext highlighter-rouge">kimi-k2.7-code</code></td>
      <td>Ollama Cloud</td>
      <td>hard coding turns only</td>
    </tr>
  </tbody>
</table>

<p><code class="language-plaintext highlighter-rouge">glm-5.2</code> is the workhorse; only deep reasoning and long context go to MiniMax, and a tough coding turn goes to Kimi.</p>

<hr />

<h2 id="verification---we-called-we-didnt-assume">Verification - we called, we didn’t assume</h2>

<p>Before writing any config, we called all three models directly. To avoid inventing numbers we inspected real responses, and three facts surfaced.</p>

<p><strong>First, one Ollama Cloud key covers both GLM and Kimi.</strong> Both <code class="language-plaintext highlighter-rouge">glm-5.2</code> and <code class="language-plaintext highlighter-rouge">kimi-k2.7-code</code> returned HTTP 200 from <code class="language-plaintext highlighter-rouge">https://ollama.com/v1</code>. Ollama Cloud bundles the GLM, Kimi, DeepSeek, and Qwen families behind a single key.</p>

<p><strong>Second, the standalone Kimi key was dead.</strong> The standalone Moonshot key in <code class="language-plaintext highlighter-rouge">.env</code> returned 401 (Invalid Authentication) against moonshot.ai, moonshot.cn, and the Anthropic-compatible endpoint alike. Fortunately Kimi K2 is reachable as Ollama Cloud’s <code class="language-plaintext highlighter-rouge">kimi-k2.7-code</code>, so the dead key was not a dead end.</p>

<p><strong>Third, MiniMax’s endpoint choice decides quality.</strong> Called through the OpenAI-compatible endpoint (<code class="language-plaintext highlighter-rouge">/v1/chat/completions</code>), the model inlines its reasoning as <code class="language-plaintext highlighter-rouge">&lt;think&gt;...&lt;/think&gt;</code> tags in the body, and CCR’s conversion layer fails to strip them, so they leak to the user (musistudio/claude-code-router#964). Called through the native Anthropic endpoint (<code class="language-plaintext highlighter-rouge">/anthropic/v1/messages</code>), the same model returns clean <code class="language-plaintext highlighter-rouge">thinking</code> and <code class="language-plaintext highlighter-rouge">text</code> blocks.</p>

<p>That last item was a bug to fix, not a reason to drop MiniMax. The fix is in the config below.</p>

<hr />

<h2 id="configuration---secrets-out-of-the-repo-config-as-code">Configuration - secrets out of the repo, config as code</h2>

<p>Keys are not hardcoded into the config file. A generator script reads the repo’s <code class="language-plaintext highlighter-rouge">.env</code> and writes <code class="language-plaintext highlighter-rouge">~/.claude-code-router/config.json</code>. No keys remain in the repo, and rotating a key just means re-running the script.</p>

<p>The core generated config:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"LOG"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
  </span><span class="nl">"HOST"</span><span class="p">:</span><span class="w"> </span><span class="s2">"127.0.0.1"</span><span class="p">,</span><span class="w">
  </span><span class="nl">"PORT"</span><span class="p">:</span><span class="w"> </span><span class="mi">3456</span><span class="p">,</span><span class="w">
  </span><span class="nl">"API_TIMEOUT_MS"</span><span class="p">:</span><span class="w"> </span><span class="mi">1800000</span><span class="p">,</span><span class="w">
  </span><span class="nl">"Providers"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
    </span><span class="p">{</span><span class="w">
      </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_base_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://ollama.com/v1/chat/completions"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_key"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;OLLAMA_GLM_API_KEY&gt;"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"models"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"glm-5.2"</span><span class="p">,</span><span class="w"> </span><span class="s2">"kimi-k2.7-code"</span><span class="p">],</span><span class="w">
      </span><span class="nl">"transformer"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"use"</span><span class="p">:</span><span class="w"> </span><span class="p">[[</span><span class="s2">"maxtoken"</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"max_tokens"</span><span class="p">:</span><span class="w"> </span><span class="mi">16000</span><span class="w"> </span><span class="p">}]]</span><span class="w"> </span><span class="p">}</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="p">{</span><span class="w">
      </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"minimax"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_base_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://api.minimax.io/anthropic/v1/messages"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"api_key"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;MINIMAX_API_KEY&gt;"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"models"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"MiniMax-M2.7"</span><span class="p">],</span><span class="w">
      </span><span class="nl">"transformer"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"use"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Anthropic"</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w">
    </span><span class="p">}</span><span class="w">
  </span><span class="p">],</span><span class="w">
  </span><span class="nl">"Router"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"default"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama,glm-5.2"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"background"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama,glm-5.2"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"think"</span><span class="p">:</span><span class="w"> </span><span class="s2">"minimax,MiniMax-M2.7"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"longContext"</span><span class="p">:</span><span class="w"> </span><span class="s2">"minimax,MiniMax-M2.7"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"longContextThreshold"</span><span class="p">:</span><span class="w"> </span><span class="mi">60000</span><span class="p">,</span><span class="w">
    </span><span class="nl">"webSearch"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ollama,glm-5.2"</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>The two lines in the MiniMax provider are what fix the thinking leak. Point <code class="language-plaintext highlighter-rouge">api_base_url</code> at the native Anthropic path and use the <code class="language-plaintext highlighter-rouge">Anthropic</code> passthrough transformer, and MiniMax responds in Anthropic message format (<code class="language-plaintext highlighter-rouge">thinking</code> + <code class="language-plaintext highlighter-rouge">text</code> blocks) from the start. Re-checked through the proxy, the response blocks were <code class="language-plaintext highlighter-rouge">["thinking", "text"]</code> with zero <code class="language-plaintext highlighter-rouge">&lt;think&gt;</code> leakage.</p>

<p>Reasoning models are slow to emit, so the timeout is generous (<code class="language-plaintext highlighter-rouge">1800000ms</code>), and <code class="language-plaintext highlighter-rouge">maxtoken</code> reserves output headroom so models like GLM and Kimi, which emit reasoning first, don’t burn the budget before the answer.</p>

<p>Subagents are routed not by config but by a prompt-leading tag. To delegate a hard coding task, prepend <code class="language-plaintext highlighter-rouge">&lt;CCR-SUBAGENT-MODEL&gt;ollama,kimi-k2.7-code&lt;/CCR-SUBAGENT-MODEL&gt;</code> to the prompt.</p>

<hr />

<h2 id="where-and-how-to-connect">Where and how to connect</h2>

<p>There is a single connection point. Start a session with <code class="language-plaintext highlighter-rouge">ccr code</code> in your working repo, and that session’s main and subagent traffic all route through the proxy per the table above. Native <code class="language-plaintext highlighter-rouge">claude</code> still connects directly to Anthropic, so it is unaffected.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># generate config, then start the router</span>
python3 scripts/ccr/gen_ccr_config.py <span class="o">&amp;&amp;</span> ccr restart

<span class="c"># start the cost-routed session (this is the connection point)</span>
ccr code

<span class="c"># switch models per task inside the session</span>
/model ollama,kimi-k2.7-code     <span class="c"># hard coding turn</span>
/model minimax,MiniMax-M2.7      <span class="c"># deep reasoning turn</span>
/model ollama,glm-5.2            <span class="c"># everyday coding</span>
</code></pre></div></div>

<p>For cost efficiency, the recommended pattern is hybrid. Run bulk, repetitive, AFK-style work (test generation, mass refactors, log analysis, translation, code exploration) under <code class="language-plaintext highlighter-rouge">ccr code</code> to cut cost, and keep judgment-heavy work (architecture decisions, subtle debugging) on the native <code class="language-plaintext highlighter-rouge">claude</code> subscription session. Moving everything to the routed session makes GLM your main loop, which can drop quality on hard tasks.</p>

<hr />

<h2 id="cost-efficiency---measured-against-sonnet-continuously">Cost efficiency - measured against Sonnet, continuously</h2>

<p>The reason this setup exists is cost. So instead of claiming “it’s cheaper,” we measure.</p>

<p>Rates verified on 2026-06-24 (USD per 1M tokens):</p>

<table>
  <thead>
    <tr>
      <th>Model</th>
      <th>Input</th>
      <th>Output</th>
      <th>Billing</th>
      <th>vs Sonnet</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Claude Sonnet 4.6 (baseline)</td>
      <td>$3.00</td>
      <td>$15.00</td>
      <td>per-token</td>
      <td>1.0x</td>
    </tr>
    <tr>
      <td>MiniMax-M2.7</td>
      <td>$0.24</td>
      <td>$0.96</td>
      <td>per-token</td>
      <td>~0.07x</td>
    </tr>
    <tr>
      <td>glm-5.2 / kimi-k2.7-code</td>
      <td>—</td>
      <td>—</td>
      <td>subscription $20/mo (Pro)</td>
      <td>usage-dependent</td>
    </tr>
  </tbody>
</table>

<p>MiniMax-M2.7 is about 7-8% of Sonnet’s per-token rate, so it is always dramatically cheaper. Ollama Cloud, by contrast, is a flat monthly subscription rather than per-token. Its effective rate is <code class="language-plaintext highlighter-rouge">monthly fee / monthly tokens used</code>, and at low volume the $20 flat fee is actually a loss. Using a blended $9/M, you must push <strong>roughly 2.2M tokens per month</strong> before it beats Sonnet.</p>

<p>That break-even is a measurement target, not a guess. CCR logs record the routed model and input/output tokens per request. A measurement script aggregates these, computing the ratio of actual cost to Sonnet-equivalent cost for per-token models, and projected-monthly Sonnet cost versus the subscription fee for subscription models. Results accumulate in a history file to track the trend, where improvement means the ratio falling over time.</p>

<p>The loop runs once a day via launchd. Claude is not in the loop; only a plain script runs on cron, so the measurement itself costs nothing. If a per-token model is ever found to be more expensive than Sonnet, a Slack alert fires. A subscription model below break-even (under-utilized) is reported but not alerted, to avoid noise during ramp-up.</p>

<p>The action rules are tied to the measurement. If a per-token model’s ratio is 1.0 or higher (more expensive than Sonnet), it comes off the routing immediately. If a subscription model stays under-utilized for months, downgrade the plan or move that route to a cheap per-token model. When prices change, updating the pricing-table file is enough to reflect it in the next run.</p>

<hr />

<h2 id="thakicloud-platform-perspective">ThakiCloud platform perspective</h2>

<p>This routing model fits naturally with the infrastructure ThakiCloud already runs.</p>

<p><strong>Code security.</strong> In environments where source code cannot leave the building (finance, public sector, healthcare), you only need to switch <code class="language-plaintext highlighter-rouge">default</code> in the config above to an internal vLLM endpoint. You keep Claude Code’s usability while prompts and code never leave. The external-model setup here is for cost verification; drop in-house GPU serving into the same skeleton and you have the on-premise version.</p>

<p><strong>Cost control.</strong> Per-task routing is per-cost routing. Send high-frequency, low-difficulty requests to cheap models and reserve top-tier models for hard reasoning, and you narrow expensive usage to where it’s truly needed, with the measurement loop proving the effect in numbers.</p>

<p><strong>Policy as code.</strong> Providers, routing rules, the pricing table, and the measurement criteria are all managed as text files committed to the repo. Only keys live in <code class="language-plaintext highlighter-rouge">.env</code> and the config is reproduced by a generator, so the same setup restores on any machine.</p>

<hr />

<h2 id="limits-and-counterarguments">Limits and counterarguments</h2>

<p>A router does not solve everything. Several points deserve a cold look.</p>

<ul>
  <li><strong>Quality gap</strong>: routing value depends on backend model quality. Open models do not always match top closed models on complex multi-step refactors or subtle debugging. Hence the hybrid recommendation.</li>
  <li><strong>Tool-call reliability</strong>: Claude Code leans heavily on tool calls. The OpenAI-compatible conversion layer can wobble tool-call formats, so it is safe for exploration/summary subagents but warrants gradual rollout for edit/implementation subagents.</li>
  <li><strong>Subscription trap</strong>: Ollama Cloud is flat-rate, so low usage is a loss. Below break-even, Sonnet is simply cheaper. The measurement loop watches exactly this point.</li>
  <li><strong>Proxy is a single point of failure</strong>: main traffic also passes through CCR, so if the proxy dies the session stalls. The fallback is native <code class="language-plaintext highlighter-rouge">claude</code>.</li>
  <li><strong>The “free” framing trap</strong>: some forks tout removing telemetry or safety guards as “free.” That is a direction a company cannot endorse. The value we take is not free but control - we decide which request goes to which model, and we measure the cost.</li>
</ul>

<p>CCR is not a cost-cutting magic trick but a routing control device. Combined with a verified model pool, fixes for real bugs like thinking leakage, and continuous measurement against Sonnet, it becomes a meaningful gain on both security and cost.</p>

<hr />

<h2 id="sources">Sources</h2>

<ul>
  <li>claude-code-router (musistudio): <a href="https://github.com/musistudio/claude-code-router">https://github.com/musistudio/claude-code-router</a></li>
  <li>MiniMax thinking-leak issue: <a href="https://github.com/musistudio/claude-code-router/issues/964">claude-code-router#964</a></li>
  <li>MiniMax M2.7 pricing: <a href="https://openrouter.ai/minimax/minimax-m2.7">openrouter.ai/minimax/minimax-m2.7</a></li>
  <li>Ollama Cloud pricing: <a href="https://ollama.com/pricing">ollama.com/pricing</a></li>
  <li>Claude API pricing: <a href="https://platform.claude.com/docs/en/about-claude/pricing">platform.claude.com/docs pricing</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="claude-code" /><category term="model-routing" /><category term="cost-optimization" /><category term="ollama" /><category term="minimax" /><category term="on-premise" /><summary type="html"><![CDATA[Routing Claude Code traffic across glm-5.2, MiniMax-M2.7, and Kimi K2 with claude-code-router. A hands-on record of verifying all three models live, fixing MiniMax thinking leakage, and building a loop that continuously checks every routed model is cheaper than Sonnet.]]></summary></entry><entry xml:lang="en"><title type="html">Connecting Claude Code to Self-Hosted Models with free-claude-code: A Real-World Test of a 17-Provider Routing Proxy</title><link href="https://thakicloud.github.io/en/llmops/free-claude-code-router/" rel="alternate" type="text/html" title="Connecting Claude Code to Self-Hosted Models with free-claude-code: A Real-World Test of a 17-Provider Routing Proxy" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/llmops/free-claude-code-router</id><content type="html" xml:base="https://thakicloud.github.io/en/llmops/free-claude-code-router/"><![CDATA[<h2 id="overview">Overview</h2>

<p>Claude Code is a powerful coding agent. However, because every request goes directly to the Anthropic API, it creates a constraint for organizations that need to control costs or keep data within their own boundaries. The recently trending <code class="language-plaintext highlighter-rouge">free-claude-code</code> project addresses this exact point. It is a proxy layer that intercepts Claude Code traffic and routes it to 17 different providers. It is an MIT-licensed project with 36.7k GitHub stars, 5.7k forks, and 712 commits.</p>

<p>The project’s marketing tagline is “Claude Code forever free.” The approach routes traffic to free or low-cost tier providers, and this framing is frankly overstated in some respects and sits in a gray area from a Terms of Service perspective. This article therefore focuses not on the “free” angle, but on what this tool means for organizations like ThakiCloud that <strong>serve their own models on Kubernetes and want to connect Claude Code to their own infrastructure</strong>. The key points are that code and prompts never leave the tenancy boundary, per-token cloud billing disappears, and no client-side modifications are needed because the endpoint is Anthropic-compatible.</p>

<blockquote>
  <p>Note: A previous article, “Routing Claude Code to In-House Models - claude-code-router,” focused on <strong>cost arbitrage</strong> between cloud models (glm, MiniMax, Kimi). This article is about a different tool (<code class="language-plaintext highlighter-rouge">free-claude-code</code>), covering the connection to <strong>self-hosted backends (Ollama, vLLM)</strong> — not cloud models — and the deployment risks that surfaced in the process.</p>
</blockquote>

<h2 id="what-this-tool-does">What This Tool Does</h2>

<p><code class="language-plaintext highlighter-rouge">free-claude-code</code> is a local proxy server that receives requests sent by Claude Code (and Codex). Its core feature is that it <strong>exactly mimics an Anthropic-compatible endpoint</strong>. From the client’s perspective, it is indistinguishable from the real Anthropic API, so the backend can be swapped without changing a single line of Claude Code.</p>

<p>The server is written in FastAPI and exposes the following endpoints:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">/v1/messages</code> - Anthropic Messages API compatible (the primary path for Claude Code)</li>
  <li><code class="language-plaintext highlighter-rouge">/v1/models</code> - Model listing</li>
  <li><code class="language-plaintext highlighter-rouge">/v1/responses</code> - OpenAI Responses API compatible (for Codex; internally converted to Messages)</li>
</ul>

<p>When a request arrives, a <strong>model router</strong> decides which provider to send it to, and a <strong>normalizer</strong> transforms thinking blocks, tool_calls, and error responses into the shape each client expects. Because response formats differ across providers, this normalization layer is where the real complexity lies.</p>

<p>To elaborate on why normalization is difficult: Claude Code assumes Anthropic’s own response structure. For instance, reasoning steps arrive as <code class="language-plaintext highlighter-rouge">thinking</code> blocks and tool calls as <code class="language-plaintext highlighter-rouge">tool_use</code> content blocks. DeepSeek, however, exports reasoning as a separate field, and OpenAI-compatible providers return tool calls as a <code class="language-plaintext highlighter-rouge">tool_calls</code> array. Even though they all mean “a tool was called,” the wire format differs in each case. The normalizer must absorb these differences and ensure Claude Code receives identically shaped responses regardless of which backend is used. The Codex path (<code class="language-plaintext highlighter-rouge">/v1/responses</code>) goes one step further, converting OpenAI Responses requests internally to Anthropic Messages before sharing the same router, normalizer, and provider adapters. This means protocol conversion happens in both directions — the key distinction between a simple reverse proxy and a routing proxy.</p>

<p><img src="/assets/images/free-claude-code-router-diagram.png" alt="free-claude-code routing architecture" />
<em>Figure 1. The FastAPI proxy receives Anthropic-compatible traffic from Claude Code and routes it to 17 providers. From ThakiCloud’s perspective, the important paths are the self-hosted backends on the right (Ollama, LM Studio, vLLM).</em></p>

<p>The supported providers number 17. On the cloud side: NVIDIA NIM, OpenRouter, Google AI Studio (Gemini), DeepSeek, Mistral La Plateforme, Mistral Codestral, OpenCode Zen, OpenCode Go, Wafer, Kimi, Cerebras, Groq, Fireworks, and Z.ai. On the <strong>self-hosted side: LM Studio, llama.cpp, and Ollama</strong>. The last three are the meaningful ones from ThakiCloud’s perspective. Since Ollama and llama.cpp expose OpenAI-compatible endpoints, a vLLM server deployed the same way on Kubernetes can be attached identically.</p>

<p>Tier-based routing is controlled via environment variables. <code class="language-plaintext highlighter-rouge">MODEL_OPUS</code>, <code class="language-plaintext highlighter-rouge">MODEL_SONNET</code>, and <code class="language-plaintext highlighter-rouge">MODEL_HAIKU</code> each specify which model to route to for the three Claude tiers; if unspecified, the fallback <code class="language-plaintext highlighter-rouge">MODEL</code> is used. This enables differentiated placement — for example, routing lightweight Haiku traffic to a small local model and heavier Opus traffic to a larger one.</p>

<h2 id="installation-and-integration">Installation and Integration</h2>

<p>The official installation path is a shell one-liner:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># macOS / Linux</span>
curl <span class="nt">-fsSL</span> <span class="s2">"https://github.com/Alishahryar1/free-claude-code/blob/main/scripts/install.sh?raw=1"</span> | sh

<span class="c"># Windows PowerShell</span>
irm <span class="s2">"https://github.com/Alishahryar1/free-claude-code/blob/main/scripts/install.ps1?raw=1"</span> | iex
</code></pre></div></div>

<p>Rather than the shell one-liner, I verified the package by installing it directly in an isolated sandbox, in order not to contaminate ThakiCloud’s shared virtual environment per our Python runtime rules.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Isolated worktree + ephemeral venv (shared .venv is 3.12.8 and would conflict)</span>
uv venv <span class="nt">--python</span> 3.14 .expenv
<span class="nv">VIRTUAL_ENV</span><span class="o">=</span>.expenv uv pip <span class="nb">install</span> <span class="s2">"git+https://github.com/Alishahryar1/free-claude-code.git"</span>
</code></pre></div></div>

<p>The package itself installs cleanly. Dependencies such as fastapi, uvicorn, httpx, pydantic, openai, and loguru resolve successfully, and console scripts like <code class="language-plaintext highlighter-rouge">fcc-server</code>, <code class="language-plaintext highlighter-rouge">fcc-init</code>, and <code class="language-plaintext highlighter-rouge">fcc-claude</code> are created. After starting the server, Claude Code is directed to the proxy as follows:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>fcc-server            <span class="c"># Start the FastAPI proxy (default http://127.0.0.1:8082)</span>
<span class="c"># Self-hosted backend example (Ollama):</span>
<span class="c">#   MODEL_HAIKU=ollama/llama3.2:3b</span>
<span class="c">#   MODEL_SONNET=ollama/qwen2.5:7b</span>
<span class="c"># Specify the base URL to point Claude Code at the proxy, then use as normal</span>
</code></pre></div></div>

<p>The admin UI is at <code class="language-plaintext highlighter-rouge">http://127.0.0.1:8082/admin</code> and is only accessible from loopback. Provider keys, model routing, and messaging and voice settings are managed here.</p>

<h2 id="actual-experiment-results">Actual Experiment Results</h2>

<p>During validation I encountered <strong>a point where reproduction was blocked</strong>, and I record it as-is. Not fabricating numbers is a principle of this report.</p>

<h3 id="boot-blocker-hard-python-314-requirement">Boot Blocker: Hard Python 3.14 Requirement</h3>

<p><code class="language-plaintext highlighter-rouge">free-claude-code</code> v2.3.14 has hardcoded <code class="language-plaintext highlighter-rouge">requires-python = "&gt;=3.14.0"</code>. Python 3.14 is the latest version, only officially released in October 2025. The problem was that the only available 3.14 in the test environment was an alpha build (3.14.0a7). Running <code class="language-plaintext highlighter-rouge">fcc-server</code> on this alpha fails with the following error:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ImportError: cannot import name 'get_annotate_from_class_namespace'
from 'annotationlib'
</code></pre></div></div>

<p>This is a conflict where the pinned pydantic expects the <code class="language-plaintext highlighter-rouge">annotationlib</code> API of the final 3.14, but that symbol is not yet present in the early alpha. I then attempted to force-run it under the next lower stable version (3.13), but installation itself is rejected because of the hard requirement in the package metadata:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>free-claude-code==2.3.14 cannot be used ... your requirements are unsatisfiable.
</code></pre></div></div>

<p>The conclusion is clear: <strong>in environments without a stable Python 3.14, this proxy will not boot.</strong> Reproduction attempt failed: the package hard-requires freshly released Python 3.14, but the only available 3.14 is an alpha that conflicts with the pinned pydantic. This is less a defect in the tool than a problem of <strong>aggressive version pinning</strong> that is at odds with the reality that production images typically remain on 3.11–3.12.</p>

<h3 id="direct-measurement-of-the-self-hosted-routing-path">Direct Measurement of the Self-Hosted Routing Path</h3>

<p>Although the proxy itself was blocked at boot, the <strong>mechanism</strong> this tool uses to call the <code class="language-plaintext highlighter-rouge">ollama</code> provider is the OpenAI-compatible endpoint. I therefore measured this path by calling local Ollama directly. These are the backend’s own routing performance numbers without the proxy overhead that fcc would add. The results of mapping Claude’s three tiers to local models are as follows (Apple Silicon, identical prompt, 64-token cap):</p>

<p><img src="/assets/images/free-claude-code-router-results.png" alt="Self-hosted routing measurement results" />
<em>Figure 2. Latency and throughput when routing Claude tiers to local Ollama models. qwen3:8b placed on the opus path is a thinking model that outputs extended reasoning tokens, significantly increasing the time.</em></p>

<table>
  <thead>
    <tr>
      <th>Routing</th>
      <th>Model</th>
      <th>Latency</th>
      <th>Completion Tokens</th>
      <th>Throughput</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>haiku</td>
      <td>llama3.2:3b</td>
      <td>0.49s</td>
      <td>33</td>
      <td>67.3 tok/s</td>
    </tr>
    <tr>
      <td>sonnet</td>
      <td>qwen2.5:7b</td>
      <td>0.56s</td>
      <td>20</td>
      <td>35.7 tok/s</td>
    </tr>
    <tr>
      <td>opus</td>
      <td>qwen3:8b</td>
      <td>8.12s</td>
      <td>281</td>
      <td>34.6 tok/s</td>
    </tr>
  </tbody>
</table>

<p>The small model (llama3.2:3b) finishes responding in under 0.5 seconds — fast enough for Haiku replacement traffic. qwen2.5:7b at 0.56 seconds is also practical. The qwen3:8b placed on the opus path, however, took 8.12 seconds, because the thinking model first emits 281 reasoning tokens. The throughput itself (34.6 tok/s) is normal, but this measurement confirms that <strong>placing a reasoning model in a heavy tier causes a token explosion and significantly increases perceived latency</strong>. A practical lesson: when designing tier mappings, the reasoning-token behavior of the model must also be considered.</p>

<h2 id="application-and-implications-for-thakiclouds-k8s-aiml-saas-platform">Application and Implications for ThakiCloud’s K8s AI/ML SaaS Platform</h2>

<p>The real value of this tool lies not in “free” but in the <strong>connection pattern</strong>. Once an Anthropic-compatible proxy is inserted as a layer, commercial agents like Claude Code can be attached directly to our infrastructure.</p>

<p>ThakiCloud schedules GPUs with Kueue and serves models with vLLM on Kubernetes. Since vLLM provides an OpenAI-compatible endpoint (<code class="language-plaintext highlighter-rouge">/v1/chat/completions</code>), it can be connected to <code class="language-plaintext highlighter-rouge">free-claude-code</code>’s self-hosted provider path in the same way as Ollama or llama.cpp. The connection method is common across self-hosted providers: specify the base URL as the cluster’s vLLM service endpoint and add the provider prefix to the model identifier. Just as Ollama uses <code class="language-plaintext highlighter-rouge">ollama/llama3.2:3b</code>, an in-house model served on vLLM is added to the routing targets with the same prefix convention. This enables the following:</p>

<ul>
  <li><strong>Data sovereignty</strong>: Code and prompts never leave the tenancy boundary. This is essential in regulated environments such as on-premises deployment and NIS (National Intelligence Service) compliance requirements.</li>
  <li><strong>Cost structure shift</strong>: Per-token metered billing is replaced by fixed GPU costs. The higher the usage, the faster self-serving reaches its break-even point.</li>
  <li><strong>Tiered differentiated placement</strong>: Lightweight Haiku traffic can be routed to small models, and heavier workloads to larger ones, optimizing GPU occupancy. The measurements above provide baseline numbers for this differentiated placement.</li>
</ul>

<p>That said, rather than adopting this tool as-is, it is more rational to <strong>borrow only the validated routing pattern</strong>. In a multi-tenant environment, the proxy must have per-tenant authentication, isolation, and observability, but <code class="language-plaintext highlighter-rouge">free-claude-code</code>’s admin UI assumes a single loopback user and is insufficient as-is. The idea behind the Anthropic-compatible normalization layer is worth borrowing, but authentication, quotas, and logging must be re-implemented to match our gateway standards.</p>

<h2 id="limitations-and-counterarguments">Limitations and Counterarguments</h2>

<p>First, there is the <strong>Terms of Service gray area</strong>. The “Claude Code for free” framing relies on routing through free-tier providers, which may conflict with each service’s terms. In enterprise environments, legitimate and sustainable use is strictly <strong>routing to owned backends (self-served models)</strong>. This is why this article emphasizes only the self-hosting path.</p>

<p>Second, there is <strong>aggressive version pinning</strong>. As seen above, the hard Python 3.14 requirement immediately prevents booting in environments without a stable runtime. Considering the cost and risk of upgrading production container images to 3.14, inserting this tool directly into a deployment pipeline at this point carries too much friction.</p>

<p>Third, <strong>quality equivalence is not guaranteed</strong>. Replacing Claude’s Opus or Sonnet with different models does not preserve coding quality. Routing is a trade-off that gains cost savings and data sovereignty at the expense of response quality; which traffic to send where must be determined by measurement, depending on task difficulty.</p>

<p>Fourth, the measurements in this report are <strong>direct backend call numbers without going through the proxy</strong>. The normalization and routing overhead of fcc is not included. Once a stable Python 3.14 environment is secured, I plan to re-measure the round-trip latency through the proxy and supplement these results.</p>

<p>In summary, <code class="language-plaintext highlighter-rouge">free-claude-code</code> is risky if consumed as a “free hack,” but read as an <strong>open-source reference for Anthropic-compatible routing patterns</strong>, it is a solid starting point for the design of connecting commercial agents to self-hosted inference infrastructure.</p>

<h2 id="sources">Sources</h2>

<ul>
  <li>GitHub: <a href="https://github.com/Alishahryar1/free-claude-code">Alishahryar1/free-claude-code</a> (MIT, 36.7k stars, v2.3.14)</li>
  <li>Measurement data: Direct calls to local Ollama OpenAI-compatible endpoint (llama3.2:3b, qwen2.5:7b, qwen3:8b, Apple Silicon)</li>
  <li>Related article: ThakiCloud Tech Blog “Routing Claude Code to In-House Models - claude-code-router”</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="free-claude-code" /><category term="Claude Code" /><category term="LLM Gateway" /><category term="Model Routing" /><category term="Ollama" /><category term="vLLM" /><category term="Self-Hosting" /><category term="FastAPI" /><category term="LLM Ops" /><summary type="html"><![CDATA[free-claude-code (36.7k stars) intercepts Claude Code traffic through an Anthropic-compatible FastAPI proxy and routes it to 17 providers. This report documents direct routing to a local Ollama backend with latency measurements, and honestly records the deployment risk introduced by a hard Python 3.14 requirement.]]></summary></entry><entry xml:lang="en"><title type="html">Running Gemma 4 26B 16x Parallel on a Single DGX Spark: NVFP4 Quantization and an Honest Cost-Efficiency Review</title><link href="https://thakicloud.github.io/en/owm/gemma-4-26b-nvfp4-dgx-spark/" rel="alternate" type="text/html" title="Running Gemma 4 26B 16x Parallel on a Single DGX Spark: NVFP4 Quantization and an Honest Cost-Efficiency Review" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/owm/gemma-4-26b-nvfp4-dgx-spark</id><content type="html" xml:base="https://thakicloud.github.io/en/owm/gemma-4-26b-nvfp4-dgx-spark/"><![CDATA[<p>⏱️ <strong>Estimated reading time</strong>: 12 min</p>

<p><img src="/assets/images/gemma-4-26b-nvfp4-dgx-spark-hero.png" alt="Gemma 4 26B NVFP4 parallel inference concept diagram" /></p>

<h2 id="overview">Overview</h2>

<p>A demo showing a small desktop box running 16 concurrent sessions of a large MoE model has been making waves. The demo uses <code class="language-plaintext highlighter-rouge">Gemma-4-26B-A4B-NVFP4</code> published by NVIDIA, running 16 parallel streams on a single DGX Spark (128 GB unified memory), reaching approximately 18 tokens/s per stream and about 300 tokens/s combined. The person who shared the demo noted that the concurrency was too high to display legibly on screen, so the demo was presented programmatically, that up to 32x parallelism is possible, and that flashinfer had not even been applied yet.</p>

<p>Two points are worth highlighting. First, this is not a lightweight E2B/E4B model that fits on a laptop. It is a full-scale Gemma MoE with 25.2 billion total parameters. Second, the reason this is possible is the combination of three factors: NVFP4 4-bit quantization, the small active-parameter footprint of MoE, and the large unified memory of the DGX Spark.</p>

<p>ThakiCloud operates a platform that serves LLMs in a multi-tenant configuration on Kubernetes. For us, “how many concurrent requests can a small on-premises box handle?” is not just an interesting demo; it is a question that feeds directly into the cost model. This post reviews the model facts, separates single-stream performance from concurrent throughput, honestly assesses whether the DGX Spark is cost-effective relative to other Blackwell GPUs, and considers how far this model fits into our skill ecosystem.</p>

<h2 id="what-the-demo-actually-showed">What the Demo Actually Showed</h2>

<p>Summarizing the claims from the original demo (<a href="https://x.com/googlegemma/status/2069452783523401804">Google Gemma team tweet</a>):</p>

<ul>
  <li>Hardware: <strong>1x DGX Spark, 128 GB unified memory (GB10 Grace-Blackwell)</strong></li>
  <li>Model: <a href="https://huggingface.co/nvidia/Gemma-4-26B-A4B-NVFP4"><code class="language-plaintext highlighter-rouge">nvidia/Gemma-4-26B-A4B-NVFP4</code></a></li>
  <li>Concurrency: <strong>16x parallel</strong>, approximately <strong>18 tokens/s per stream</strong>, <strong>approximately 300 tokens/s combined</strong></li>
  <li>Headroom: <strong>up to 32x</strong> parallelism is possible, capped at 16x for screen readability</li>
  <li>Optimization headroom: <strong>flashinfer not yet applied</strong>, so further speedup is likely once support arrives</li>
</ul>

<p>One potential misreading to address upfront: “18 tokens/s per stream” is the per-stream figure when 16 streams run simultaneously. A single stream alone is faster. The trade-off between concurrency and single-stream latency is covered below with measured numbers.</p>

<h2 id="gemma-4-26b-a4b-nvfp4-model-facts">Gemma-4-26B-A4B-NVFP4: Model Facts</h2>

<p>The model NVIDIA published is Google DeepMind’s <code class="language-plaintext highlighter-rouge">gemma-4-26B-A4B-it</code> quantized to NVFP4 using the NVIDIA Model Optimizer. Key specs from the model card:</p>

<table>
  <thead>
    <tr>
      <th>Field</th>
      <th>Value</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Base model</td>
      <td>google/gemma-4-26B-A4B-it</td>
    </tr>
    <tr>
      <td>Architecture</td>
      <td>Mixture-of-Experts (Transformer)</td>
    </tr>
    <tr>
      <td>Total parameters</td>
      <td>25.2B</td>
    </tr>
    <tr>
      <td>Active parameters</td>
      <td>3.8B (per token)</td>
    </tr>
    <tr>
      <td>Expert configuration</td>
      <td>8 active + 1 shared out of 128 experts</td>
    </tr>
    <tr>
      <td>Layers</td>
      <td>30</td>
    </tr>
    <tr>
      <td>Context</td>
      <td>256K tokens</td>
    </tr>
    <tr>
      <td>Sliding window</td>
      <td>1024 tokens</td>
    </tr>
    <tr>
      <td>Input modalities</td>
      <td>Text + image</td>
    </tr>
    <tr>
      <td>Quantization</td>
      <td>NVFP4 (Model Optimizer v0.43.0)</td>
    </tr>
    <tr>
      <td>Target hardware</td>
      <td>NVIDIA Blackwell</td>
    </tr>
    <tr>
      <td>License</td>
      <td>Apache 2.0</td>
    </tr>
  </tbody>
</table>

<h3 id="what-nvfp4-is-and-why-it-requires-blackwell">What NVFP4 Is and Why It Requires Blackwell</h3>

<p>NVFP4 is a 4-bit floating-point format accelerated in hardware on NVIDIA’s Blackwell generation. Unlike INT4 quantization, which simply truncates weights to 4-bit integers, NVFP4 uses microscaling with FP8 scale factors at small block granularity. This allows memory savings comparable to INT4 while keeping accuracy loss small.</p>

<p>The memory impact is most direct. Storing 25.2B parameters in BF16 requires roughly 50 GB; NVFP4 compresses the weights to approximately <strong>14 to 16 GB</strong>. On the DGX Spark’s 128 GB unified memory, with weights at 16 GB, more than 100 GB remains available for the KV cache. That headroom is what enables 16 to 32x concurrency and long 256K-token contexts.</p>

<p>The hardware acceleration for NVFP4 is Blackwell-exclusive. On older generations like Hopper (H100) or Ada (RTX 4090), there are no NVFP4 tensor core paths, so the format’s benefits cannot be realized. In practice, this model is built to run on Blackwell.</p>

<h3 id="benchmark-how-much-does-nvfp4-quantization-cost">Benchmark: How Much Does NVFP4 Quantization Cost?</h3>

<p>The model card presents NVFP4 and baseline (unquantized) scores side by side:</p>

<table>
  <thead>
    <tr>
      <th>Benchmark</th>
      <th>NVFP4</th>
      <th>Baseline</th>
      <th>Domain</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>AIME 2025</td>
      <td>90.00%</td>
      <td>88.95%</td>
      <td>Math competition</td>
    </tr>
    <tr>
      <td>MMLU Pro</td>
      <td>84.80%</td>
      <td>85.00%</td>
      <td>General knowledge and reasoning</td>
    </tr>
    <tr>
      <td>IFBench</td>
      <td>78.1%</td>
      <td>77.77%</td>
      <td>Instruction following</td>
    </tr>
    <tr>
      <td>GPQA Diamond</td>
      <td>79.90%</td>
      <td>80.30%</td>
      <td>Graduate-level science reasoning</td>
    </tr>
  </tbody>
</table>

<p>All four benchmarks are within 1 percentage point of baseline. AIME and IFBench are slightly higher for the quantized version, which is most safely interpreted as measurement variance. The key takeaway is that “4-bit compression preserves quality in practice,” which is exactly the advantage NVFP4 claims over INT4. That said, none of the public benchmarks cover Korean-language tasks, so separate internal evaluation is recommended for Korean-domain use cases.</p>

<h2 id="real-performance-single-stream-vs-concurrency">Real Performance: Single Stream vs. Concurrency</h2>

<p>The “18 tokens/s per stream” from the demo can seem slow in isolation. The numbers need to be read with single-stream and concurrent modes separated. Synthesizing community reports measuring this model on the DGX Spark:</p>

<ul>
  <li><strong>Single stream, no MTP</strong>: approximately 32 tokens/s (with 64k context setting)</li>
  <li><strong>Single stream + MTP (Multi-Token Prediction)</strong>: approximately <strong>55 to 61 tokens/s</strong> (32k context setting, best on short-to-medium responses and structured JSON)</li>
  <li><strong>16x concurrency</strong>: approximately 18 tokens/s per stream, <strong>approximately 300 tokens/s combined</strong></li>
  <li><strong>Long-context prefill</strong>: approximately 11.9 s for 25k-token input, approximately 28.6 s for 50k-token input (64k context setting)</li>
</ul>

<p>Two observations stand out.</p>

<p>First, <strong>MoE decoding is memory-bandwidth-bound</strong>. With only 3.8B active parameters per token, compute (FLOPs) is light, but every token requires fetching the active expert weights from memory. The DGX Spark’s LPDDR5X unified memory has lower bandwidth than datacenter HBM, which is why single-stream speed is “modest for a Blackwell.” Even with FP4 compute capacity to spare, bandwidth is the ceiling.</p>

<p>Second, the DGX Spark’s real strength is not single-stream latency but <strong>aggregate concurrent throughput</strong>. Getting approximately 300 tokens/s across 16 streams means multiple requests share bandwidth efficiently. The large unified memory that allows a generous KV cache pool makes this possible. In other words, the machine is better suited to “serving many agents or users concurrently at adequate speed” than “delivering the fastest single response.”</p>

<pre><code class="language-mermaid">flowchart LR
    subgraph Spark["DGX Spark · 128 GB Unified Memory"]
      W["NVFP4 Weights&lt;br/&gt;~16 GB"]
      KV["KV Cache Pool&lt;br/&gt;~100 GB+ headroom"]
    end
    R1["Request 1"] --&gt; Spark
    R2["Request 2"] --&gt; Spark
    R3["..."] --&gt; Spark
    R16["Request 16"] --&gt; Spark
    Spark --&gt; O["~18 tok/s per stream&lt;br/&gt;~300 tok/s combined"]
</code></pre>

<h2 id="honest-review-1-is-the-dgx-spark-actually-cost-effective">Honest Review 1: Is the DGX Spark Actually Cost-Effective?</h2>

<p>The short answer is: <strong>exceptional value per unit of memory, average value per unit of token latency</strong>. Different Blackwell chips have different characteristics.</p>

<table>
  <thead>
    <tr>
      <th>Chip</th>
      <th>Price (USD)</th>
      <th>Memory</th>
      <th>Bandwidth</th>
      <th>NVFP4 MoE status (2026-06)</th>
      <th>Character</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>DGX Spark</strong> (GB10, SM121)</td>
      <td>~$4,699</td>
      <td>128 GB unified LPDDR5X</td>
      <td>273 GB/s</td>
      <td>✅ Working (vLLM Marlin backend)</td>
      <td>Large memory, high concurrency, low bandwidth</td>
    </tr>
    <tr>
      <td><strong>RTX 5090</strong> (SM120)</td>
      <td>~$2,000 [estimate]</td>
      <td>32 GB GDDR7</td>
      <td>1,792 GB/s</td>
      <td>⚠️ Currently broken (flashinfer #2577)</td>
      <td>Best $/token potential, small VRAM</td>
    </tr>
    <tr>
      <td><strong>RTX PRO 6000</strong> Blackwell (SM120)</td>
      <td>~$8,500</td>
      <td>96 GB GDDR7</td>
      <td>1,792 GB/s</td>
      <td>⚠️ Same SM120 issue</td>
      <td>Large VRAM, overkill for this model</td>
    </tr>
    <tr>
      <td><strong>B200</strong> (SM100, datacenter)</td>
      <td>~$3 to $10/hr cloud [estimate]</td>
      <td>192 GB HBM3e</td>
      <td>8,000 GB/s</td>
      <td>✅ Fully supported (TRT-LLM/flashinfer)</td>
      <td>Maximum performance, order-of-magnitude cost difference</td>
    </tr>
  </tbody>
</table>

<p>The most important column in this table is not price but <strong>NVFP4 MoE status</strong>, because that is where theory and reality diverge.</p>

<ul>
  <li><strong>On paper, the RTX 5090 wins on $/token.</strong> Its bandwidth is 6.6x that of the DGX Spark (1,792 vs. 273 GB/s), and since MoE decoding is bandwidth-bound, theoretical throughput ceilings follow almost directly. Reading 16 GB of weights at 273 GB/s gives a theoretical ceiling of roughly 170 tokens/s; at 1,792 GB/s, roughly 1,100 tokens/s. The RTX 5090 costs about half as much, so in simple arithmetic it is 5 to 6x more efficient.</li>
  <li><strong>In reality, NVFP4 MoE kernels are currently broken on consumer and professional Blackwell (SM120).</strong> The flashinfer NVFP4 GEMM issue on SM120 (<a href="https://github.com/flashinfer-ai/flashinfer/issues/2577">#2577</a>) remains open, making it effectively impossible to run this 4-bit MoE correctly on the RTX 5090 or RTX PRO 6000. The on-paper leader is, for now, “can’t run it.”</li>
  <li><strong>That leaves the DGX Spark (SM121) as the only consumer-class box where NVFP4 MoE actually works today.</strong> Bandwidth is lower, so throughput is conservative, but “the 4-bit MoE box that runs today” is the actual reason this demo came from a DGX Spark.</li>
  <li><strong>Datacenter Blackwell (B200, SM100)</strong> ships with full TRT-LLM and flashinfer NVFP4 support, but the per-unit cost is an order of magnitude different. 24/7 self-hosted serving favors owned hardware; burst or multi-tenant workloads may favor cloud B200.</li>
</ul>

<p>In summary, the DGX Spark is not a machine for buying frontier-level per-token speed. It is a machine for <strong>buying large memory and high concurrency, in a form that works today, at a relatively accessible price for development, prototyping, and small-scale concurrent serving.</strong> Once SM120 kernels are fixed, the RTX 5090’s theoretical cost advantage becomes real. Until then, the DGX Spark’s position is clear. The 16x parallel demo is impressive precisely because it builds on that strength.</p>

<h2 id="honest-review-2-what-workloads-does-this-fit">Honest Review 2: What Workloads Does This Fit?</h2>

<p>Once the cost-efficiency profile is established, appropriate workloads follow naturally.</p>

<p><strong>Good fit</strong></p>

<ul>
  <li>Multiple concurrent agents: 16 to 32 workers each running at moderate speed simultaneously. Aggregate throughput is the strength.</li>
  <li>Structured output workloads: the model card confirms function calling and JSON structured output support, and MTP is fastest on short-to-medium responses and control JSON. Well-suited to classification, tagging, and extraction tasks.</li>
  <li>Long-context processing: 256K context and a large KV headroom leave room for long-document summarization and RAG context injection.</li>
  <li>On-premises prototyping: experimenting with large MoE serving on a desk without datacenter GPUs.</li>
</ul>

<p><strong>Poor fit</strong></p>

<ul>
  <li>Single-user ultra-low-latency chat: per-stream speed is slower than GDDR7 cards. Not appropriate if “fastest single response” is the goal.</li>
  <li>Hardest single-shot reasoning: tasks requiring quality headroom should use a 31B dense model, something larger, or a closed-source flagship. At 26B this is a throughput-tier model.</li>
</ul>

<h2 id="serving-guide">Serving Guide</h2>

<p>The recommended path per the model card is vLLM. Current constraints to be aware of:</p>

<ul>
  <li><strong>vLLM TP=1 only</strong>: the current build supports tensor parallelism of 1 only (assumes a single GPU or single box).</li>
  <li><strong>Gemma 4-specific parsers required</strong>: the flags <code class="language-plaintext highlighter-rouge">--tool-call-parser gemma4</code> and <code class="language-plaintext highlighter-rouge">--reasoning-parser gemma4</code> must be specified for function calling and reasoning output to parse correctly.</li>
  <li><strong>flashinfer not yet applied</strong>: the demo author stated flashinfer was not used. There is headroom for additional acceleration once attention kernel optimization is added.</li>
</ul>

<p>For production use, Linux OS and Blackwell hardware with NVFP4 tensor cores are prerequisites. Running this build on older-generation GPUs will not deliver the 4-bit acceleration benefits.</p>

<h2 id="implications-for-the-thakicloud-k8s-aiml-saas-platform">Implications for the ThakiCloud K8s AI/ML SaaS Platform</h2>

<p>ThakiCloud operates a multi-tenant platform that manages GPU quotas with Kueue and serves models with vLLM. This demo has three implications for our operational model.</p>

<p><strong>A self-hosting candidate for worker-tier models.</strong> Our agent orchestration follows the cost discipline of “workers cheap, gates expensive.” Worker tasks such as exploration, classification, summarization, and structured extraction do not need top-tier models. NVFP4 26B, with roughly 300 tokens/s combined throughput and function calling plus JSON output, is a strong candidate for running many workers concurrently on-premises. Keeping only high-risk steps such as verification, synthesis, and architectural judgment on upper-tier models creates structural cost reduction.</p>

<p><strong>Large unified memory simplifies multi-tenant KV budgeting.</strong> With weights at 16 GB on a 128 GB unified memory, the KV cache headroom exceeds 100 GB. KV cache is the first resource to run out in high-concurrency multi-tenant environments. This headroom allows generous per-tenant concurrency limits.</p>

<p><strong>A reference configuration for on-premises and compliance proposals.</strong> Apache 2.0 license plus single-box serving is a configuration that can be proposed directly to public-sector and financial clients who require self-hosting. The ability to run a large MoE on a small box without datacenter GPUs is a practical deployment path for environments with constraints such as National Intelligence Service requirements or data-residency restrictions.</p>

<h2 id="honest-review-3-where-does-this-model-fit-in-our-skill-ecosystem">Honest Review 3: Where Does This Model Fit in Our Skill Ecosystem?</h2>

<p>Most of ThakiCloud’s skill and agent ecosystem uses upper-tier models such as Opus or Sonnet as the primary. Where does NVFP4 26B slot in? Honestly:</p>

<ul>
  <li><strong>Drop-in replacement (worker tier)</strong>: file reading and grep summarization, classification and enum normalization (format-determinism workers), first-draft generation, news and document extraction. Read-only and structured tasks currently handled by haiku/sonnet sub-agents can largely be moved to on-premises 26B.</li>
  <li><strong>Conditional (with verification reinforcement)</strong>: agent tool-call workers. Function calling and JSON output are supported, so this model can serve as a terminal worker in tool-call loops. However, fan-out results must be closed with adversarial verification by an upper-tier model to prevent hallucination accumulation.</li>
  <li><strong>Not recommended (gate tier)</strong>: multi-step architectural reasoning, synthesis and verification judgments, high-risk content generation. Stages requiring quality headroom stay with Opus.</li>
</ul>

<p>The key is matching model tier to task tier. Viewing NVFP4 26B as an “Opus replacement” leads to disappointment. Viewing it as “an on-premises self-hosting candidate for the haiku/sonnet worker tier” opens a path to restructuring costs. This aligns exactly with our routing discipline: exploration cheap, gates expensive.</p>

<h2 id="limitations-and-counter-arguments">Limitations and Counter-Arguments</h2>

<p>For balance:</p>

<ul>
  <li><strong>Single-stream speed is conservative.</strong> Memory-bandwidth limitations make it slower than GDDR7 cards. Latency-sensitive workloads require a different hardware choice.</li>
  <li><strong>Demo figures are configuration-dependent.</strong> The 18 tokens/s and 300 tokens/s figures apply to 16x concurrency with specific settings. Results vary with prompt length, output length, and MTP usage. Your own workload requires re-measurement.</li>
  <li><strong>vLLM TP=1 and no flashinfer are current-snapshot constraints.</strong> These numbers will change as optimizations are added; treat this as a point-in-time reading.</li>
  <li><strong>MoE serving has operational complexity.</strong> Even though active parameters are 3.8B, all weights must reside in memory, and expert routing affects batch efficiency. “It’s small” is an oversimplification.</li>
  <li><strong>Korean-language real-world validation is needed.</strong> Public benchmarks are English-centric. Korean RAG and tool-call accuracy require internal evaluation.</li>
</ul>

<p>Even with these caveats, the combination of Apache 2.0, single-box large-MoE serving, and high concurrency backed by large memory is a genuinely attractive option for organizations considering on-premises or self-hosted deployment. Approached with the mindset of “buying cheap memory and concurrency” rather than “buying frontier speed,” DGX Spark plus NVFP4 26B has a clear and legitimate use case.</p>

<h2 id="reference-links">Reference Links</h2>

<ul>
  <li><a href="https://huggingface.co/nvidia/Gemma-4-26B-A4B-NVFP4">Gemma-4-26B-A4B-NVFP4 model card (Hugging Face)</a></li>
  <li><a href="https://x.com/googlegemma/status/2069452783523401804">Original demo tweet (Google Gemma)</a></li>
  <li><a href="https://thakicloud.github.io/owm/gemma-4-open-weight-lineup/">Full Gemma 4 lineup overview (ThakiCloud blog)</a></li>
  <li><a href="https://github.com/NVIDIA/TensorRT-Model-Optimizer">NVIDIA TensorRT Model Optimizer</a></li>
  <li><a href="https://developer.nvidia.com/blog/introducing-nvfp4-for-efficient-and-accurate-low-precision-inference/">Introducing NVFP4 (NVIDIA Developer)</a></li>
  <li><a href="https://github.com/flashinfer-ai/flashinfer/issues/2577">flashinfer NVFP4 GEMM SM120 issue #2577</a></li>
  <li><a href="https://ai-muninn.com/en/blog/dgx-spark-gemma4-26b-nvfp4-52-toks">DGX Spark Gemma 4 26B NVFP4 benchmark (ai-muninn)</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="owm" /><category term="gemma-4" /><category term="nvfp4" /><category term="dgx-spark" /><category term="blackwell" /><category term="mixture-of-experts" /><category term="quantization" /><category term="vllm" /><category term="on-premise" /><category term="inference" /><summary type="html"><![CDATA[NVIDIA's Gemma-4-26B-A4B-NVFP4 running 16 parallel streams on a single DGX Spark (128 GB unified memory) delivers roughly 18 tokens/s per stream and about 300 tokens/s combined. This post covers how NVFP4 compresses a 25.2B MoE to 14 GB, the trade-off between single-stream latency and concurrency, and an honest assessment of whether the DGX Spark is actually cost-effective compared to other Blackwell GPUs.]]></summary></entry><entry xml:lang="en"><title type="html">The Complete Gemma 4 Lineup: Five Apache 2.0 Open-Weight Models and an On-Premises Serving Guide</title><link href="https://thakicloud.github.io/en/owm/gemma-4-open-weight-lineup/" rel="alternate" type="text/html" title="The Complete Gemma 4 Lineup: Five Apache 2.0 Open-Weight Models and an On-Premises Serving Guide" /><published>2026-06-24T00:00:00+09:00</published><updated>2026-06-24T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/owm/gemma-4-open-weight-lineup</id><content type="html" xml:base="https://thakicloud.github.io/en/owm/gemma-4-open-weight-lineup/"><![CDATA[<p>⏱️ <strong>Estimated reading time</strong>: 10 min</p>

<p><img src="/assets/images/gemma-4-open-weight-lineup-hero.png" alt="Gemma 4 lineup concept" /></p>

<h2 id="gemma-4-overview">Gemma 4 Overview</h2>

<p>Released by Google DeepMind on April 2, 2026, Gemma 4 is the most intelligent open-weight model family Gemma has shipped to date. Google states that it was built on the same research and technology that underpins Gemini 3. In other words, think of it as the training recipe behind a closed flagship distilled down into an open-weight lineup.</p>

<p>From a ThakiCloud perspective, two changes stand out this generation. First, the license moved to <strong>Apache 2.0</strong>. Unlike earlier Gemma generations that carried a separate Gemma usage policy, Gemma 4 adopts a commercially permissive standard open-source license. Second, it ships not as a single size but as a five-model lineup that spans <strong>everything from the edge (phones) to a single server GPU</strong>. That means you can pick a deployment target by device tier within the same model family.</p>

<p>Rather than going deep on a single model, this post aims to <strong>compare all five models at a glance and clarify which one to choose for which situation</strong>.</p>

<h2 id="the-gemma-4-lineup-all-five-models">The Gemma 4 Lineup: All Five Models</h2>

<p>Gemma 4 consists of the following five models. Organized by parameters, context, modality, and architecture per the model card:</p>

<table>
  <thead>
    <tr>
      <th>Model</th>
      <th>Parameters</th>
      <th>Context</th>
      <th>Input Modalities</th>
      <th>Architecture</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>E2B</strong></td>
      <td>2.3B effective (5.1B with embeddings)</td>
      <td>128K</td>
      <td>Text + Image + Audio</td>
      <td>Dense</td>
    </tr>
    <tr>
      <td><strong>E4B</strong></td>
      <td>4.5B effective (8B with embeddings)</td>
      <td>128K</td>
      <td>Text + Image + Audio</td>
      <td>Dense</td>
    </tr>
    <tr>
      <td><strong>12B Unified</strong></td>
      <td>11.95B</td>
      <td>256K</td>
      <td>Text + Image + Audio</td>
      <td>Dense</td>
    </tr>
    <tr>
      <td><strong>26B A4B</strong></td>
      <td>25.2B total / 3.8B active</td>
      <td>256K</td>
      <td>Text + Image</td>
      <td>MoE (8 of 128 experts active)</td>
    </tr>
    <tr>
      <td><strong>31B Dense</strong></td>
      <td>30.7B</td>
      <td>256K</td>
      <td>Text + Image</td>
      <td>Dense</td>
    </tr>
  </tbody>
</table>

<p>All five output text. Audio input is supported only on the E2B, E4B, and 12B models; the 26B and 31B handle text and image.</p>

<p>The “E” in <code class="language-plaintext highlighter-rouge">E2B</code> and <code class="language-plaintext highlighter-rouge">E4B</code> stands for effective parameters. It is the size based on actual compute parameters excluding the embedding table, and effective values are the more realistic figure when gauging memory and compute budgets. Both models squarely target edge devices such as phones and laptops.</p>

<p>The heart of the lineup is the <strong>division of labor between the two top models: the 26B A4B (MoE) and the 31B (Dense)</strong>.</p>

<ul>
  <li><strong>26B A4B</strong> is a Mixture-of-Experts. It holds 25.2B total parameters but activates only about 3.8B per token. The full weights still have to sit in VRAM, but per-token compute (FLOPs) is based on the active parameters, which is <strong>favorable for latency and throughput</strong>. It suits serving where you need to push large volumes of requests quickly.</li>
  <li><strong>31B Dense</strong> is a standard dense model where every parameter participates on every token. Oriented toward maximizing quality and fine-tuning suitability, Google positions the 31B as the quality ceiling of the lineup.</li>
</ul>

<p>According to Google, the 31B ranked #3 among open models worldwide on the Arena AI text leaderboard and the 26B placed #6, and it described the lineup as “competing with models 20x its size.” Such leaderboard rankings shift over time, so it is better to read them as a direction (“high intelligence density relative to its class”) than as absolute figures.</p>

<h3 id="model-selection-flow">Model Selection Flow</h3>

<pre><code class="language-mermaid">flowchart TD
    A[Choose a Gemma 4 model] --&gt; B{Deployment target?}
    B --&gt;|Phone/edge device| C[E2B / E4B&lt;br/&gt;128K, audio support]
    B --&gt;|Single-GPU on-prem| D{Priority?}
    D --&gt;|Throughput/latency| E[26B A4B MoE&lt;br/&gt;active 3.8B]
    D --&gt;|Top quality/fine-tuning| F[31B Dense]
    D --&gt;|Multimodal + audio + balance| G[12B Unified&lt;br/&gt;256K, audio support]
</code></pre>

<h2 id="architecture-hybrid-attention-and-multimodality">Architecture: Hybrid Attention and Multimodality</h2>

<p>All five Gemma 4 models share a <strong>hybrid attention</strong> mechanism. It interleaves local sliding-window attention with full global attention. Short ranges are handled cheaply by the sliding window, while global attention is periodically inserted to capture full-context dependencies, with the goal of curbing memory and compute cost on long contexts. This design is the backdrop to the upper models (12B/26B/31B) handling a 256K context.</p>

<p>Multimodality is the default this generation. All five take text and image as input, and the edge/mid tiers (E2B/E4B/12B) also handle audio input. Features aimed at agentic workflows are built in too. Function calling, structured JSON output, and native system instructions are officially supported, and the lineup emphasizes improvements in multi-step planning and logical reasoning over the previous generation. The training data cutoff is January 2025.</p>

<p>Language support is broad: 35+ languages out of the box and 140+ languages at the pretraining level. Actual quality in Korean operation requires direct evaluation, but the multilingual coverage itself is wide.</p>

<h2 id="benchmarks">Benchmarks</h2>

<p>The representative benchmarks Google published for the 31B instruction-tuned model are below, per the model card.</p>

<table>
  <thead>
    <tr>
      <th>Benchmark</th>
      <th>31B (IT)</th>
      <th>Area Measured</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>MMLU-Pro</td>
      <td>85.2%</td>
      <td>General knowledge &amp; reasoning</td>
    </tr>
    <tr>
      <td>GPQA Diamond</td>
      <td>84.3%</td>
      <td>Graduate-level science reasoning</td>
    </tr>
    <tr>
      <td>LiveCodeBench v6</td>
      <td>80.0%</td>
      <td>Code generation</td>
    </tr>
    <tr>
      <td>MATH-Vision</td>
      <td>85.6%</td>
      <td>Vision-grounded math</td>
    </tr>
    <tr>
      <td>Codeforces (ELO)</td>
      <td>2150</td>
      <td>Competitive programming</td>
    </tr>
  </tbody>
</table>

<p>At the 31B single-node scale, GPQA Diamond at 84.3% and MMLU-Pro at 85.2% are top-tier among comparable open-weight models. That said, the benchmarks are for the instruction-tuned variant, and real domain-task performance must be validated separately. In particular, Korean reasoning and coding tasks are not directly reflected in public benchmarks, so measuring them with an internal eval set is recommended.</p>

<h2 id="serving-and-deployment">Serving and Deployment</h2>

<p>Gemma 4 secured broad serving-ecosystem support from launch. The official paths are:</p>

<ul>
  <li><strong>Inference servers</strong>: vLLM, SGLang, llama.cpp, Ollama, LM Studio, NVIDIA NIM</li>
  <li><strong>Frameworks</strong>: Hugging Face Transformers / TRL / Transformers.js / Candle, Keras, MaxText, NeMo</li>
  <li><strong>Edge/on-device</strong>: LiteRT-LM, Cactus</li>
  <li><strong>Fine-tuning/quantization</strong>: Unsloth, Tunix</li>
  <li><strong>Deployment infra</strong>: Docker, Baseten, Google Cloud (Vertex AI)</li>
</ul>

<p>Weights can be downloaded from the <a href="https://huggingface.co/collections/google/gemma-4">google/gemma-4 collection on Hugging Face</a>, Kaggle, and Ollama.</p>

<h3 id="on-prem-gpu-requirements-estimated">On-Prem GPU Requirements (Estimated)</h3>

<p>A rough on-prem deployment guide based on each model’s BF16 weight memory. These are weight estimates excluding KV cache and runtime overhead, so leave headroom for your context length and concurrent request count in an actual deployment.</p>

<table>
  <thead>
    <tr>
      <th>Model</th>
      <th>BF16 weights (est.)</th>
      <th>Realistic on-prem starting point</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>E2B / E4B</td>
      <td>~5–16GB [est.]</td>
      <td>Consumer GPU, laptop, phone (LiteRT)</td>
    </tr>
    <tr>
      <td>12B Unified</td>
      <td>~24GB [est.]</td>
      <td>Single 24GB GPU (RTX 4090/L4 class), headroom when quantized</td>
    </tr>
    <tr>
      <td>26B A4B (MoE)</td>
      <td>~50GB [est.]</td>
      <td>A single H100/A100 80GB</td>
    </tr>
    <tr>
      <td>31B Dense</td>
      <td>~62GB [est.]</td>
      <td>A single H100/A100 80GB</td>
    </tr>
  </tbody>
</table>

<p>The practical strength of the lineup is that both top models (26B, 31B) fit on <strong>a single 80GB GPU</strong> in BF16. That means you can run frontier-grade inference on a single server without multi-node tensor parallelism, which sharply lowers the bar to on-prem adoption. With a smaller GPU budget, step down to the 12B or to a quantized path (GGUF Q4/Q8). Thanks to its MoE nature computing only the active 3.8B, the 26B has a throughput edge per token over the 31B Dense at the same VRAM.</p>

<h2 id="implications-for-the-thakicloud-k8s-aiml-saas-platform">Implications for the ThakiCloud K8s AI/ML SaaS Platform</h2>

<p>The Gemma 4 lineup meshes well with ThakiCloud’s multi-tenant serving strategy. It matters on three fronts.</p>

<p><strong>Apache 2.0 unlocks the adoption barrier.</strong> A frontier-grade open-weight family released under standard Apache 2.0 is highly significant for enterprise and on-prem adoption. You can embed it in commercial services without the burden of reviewing a separate usage policy and freely distribute fine-tuned artifacts. It is a model family you can propose directly to environments with strict license compliance, such as domestic public-sector and finance, and to on-prem customers who require self-hosting.</p>

<p><strong>The lineup itself aligns with multi-tenant GPU routing.</strong> ThakiCloud manages GPU quotas with Kueue and serves models with vLLM. Gemma 4’s five-model lineup is a structure that lets you route model tiers within one family to match tenant needs (latency-sensitive, quality-first, edge inference). Route light chat/summarization to the 12B, throughput-critical batches to the 26B MoE, and high-difficulty reasoning/coding to the 31B, and you can optimize the GPU budget by task tier while keeping the same tokenizer and prompt format.</p>

<p><strong>Single-80GB-GPU serving simplifies the cost model.</strong> That the 26B and 31B fit on a single H100/A100 simplifies Kueue GPU job cost estimation. The communication overhead and scheduling complexity of multi-node tensor parallelism disappear, so you can price cleanly with a per-tenant dedicated-single-GPU model. The 26B MoE’s active-3.8B trait means it can take more concurrent requests on the same GPU, which is also favorable on a per-request unit-cost basis.</p>

<p>In short, Gemma 4 is a fit as a reference model family when ThakiCloud proposes a “single-GPU on-prem + multi-tenant model routing” operating pattern to customers.</p>

<h2 id="limitations-and-counterpoints">Limitations and Counterpoints</h2>

<p>For balance, a few caveats deserve mention.</p>

<ul>
  <li><strong>The gap between benchmarks and real use.</strong> The published figures center on the instruction-tuned, English-language benchmarks. Korean domain tasks, especially RAG and agent tool-call accuracy, must be re-measured with your own eval set.</li>
  <li><strong>The operational difficulty of MoE serving.</strong> The 26B A4B has low per-token compute but must keep the full weights resident in VRAM, and expert routing affects batch efficiency and memory patterns. The simplistic reading “it’s small because active is 3.8B” is risky.</li>
  <li><strong>Asymmetric audio support.</strong> Audio input exists only on E2B/E4B/12B. If you want top quality (26B/31B) and audio at the same time, a trade-off arises within the lineup.</li>
  <li><strong>January 2025 training cutoff.</strong> Tasks needing the latest information must be supplemented with RAG and tool integration.</li>
</ul>

<p>Even so, the Apache 2.0 license, the feasibility of single-GPU serving, and a lineup that bridges the edge to the server are reason enough to put Gemma 4 at the top of the evaluation list for any organization considering on-prem and self-hosting.</p>

<h2 id="references">References</h2>

<ul>
  <li><a href="https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/">Gemma 4 official announcement blog (Google)</a></li>
  <li><a href="https://ai.google.dev/gemma/docs/core/model_card_4">Gemma 4 model card (Google AI for Developers)</a></li>
  <li><a href="https://ai.google.dev/gemma/docs/core">Gemma 4 model overview docs</a></li>
  <li><a href="https://huggingface.co/collections/google/gemma-4">google/gemma-4 collection on Hugging Face</a></li>
  <li><a href="https://github.com/google-deepmind/gemma">Google DeepMind Gemma GitHub library</a></li>
  <li><a href="https://cloud.google.com/blog/products/ai-machine-learning/gemma-4-available-on-google-cloud">Gemma 4 availability on Google Cloud</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="owm" /><category term="gemma-4" /><category term="google-deepmind" /><category term="open-weight" /><category term="apache-2.0" /><category term="mixture-of-experts" /><category term="multimodal" /><category term="edge-ai" /><category term="vllm" /><category term="sglang" /><category term="on-premise" /><summary type="html"><![CDATA[Released by Google DeepMind in April 2026, Gemma 4 is a multimodal open-weight family of five models spanning E2B to 31B. We break down the Apache 2.0 license, 256K context, the difference between the 26B MoE and 31B Dense, and how to pick each model from an on-premises serving perspective.]]></summary></entry></feed>