diff --git a/ollamagemma426bv3/Chart.yaml b/ollamagemma426bv3/Chart.yaml index fd4463634..f9b5467d6 100644 --- a/ollamagemma426bv3/Chart.yaml +++ b/ollamagemma426bv3/Chart.yaml @@ -3,4 +3,4 @@ appVersion: 0.32.1 description: Gemma 4 26B served with Ollama + llm-init (GPU only) name: ollamagemma426bv3 type: application -version: 1.0.6 \ No newline at end of file +version: 1.0.18 \ No newline at end of file diff --git a/ollamagemma426bv3/OlaresManifest.yaml b/ollamagemma426bv3/OlaresManifest.yaml index 45ad0fb50..ed86214ed 100644 --- a/ollamagemma426bv3/OlaresManifest.yaml +++ b/ollamagemma426bv3/OlaresManifest.yaml @@ -4,12 +4,15 @@ apiVersion: 'v3' metadata: name: ollamagemma426bv3 icon: https://app.cdn.olares.com/appstore/llm/ollama/gemma.png - description: "Gemma 4 26B served with Ollama." + description: A local AI model for text generation, coding, and image understanding appid: ollamagemma426bv3 title: Gemma 4 26B (Ollama) - version: '1.0.6' + version: '1.0.18' categories: - - AI + - AI + - models + tags: + - llm sharedEntrances: - name: ollamagemma426bv3 host: sharedentrances-api @@ -34,50 +37,38 @@ workloadReplicas: spec: onlyAdmin: true versionName: 'gemma4:26b' - upgradeDescription: | - v1.0.6: bump ollama to 0.32.1. - v1.0.5: nvidia host memory — requiredMemory 22Gi, OLLAMA_MEMORY_REQUEST 21Gi, OLLAMA_MEMORY_LIMIT 30Gi; llm-init limit 2Gi; limitedMemory 32Gi. - v1.0.4: bump ollama to 0.31.2. - v1.0.4: bump llm-init to v1.3.1. fullDescription: | - **Model Overview** - Gemma 4 26B is a mixture-of-experts model from Google's Gemma 4 family, instruction-tuned for reasoning, coding, and multimodal tasks. It supports thinking, tool calling, and vision, with broad multimodal coverage including video and audio in the Gemma 4 line. This app pulls `gemma4:26b` from the Ollama library. + Gemma 4 26B A4B is a model from Google DeepMind that takes text and images as input and generates text responses. This app runs the model locally with Ollama for conversations, coding assistance, and questions about images. - Recommended when you need high decode throughput alongside rich multimodal support. Gemma 4 26B offers extensive multimodal capabilities for vision, video, and audio workloads. + **Key features** - **Preset Configuration** - - Model: `gemma4:26b` - - Capabilities: thinking, tools, vision - - Engine args: `OLLAMA_KEEP_ALIVE=-1 OLLAMA_CONTEXT_LENGTH=131072 OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 OLLAMA_NUM_PARALLEL=1` (128K context, keep model in VRAM, flash attention, q8_0 KV cache) - - Required GPU memory: `23Gi` + - Generate and summarize text, answer questions, and assist with code. + - Interpret images and respond to prompts that combine text and images. + - Use a thinking mode for reasoning tasks. + - Support tool calling in compatible applications that provide tools. - **Accelerator modes** - | Mode | Device | Details | - |----------------|-------------------|----------------------------------------------------------------------| - | `nvidia` | GPU (CUDA) | Uses `23Gi` GPU memory; Ollama uses GPU by default | - | `nvidia-gb10` | GPU (Spark) | Like above, but memory is managed by the pod | - - **How It Works** - First, Model Console pulls the model from the Ollama library and gets it ready, then the Ollama daemon starts serving the model when it's ready. These two parts run separately but share files and progress info. + **Using the model on Olares** - **Stack** - - **Ollama daemon** (port 11434): pulls and serves the model - - **Model Console** (port 8090): drives model pull, shows progress, and provides the OpenAI API, proxying to Ollama + The app downloads `gemma4:26b` from the Ollama library. Model Console shows download progress and manages the model for use by compatible Olares applications. The default context window is 128K tokens, which limits how much conversation and other input the model can process at once. - **Model Storage** - All pulled models are stored in a shared folder at `appCommon/ollama`. All Ollama-based apps share this location, so blobs deduplicate by digest across installs. + [Gemma 4 documentation](https://ai.google.dev/gemma/docs/core/model_card_4) - - developer: Google + developer: Google DeepMind website: https://ai.google.dev/gemma - sourceCode: https://huggingface.co/google/gemma-4-26b-it + sourceCode: https://huggingface.co/google/gemma-4-26B-A4B-it + doc: https://ai.google.dev/gemma/docs/core/model_card_4 submitter: Olares locale: - en-US - zh-CN + - de-DE + - es-ES + - it-IT + - fr-FR + - ja-JP license: - - text: Gemma Terms of Use - url: https://ai.google.dev/gemma/terms + - text: Apache-2.0 + url: https://ai.google.dev/gemma/apache_2 accelerator: # nvidia — discrete GPU; OLLAMA_REQUIRED_GPU_MEMORY -> gpumem @@ -87,9 +78,9 @@ spec: requiredCpu: "1300m" requiredDisk: 50Mi limitedDisk: 500Gi - # Engine MEMORY_REQUEST 21Gi + llm-init <= requiredMemory 22Gi; MEMORY_LIMIT 30Gi + llm-init 2Gi <= limitedMemory 32Gi + # Engine MEMORY_REQUEST 6Gi + llm-init <= requiredMemory 7Gi; MEMORY_LIMIT 30Gi + llm-init 2Gi <= limitedMemory 32Gi limitedMemory: "32Gi" - requiredMemory: "22Gi" + requiredMemory: "7Gi" requiredGPUMemory: "23Gi" limitedGPUMemory: "24Gi" - mode: nvidia-gb10 @@ -103,6 +94,9 @@ spec: - amd64 - arm64 permission: + # appCache holds the shared RUN_DIR handoff dir + # (/llm-init-run/), same as the llamacpp charts. + appCache: true appData: true appCommon: true options: @@ -188,9 +182,9 @@ envs: type: string editable: false applyOnChange: false - - envName: OLLAMA_MEMORY_REQUEST # sum with llm-init <= requiredMemory 22Gi + - envName: OLLAMA_MEMORY_REQUEST # sum with llm-init <= requiredMemory 7Gi required: true - default: "21Gi" + default: "6Gi" type: string editable: false applyOnChange: false diff --git a/ollamagemma426bv3/i18n/de-DE/OlaresManifest.yaml b/ollamagemma426bv3/i18n/de-DE/OlaresManifest.yaml new file mode 100644 index 000000000..ccb8c2fd7 --- /dev/null +++ b/ollamagemma426bv3/i18n/de-DE/OlaresManifest.yaml @@ -0,0 +1,19 @@ +metadata: + title: Gemma 4 26B (Ollama) + description: Ein lokales KI-Modell für Textgenerierung, Programmierhilfe und Bildverständnis +spec: + fullDescription: | + Gemma 4 26B A4B ist ein Modell von Google DeepMind, das Text und Bilder als Eingabe verarbeitet und Textantworten erzeugt. Diese App führt das Modell lokal mit Ollama aus, um Gespräche, Programmierhilfe und Fragen zu Bildern zu ermöglichen. + + **Hauptfunktionen** + + - Texte erzeugen und zusammenfassen, Fragen beantworten und beim Programmieren helfen. + - Bilder interpretieren und auf Eingaben antworten, die Text und Bilder kombinieren. + - Einen Denkmodus für Schlussfolgerungsaufgaben nutzen. + - Werkzeugaufrufe in kompatiblen Anwendungen unterstützen, die Werkzeuge bereitstellen. + + **Das Modell auf Olares verwenden** + + Die App lädt `gemma4:26b` aus der Ollama-Bibliothek herunter. Model Console zeigt den Downloadfortschritt an und verwaltet das Modell für kompatible Olares-Anwendungen. Das voreingestellte Kontextfenster umfasst 128K Tokens und begrenzt die Menge an Gesprächsinhalten und weiteren Eingaben, die das Modell gleichzeitig verarbeiten kann. + + [Gemma-4-Dokumentation](https://ai.google.dev/gemma/docs/core/model_card_4) diff --git a/ollamagemma426bv3/i18n/en-US/OlaresManifest.yaml b/ollamagemma426bv3/i18n/en-US/OlaresManifest.yaml index 5331cfadd..169dbd0b9 100644 --- a/ollamagemma426bv3/i18n/en-US/OlaresManifest.yaml +++ b/ollamagemma426bv3/i18n/en-US/OlaresManifest.yaml @@ -1,33 +1,19 @@ metadata: - description: "Gemma 4 26B served with Ollama." title: Gemma 4 26B (Ollama) - + description: A local AI model for text generation, coding, and image understanding spec: fullDescription: | - **Model Overview** - Gemma 4 26B is a mixture-of-experts model from Google's Gemma 4 family, instruction-tuned for reasoning, coding, and multimodal tasks. It supports thinking, tool calling, and vision, with broad multimodal coverage including video and audio in the Gemma 4 line. This app pulls `gemma4:26b` from the Ollama library. - - Recommended when you need high decode throughput alongside rich multimodal support. Gemma 4 26B offers extensive multimodal capabilities for vision, video, and audio workloads. + Gemma 4 26B A4B is a model from Google DeepMind that takes text and images as input and generates text responses. This app runs the model locally with Ollama for conversations, coding assistance, and questions about images. - **Preset Configuration** - - Model: `gemma4:26b` - - Capabilities: thinking, tools, vision - - Engine args: `OLLAMA_KEEP_ALIVE=-1 OLLAMA_CONTEXT_LENGTH=131072 OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 OLLAMA_NUM_PARALLEL=1` (128K context, keep model in VRAM, flash attention, q8_0 KV cache) - - Required GPU memory: `23Gi` + **Key features** - **Accelerator modes** - | Mode | Device | Details | - |----------------|-------------------|----------------------------------------------------------------------| - | `nvidia` | GPU (CUDA) | Uses `23Gi` GPU memory; Ollama uses GPU by default | - | `nvidia-gb10` | GPU (Spark) | Like above, but memory is managed by the pod | - - **How It Works** - First, Model Console pulls the model from the Ollama library and gets it ready, then the Ollama daemon starts serving the model when it's ready. These two parts run separately but share files and progress info. + - Generate and summarize text, answer questions, and assist with code. + - Interpret images and respond to prompts that combine text and images. + - Use a thinking mode for reasoning tasks. + - Support tool calling in compatible applications that provide tools. - **Stack** - - **Ollama daemon** (port 11434): pulls and serves the model - - **Model Console** (port 8090): drives model pull, shows progress, and provides the OpenAI API, proxying to Ollama + **Using the model on Olares** - **Model Storage** - All pulled models are stored in a shared folder at `appCommon/ollama`. All Ollama-based apps share this location, so blobs deduplicate by digest across installs. + The app downloads `gemma4:26b` from the Ollama library. Model Console shows download progress and manages the model for use by compatible Olares applications. The default context window is 128K tokens, which limits how much conversation and other input the model can process at once. + [Gemma 4 documentation](https://ai.google.dev/gemma/docs/core/model_card_4) diff --git a/ollamagemma426bv3/i18n/es-ES/OlaresManifest.yaml b/ollamagemma426bv3/i18n/es-ES/OlaresManifest.yaml new file mode 100644 index 000000000..3af17cea8 --- /dev/null +++ b/ollamagemma426bv3/i18n/es-ES/OlaresManifest.yaml @@ -0,0 +1,19 @@ +metadata: + title: Gemma 4 26B (Ollama) + description: Un modelo de IA local para generar texto, ayudar a programar y comprender imágenes +spec: + fullDescription: | + Gemma 4 26B A4B es un modelo de Google DeepMind que recibe texto e imágenes y genera respuestas de texto. Esta aplicación ejecuta el modelo localmente con Ollama para conversaciones, ayuda con la programación y preguntas sobre imágenes. + + **Funciones principales** + + - Generar y resumir textos, responder preguntas y ayudar con la programación. + - Interpretar imágenes y responder a instrucciones que combinan texto e imágenes. + - Utilizar un modo de pensamiento para tareas de razonamiento. + - Admitir llamadas a herramientas en aplicaciones compatibles que las proporcionen. + + **Usar el modelo en Olares** + + La aplicación descarga `gemma4:26b` de la biblioteca de Ollama. Model Console muestra el progreso de la descarga y gestiona el modelo para las aplicaciones Olares compatibles. La ventana de contexto predeterminada es de 128K tokens y limita la cantidad de conversación y de otras entradas que el modelo puede procesar a la vez. + + [Documentación de Gemma 4](https://ai.google.dev/gemma/docs/core/model_card_4) diff --git a/ollamagemma426bv3/i18n/fr-FR/OlaresManifest.yaml b/ollamagemma426bv3/i18n/fr-FR/OlaresManifest.yaml new file mode 100644 index 000000000..960e49587 --- /dev/null +++ b/ollamagemma426bv3/i18n/fr-FR/OlaresManifest.yaml @@ -0,0 +1,19 @@ +metadata: + title: Gemma 4 26B (Ollama) + description: Un modèle d’IA local pour générer du texte, aider à coder et comprendre des images +spec: + fullDescription: | + Gemma 4 26B A4B est un modèle de Google DeepMind qui reçoit du texte et des images et génère des réponses textuelles. Cette application exécute le modèle localement avec Ollama pour les conversations, l’aide à la programmation et les questions sur des images. + + **Fonctionnalités principales** + + - Générer et résumer du texte, répondre aux questions et aider à programmer. + - Interpréter des images et répondre à des requêtes combinant texte et images. + - Utiliser un mode de réflexion pour les tâches de raisonnement. + - Prendre en charge les appels d’outils dans les applications compatibles qui fournissent ces outils. + + **Utiliser le modèle sur Olares** + + L’application télécharge `gemma4:26b` depuis la bibliothèque Ollama. Model Console affiche la progression du téléchargement et gère le modèle pour les applications Olares compatibles. La fenêtre de contexte par défaut est de 128K tokens, ce qui limite la quantité de conversation et d’autres données d’entrée que le modèle peut traiter en une fois. + + [Documentation de Gemma 4](https://ai.google.dev/gemma/docs/core/model_card_4) diff --git a/ollamagemma426bv3/i18n/it-IT/OlaresManifest.yaml b/ollamagemma426bv3/i18n/it-IT/OlaresManifest.yaml new file mode 100644 index 000000000..63c39734f --- /dev/null +++ b/ollamagemma426bv3/i18n/it-IT/OlaresManifest.yaml @@ -0,0 +1,19 @@ +metadata: + title: Gemma 4 26B (Ollama) + description: Un modello IA locale per generare testo, assistere nella programmazione e comprendere immagini +spec: + fullDescription: | + Gemma 4 26B A4B è un modello di Google DeepMind che riceve testo e immagini e genera risposte testuali. Questa app esegue il modello localmente con Ollama per conversazioni, assistenza nella programmazione e domande sulle immagini. + + **Funzionalità principali** + + - Generare e riassumere testi, rispondere a domande e aiutare nella programmazione. + - Interpretare immagini e rispondere a richieste che combinano testo e immagini. + - Usare una modalità di riflessione per le attività di ragionamento. + - Supportare le chiamate agli strumenti nelle applicazioni compatibili che li mettono a disposizione. + + **Usare il modello su Olares** + + L’app scarica `gemma4:26b` dalla libreria Ollama. Model Console mostra l’avanzamento del download e gestisce il modello per le applicazioni Olares compatibili. La finestra di contesto predefinita è di 128K token e limita la quantità di conversazione e di altri dati in ingresso che il modello può elaborare in una volta. + + [Documentazione di Gemma 4](https://ai.google.dev/gemma/docs/core/model_card_4) diff --git a/ollamagemma426bv3/i18n/ja-JP/OlaresManifest.yaml b/ollamagemma426bv3/i18n/ja-JP/OlaresManifest.yaml new file mode 100644 index 000000000..6e1e6b230 --- /dev/null +++ b/ollamagemma426bv3/i18n/ja-JP/OlaresManifest.yaml @@ -0,0 +1,19 @@ +metadata: + title: Gemma 4 26B (Ollama) + description: 文章生成、プログラミング支援、画像理解のためのローカルAIモデル +spec: + fullDescription: | + Gemma 4 26B A4BはGoogle DeepMindのモデルで、テキストと画像を入力として受け取り、テキストで回答します。このアプリはOllamaでモデルをローカル実行し、会話、プログラミング支援、画像についての質問に利用できます。 + + **主な機能** + + - 文章の生成と要約、質問への回答、プログラミングの支援を行います。 + - 画像を解釈し、テキストと画像を組み合わせたプロンプトに回答します。 + - 推論タスクに思考モードを利用できます。 + - ツールを提供する対応アプリでツール呼び出しをサポートします。 + + **Olaresでモデルを使う** + + このアプリはOllamaライブラリから`gemma4:26b`をダウンロードします。Model Consoleでダウンロードの進捗を表示し、対応するOlaresアプリで利用できるようモデルを管理します。デフォルトのコンテキストウィンドウは128Kトークンで、モデルが一度に処理できる会話やその他の入力の量を制限します。 + + [Gemma 4のドキュメント](https://ai.google.dev/gemma/docs/core/model_card_4) diff --git a/ollamagemma426bv3/i18n/zh-CN/OlaresManifest.yaml b/ollamagemma426bv3/i18n/zh-CN/OlaresManifest.yaml index a784c419b..80e499cca 100644 --- a/ollamagemma426bv3/i18n/zh-CN/OlaresManifest.yaml +++ b/ollamagemma426bv3/i18n/zh-CN/OlaresManifest.yaml @@ -1,33 +1,19 @@ metadata: - description: "使用 Ollama 运行 Gemma 4 26B 模型。" title: Gemma 4 26B (Ollama) - + description: 用于文本生成、编程辅助和图像理解的本地 AI 模型 spec: fullDescription: | - **模型简介** - Gemma 4 26B 是 Google Gemma 4 系列的混合专家模型,经指令微调,适用于推理、编程与多模态任务。支持思考、工具调用与视觉能力,Gemma 4 系列还覆盖视频与音频等多模态场景。本应用从 Ollama 模型库拉取 `gemma4:26b`。 - - 适合需要高解码吞吐与丰富多模态能力的场景。Gemma 4 26B 在视觉、视频与音频等负载上提供广泛的多模态能力。 + Gemma 4 26B A4B 是 Google DeepMind 开发的模型,可接收文本和图像输入并生成文本回复。本应用通过 Ollama 在本地运行该模型,用于对话、编程辅助和图像问答。 - **预设配置** - - 模型:`gemma4:26b` - - 能力:思考、工具、视觉 - - 引擎参数:`OLLAMA_KEEP_ALIVE=-1 OLLAMA_CONTEXT_LENGTH=131072 OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 OLLAMA_NUM_PARALLEL=1`(128K 上下文、模型常驻显存、Flash Attention、q8_0 KV 缓存) - - 所需显存:`23Gi` + **主要功能** - **加速器模式** - | 模式 | 设备 | 说明 | - |----------------|------------------|--------------------------------------------------------------| - | `nvidia` | GPU (CUDA) | 使用 `23Gi` 显存;Ollama 默认使用 GPU | - | `nvidia-gb10` | GPU (Spark) | 与上相同,显存由 pod 管理 | - - **工作流程说明** - 首先,Model Console 从 Ollama 模型库拉取并准备模型,然后 Ollama 守护进程在模型准备好后启动服务。两个部分独立运行但共享文件与进度信息。 + - 生成和总结文本、回答问题并辅助编程。 + - 理解图像,响应同时包含文本和图像的提示。 + - 使用思考模式处理推理任务。 + - 在提供工具的兼容应用中支持工具调用。 - **技术栈说明** - - **Ollama 守护进程**(11434 端口):拉取并服务模型 - - **Model Console**(8090 端口):驱动模型拉取、展示进度,并通过 OpenAI API 代理到 Ollama + **在 Olares 上使用模型** - **模型存储** - 所有拉取的模型存储在共享目录 `appCommon/ollama`。所有基于 Ollama 的应用共享此位置,相同 blob 按 digest 去重。 + 本应用从 Ollama 模型库下载 `gemma4:26b`。Model Console 显示下载进度并管理模型,供兼容的 Olares 应用使用。默认上下文窗口为 128K tokens,决定模型一次能够处理多少对话和其他输入内容。 + [Gemma 4 文档](https://ai.google.dev/gemma/docs/core/model_card_4) diff --git a/ollamagemma426bv3/owners b/ollamagemma426bv3/owners index 48e63a537..fabb433be 100644 --- a/ollamagemma426bv3/owners +++ b/ollamagemma426bv3/owners @@ -1,7 +1,7 @@ owners: -- 'LittleLollipop' -- 'TShentu' -- 'hysyeah' -- 'pengpeng' -- 'harveyff' -- 'FantasticCode2019' + - username: 'LittleLollipop' + - username: 'TShentu' + - username: 'hysyeah' + - username: 'pengpeng' + - username: 'harveyff' + - username: 'FantasticCode2019' diff --git a/ollamagemma426bv3/templates/llm-init.yaml b/ollamagemma426bv3/templates/llm-init.yaml index fceb8b5e2..aab45e228 100644 --- a/ollamagemma426bv3/templates/llm-init.yaml +++ b/ollamagemma426bv3/templates/llm-init.yaml @@ -46,6 +46,10 @@ {{- /* User ENGINE_ARGS for llm-init: never OLLAMA_KEEP_ALIVE (see engineArgsForLlminit). Empty when user leaves ENGINE_ARGS blank — keep_alive is ollama-daemon-only. */ -}} {{- $engineArgs := include "ollamagemma426bv3.engineArgsForLlminit" (dict "Args" ($oe.ENGINE_ARGS | default "") "IsCpu" $isCpuMode) -}} +{{- /* Shared RUN_DIR host path. Same convention as llamacppllmbasev3: + appCache (run/scratch state, not user data), namespaced per release. + Declared in both templates -- helm renders each file on its own. */ -}} +{{- $runStateHostPath := printf "%s/llm-init-run/%s" .Values.userspace.appCache .Release.Name -}} --- # llm-init Pod (no GPU). Talks to the ollama daemon via the "ollama" # Service on :11434 (defined in templates/ollama.yaml). llm-init derives @@ -75,13 +79,44 @@ spec: io.kompose.service: llm-init spec: restartPolicy: Always + volumes: + # Shared RUN_DIR: the one-way handoff channel to the ollama daemon + # (engine_args, engine_restart, wrappers/common.sh). llm-init and the + # daemon are separate Deployments, so an emptyDir cannot carry it -- + # it has to be a path both Pods can reach. + # + # model-spec.json and progress_state.json live here too (both default + # under RUN_DIR), so a Model Console card edit survives a Pod restart. + # Consequence worth knowing: once the card exists on disk it wins over + # the chart's ENGINE_ARGS env, so a later edit of the ENGINE_ARGS + # setting is logged as ignored rather than applied. Edit engine args on + # the model card, not in the app settings. + - name: run-state + hostPath: + path: "{{ $runStateHostPath }}" + type: DirectoryOrCreate + initContainers: + # hostPath dirs are created root-owned; llm-init runs as UID 1000. + - name: init-chown + image: docker.io/beclab/aboveos-busybox:1.37.0 + command: + - sh + - -c + - "mkdir -p /run/llm-init/wrappers && chown -R 1000:1000 /run/llm-init || true" + volumeMounts: + - name: run-state + mountPath: /run/llm-init + securityContext: + runAsUser: 0 containers: - name: llm-init - image: docker.io/beclab/llm-init:v1.3.1 + image: docker.io/beclab/llm-init:v1.7.21 imagePullPolicy: IfNotPresent env: - name: ENGINE_KIND value: ollama + - name: RUN_DIR + value: /run/llm-init - name: ENGINE_ARGS value: "{{ $engineArgs }}" - name: MODEL_NAME @@ -105,6 +140,9 @@ spec: ports: - name: http containerPort: 8090 + volumeMounts: + - name: run-state + mountPath: /run/llm-init livenessProbe: httpGet: path: /livez diff --git a/ollamagemma426bv3/templates/ollama.yaml b/ollamagemma426bv3/templates/ollama.yaml index 316706aea..eff33f625 100644 --- a/ollamagemma426bv3/templates/ollama.yaml +++ b/ollamagemma426bv3/templates/ollama.yaml @@ -17,7 +17,7 @@ {{- /* CPU/RAM via olaresEnv (manifest defaults); accelerator -1 sums rendered workloads. Defaults: 200m/2Gi req, 6/35Gi lim (+ llm-init 200m/256Mi). */ -}} {{- $cpuRequest := trim ($oe.OLLAMA_CPU_REQUEST | default "200m") -}} -{{- $memRequest := trim ($oe.OLLAMA_MEMORY_REQUEST | default "21Gi") -}} +{{- $memRequest := trim ($oe.OLLAMA_MEMORY_REQUEST | default "6Gi") -}} {{- $cpuLimit := trim ($oe.OLLAMA_CPU_LIMIT | default "6") -}} {{- $memLimit := trim ($oe.OLLAMA_MEMORY_LIMIT | default "30Gi") -}} {{- /* Per-instance model memory quota. nvidia.com/gpumem needs a BARE MiB int; @@ -28,6 +28,10 @@ {{- $memRequest = printf "%sMi" $gpuMiB -}} {{- $memLimit = printf "%sMi" $gpuMiB -}} {{- end -}} +{{- /* Shared RUN_DIR host path. Same convention as llamacppllmbasev3: + appCache (run/scratch state, not user data), namespaced per release. + Declared in both templates -- helm renders each file on its own. */ -}} +{{- $runStateHostPath := printf "%s/llm-init-run/%s" .Values.userspace.appCache .Release.Name -}} --- # Ollama daemon Pod (single container) so the Olares # applications.app.bytetrade.io/gpu-inject annotation cleanly targets just @@ -76,8 +80,12 @@ spec: path: "{{ .Values.userspace.appCommon }}/ollama" type: DirectoryOrCreate {{- if not $isCpuMode }} - # CUDA JIT compile cache lives alongside the models under appCommon/ollama - # (appCache is not available for this hostPath mount). + # CUDA JIT compile cache, kept under appCommon/ollama beside the blobs + # on purpose: appCommon is shared across every ollama app, so one JIT + # cache serves all of them, and purging the model store drops the + # matching cache with it. appCache is granted (the RUN_DIR handoff + # below uses it) but is per-app -- moving this there would fragment + # that sharing and orphan every existing install's warm cache. - name: cuda-compute-cache hostPath: path: "{{ .Values.userspace.appCommon }}/ollama/.nv" @@ -87,6 +95,16 @@ spec: configMap: name: llm-init-wrappers defaultMode: 0555 + # Shared RUN_DIR, read-only on this side: the handoff is one-way, no + # wrapper ever writes back. This is what carries the model card's + # engine_args and the engine_restart generation the wrapper polls, plus + # the common.sh llm-init publishes on every boot. Same hostPath the + # llminit Deployment mounts read-write (templates/llm-init.yaml), which + # is also where the init container that chowns it lives. + - name: run-state + hostPath: + path: "{{ $runStateHostPath }}" + type: DirectoryOrCreate containers: - name: ollama image: docker.io/ollama/ollama:0.32.1 @@ -97,6 +115,13 @@ spec: value: ollama - name: ENGINE_ARGS value: "{{ $engineArgs }}" + # Source the helpers llm-init publishes into RUN_DIR instead of a + # copy inlined in this chart: supervise_engine ships with the + # llm-init image (>= v1.5.0), so a fix to it arrives with an image + # bump. The ConfigMap carries no fallback copy -- pinning llm-init + # below v1.5.0 would leave the wrapper waiting for this file. + - name: WRAPPER_COMMON + value: /run/llm-init/wrappers/common.sh - name: MODEL_SOURCE value: "{{ $modelSource }}" - name: MODEL_NAME @@ -156,6 +181,9 @@ spec: - name: wrappers mountPath: /llm-init/wrappers readOnly: true + - name: run-state + mountPath: /run/llm-init + readOnly: true resources: # nvidia.com/gpumem is the per-instance GPU memory quota read by the # Olares gpu-inject webhook (accelerator is -1/auto, can't carry it). diff --git a/ollamagemma426bv3/templates/wrappers.yaml b/ollamagemma426bv3/templates/wrappers.yaml index 6f5d4ee00..26d92a95f 100644 --- a/ollamagemma426bv3/templates/wrappers.yaml +++ b/ollamagemma426bv3/templates/wrappers.yaml @@ -1,6 +1,16 @@ # Engine wrapper script, mounted into the Ollama daemon container at -# /llm-init/wrappers. Exports ENGINE_ARGS, starts ollama serve, then preloads -# the install-time model into VRAM after llm-init pull (name from MODEL_SOURCE). +# /llm-init/wrappers. +# +# Shape follows deploy/wrappers/ollama.sh in the llm-init repo: source the +# helpers llm-init publishes into RUN_DIR, wait for the model-card handoff, +# then run `ollama serve` under supervise_engine so a Model Console edit to +# engine_args relaunches the daemon. Only the VRAM preload below is this +# chart's own -- supervise_engine itself is not something a chart copy should +# own (see docs/architecture/engine-boot.html#restart). +# +# The container sets WRAPPER_COMMON=/run/llm-init/wrappers/common.sh, so this +# ConfigMap deliberately carries no fallback copy: the helpers ship with the +# llm-init image (>= v1.5.0) and are rewritten into RUN_DIR on every boot. apiVersion: v1 kind: ConfigMap metadata: @@ -11,23 +21,35 @@ metadata: data: ollama.sh: | #!/bin/sh - set -eu + # Ollama wrapper. + # + # ENGINE_ARGS is a KEY=VALUE list of OLLAMA_* daemon env. The chart env is + # only the fallback: when llm-init has published ${RUN_DIR}/engine_args the + # card wins, and supervise_engine reloads it before every launch. The card + # never carries OLLAMA_KEEP_ALIVE (llm-init strips it -- it forwards the + # value on /api/chat instead), so the -1 default is re-applied below on + # each launch rather than inherited from the chart env. + # shellcheck disable=SC2034 ENGINE=ollama - log() { printf '[wrapper-%s] %s\n' "$ENGINE" "$*"; } + # Source the shared helpers: the sibling copy by default, or the one + # llm-init publishes into RUN_DIR when WRAPPER_COMMON says so. That copy + # can arrive late — the two containers are separate Deployments with no + # ordering between them — so waiting here is the normal path. + # Keep this block byte-identical across wrappers (tests/wrappers checks). + WRAPPER_COMMON=${WRAPPER_COMMON:-"$(dirname "$0")/common.sh"} + _wc=0 + while [ ! -f "$WRAPPER_COMMON" ] && [ "$_wc" -lt "${WRAPPER_COMMON_WAIT:-3600}" ]; do + printf '[wrapper] waiting for %s (elapsed=%ss)\n' "$WRAPPER_COMMON" "$_wc" + sleep 5 + _wc=$((_wc + 5)) + done + [ -f "$WRAPPER_COMMON" ] || { printf '[wrapper] %s never appeared\n' "$WRAPPER_COMMON" >&2; exit 1; } + unset _wc + # shellcheck source=common.sh + . "$WRAPPER_COMMON" - engine_args_export_env() { - args="${ENGINE_ARGS:-}" - [ -z "$args" ] && return 0 - # shellcheck disable=SC2086 - set -- $args - for tok in "$@"; do - case "$tok" in - *=*) export "$tok" && log "engine_args export: $tok" ;; - *) log "engine_args drop non-KV token: $tok" ;; - esac - done - } + export OLLAMA_HOST="${OLLAMA_HOST:-0.0.0.0:11434}" # Ollama names are model:tag. MODEL_SOURCE (ollama://qwen3.5:4b) is authoritative; # MODEL_NAME may use a hyphen (qwen3.5-4b) which show/run will not resolve. @@ -82,8 +104,6 @@ data: preload_via_api() { model="$1" - host="${OLLAMA_HOST#http://}" - host="${host#https://}" case "${MODEL_MODE:-chat}" in embedding|embed) if ollama embed "$model" "warmup" >/dev/null 2>&1; then @@ -95,6 +115,12 @@ data: ollama run "$model" "Hello" >/dev/null 2>&1 } + # preload_model polls until `ollama show` resolves a candidate (the daemon is + # up AND llm-init has finished the pull), then warms VRAM. It runs beside the + # daemon rather than before it: supervise_engine has to end up tracking the + # `ollama serve` PID itself, so run_ollama execs and cannot wait for anything + # afterwards. Bounded by OLLAMA_PRELOAD_TIMEOUT so a launch that never gets a + # model does not leave a poller behind. preload_model() { case "${OLLAMA_PRELOAD:-true}" in false|FALSE|0|no|NO|off|OFF) @@ -139,22 +165,21 @@ data: fi } - export OLLAMA_HOST="${OLLAMA_HOST:-0.0.0.0:11434}" - engine_args_export_env - normalize_keep_alive - export OLLAMA_KEEP_ALIVE="${OLLAMA_KEEP_ALIVE:--1}" build_model_candidates - log "starting ollama serve on $OLLAMA_HOST" - ollama serve "$@" & - SERVER_PID=$! - trap 'kill "$SERVER_PID" 2>/dev/null; wait "$SERVER_PID" 2>/dev/null; exit 0' INT TERM - - until ollama list >/dev/null 2>&1; do - sleep 1 - done - log "ollama API ready" + # No download sentinel for Ollama; still wait for model-card handoff so we + # do not briefly serve with chart ENGINE_ARGS while llm-init reconciles. + wait_for_engine_args_handoff - preload_model + run_ollama() { + engine_args_export_env + normalize_keep_alive + export OLLAMA_KEEP_ALIVE="${OLLAMA_KEEP_ALIVE:--1}" + # Re-run on every launch: a card edit relaunches the daemon, which drops + # what was resident in VRAM. + preload_model & + log "starting ollama serve on $OLLAMA_HOST" + exec ollama serve "$@" + } - wait "$SERVER_PID" + supervise_engine run_ollama "$@"