From ba19e4bfba64cec941c4236da366b64664e42734 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 21 Nov 2026 17:38:33 +0100 Subject: [PATCH] [NEW][stratahy4flashsq96][0.0.1] Tencent Hy4 Flash SQ 96 --- stratahy4flashsq96/.helmignore | 4 + stratahy4flashsq96/Chart.yaml | 7 + stratahy4flashsq96/OlaresManifest.yaml | 218 ++++++ .../i18n/de-DE/OlaresManifest.yaml | 35 + .../i18n/en-US/OlaresManifest.yaml | 35 + .../i18n/es-ES/OlaresManifest.yaml | 35 + .../i18n/fr-FR/OlaresManifest.yaml | 35 + .../i18n/it-IT/OlaresManifest.yaml | 35 + .../i18n/ja-JP/OlaresManifest.yaml | 35 + .../i18n/zh-CN/OlaresManifest.yaml | 35 + stratahy4flashsq96/owners | 2 + stratahy4flashsq96/templates/_helpers.tpl | 39 + stratahy4flashsq96/templates/llm-init.yaml | 263 +++++++ stratahy4flashsq96/templates/secret.yaml | 15 + stratahy4flashsq96/templates/strata.yaml | 149 ++++ stratahy4flashsq96/templates/wrappers.yaml | 714 ++++++++++++++++++ stratahy4flashsq96/values.yaml | 13 + 17 files changed, 1669 insertions(+) create mode 100644 stratahy4flashsq96/.helmignore create mode 100644 stratahy4flashsq96/Chart.yaml create mode 100644 stratahy4flashsq96/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/i18n/de-DE/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/i18n/en-US/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/i18n/es-ES/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/i18n/fr-FR/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/i18n/it-IT/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/i18n/ja-JP/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/i18n/zh-CN/OlaresManifest.yaml create mode 100644 stratahy4flashsq96/owners create mode 100644 stratahy4flashsq96/templates/_helpers.tpl create mode 100644 stratahy4flashsq96/templates/llm-init.yaml create mode 100644 stratahy4flashsq96/templates/secret.yaml create mode 100644 stratahy4flashsq96/templates/strata.yaml create mode 100644 stratahy4flashsq96/templates/wrappers.yaml create mode 100644 stratahy4flashsq96/values.yaml diff --git a/stratahy4flashsq96/.helmignore b/stratahy4flashsq96/.helmignore new file mode 100644 index 000000000..57084ca00 --- /dev/null +++ b/stratahy4flashsq96/.helmignore @@ -0,0 +1,4 @@ +.DS_Store +__pycache__/ +*.pyc +*.tgz diff --git a/stratahy4flashsq96/Chart.yaml b/stratahy4flashsq96/Chart.yaml new file mode 100644 index 000000000..e1d1df08b --- /dev/null +++ b/stratahy4flashsq96/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: stratahy4flashsq96 +description: Tencent Hy4-Flash SQ-96 with Strata and Model Console +icon: https://app.cdn.olares.com/appstore/strata/icon.png +type: application +version: 0.0.1 +appVersion: "0.2.18" diff --git a/stratahy4flashsq96/OlaresManifest.yaml b/stratahy4flashsq96/OlaresManifest.yaml new file mode 100644 index 000000000..48d8ea491 --- /dev/null +++ b/stratahy4flashsq96/OlaresManifest.yaml @@ -0,0 +1,218 @@ +olaresManifest.version: 0.12.0 +olaresManifest.type: app +apiVersion: v3 +metadata: + name: stratahy4flashsq96 + icon: https://app.cdn.olares.com/appstore/strata/icon.png + description: "Tencent Hy4-Flash SQ-96 for multimodal chat, reasoning, and tool calling, powered locally by Strata" + appid: stratahy4flashsq96 + title: Hy4-Flash SQ-96 (Strata) + version: 0.0.1 + categories: + - AI + - models + tags: + - llm +sharedEntrances: +- name: stratahy4flashsq96 + host: sharedentrances-api + port: 0 + title: Tencent Hy4-Flash SQ-96 + invisible: true + authLevel: internal + icon: https://app.cdn.olares.com/appstore/strata/icon.png +entrances: +- name: strataclient + port: 8090 + host: download-svc + title: Tencent Hy4-Flash SQ-96 + icon: https://app.cdn.olares.com/appstore/strata/icon.png + openMethod: window + authLevel: internal +- name: strataui + port: 8080 + # Keep the route available without blocking initialization on model loading. + skip: true + host: strata + title: Strata UI — Hy4-Flash SQ-96 + icon: https://app.cdn.olares.com/appstore/strata/icon.png + openMethod: window + authLevel: internal +workloadReplicas: + stratahy4flashsq96: 1 + llminit: 1 +spec: + onlyAdmin: true + versionName: Tencent Hy4-Flash SQ-96 + upgradeDescription: | + Initial release of Tencent Hy4-Flash SQ-96 on Strata v0.2.18 (strata-hy4 0.1.64) and Model Console (llm-init v1.7.26), tuned for Olares One (24 GiB NVIDIA GPU + 96 GiB RAM). + + - Runs native `.strata` v1.0 `SQ-96` weights (`89.58 GB`) with the shared `Engram-Q8` NVMe lookup shard (`67.58 GB`) and native `Vision` shard (`0.93 GB`) — zero GGUF conversion wait on first startup. + - Enables multimodal image understanding, `high`/`max` reasoning effort control, OpenAI-compatible tool calling, and embedded 5-layer `DFly2` speculative decoding at 131,072 context tokens. + - Ships an editable 19-core default CPU limit (20-core platform quota) with 16 AVX-VNNI CPU expert worker threads, 2 MiB hugepage arena collapse (`STRATA_CPUEXP_COLLAPSE=1`), 80 GiB container memory ceiling (57 GiB install requirement) for full dynamic VRAM `AdaptiveExpertCache`, and direct cold I/O (`STRATA_CPUEXP_COLD_IO=direct`). + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flash is a 220B-parameter Mixture-of-Experts multimodal AI model (12B active parameters per token, with 63.4B parameters in 4 Engram lookup modules) for answering questions, understanding images, reasoning, and calling tools. This app runs Strata's native `.strata` v1.0 `SQ-96` quantized edition locally using the dedicated `strata-hy4` C++/CUDA engine. + + Strata is an open-source inference engine for running large AI models locally. For Hy4-Flash, it keeps the dense trunk, MLA KV cache, and hottest experts in GPU memory, holds the remaining experts in system RAM, and pages the 4-KiB-aligned `Engram-Q8` lookup table directly from NVMe storage with a 900 MiB RAM cache. Model Console connects the engine to Olares. + + **Key features** + + - Generate text responses from text and image inputs, with thinking (`high` / `max` reasoning effort) and tool calling in compatible applications. + - Accelerate generation with the embedded 5-layer `DFly2` speculative drafter (`0 B` additional KV cache). + - Use Model Console to download the model, monitor readiness, and adjust engine settings. + - Connect compatible applications through Olares Router or the OpenAI-compatible chat API. + + **This edition** + + This edition (`SQ-96`) supports text and image input (`Hy4-Flash-Vision.strata` runs natively inside `strata-hy4`); video input is not enabled. The default context limit is 131,072 tokens, with one request processed at a time. Available context depends on memory and engine settings. + + **Before first use** + + First startup downloads 158.1 GB across three `.strata` v1.0 files (`Hy4-Flash-SQ-96.strata`, `Hy4-Flash-Engram-Q8.strata`, and `Hy4-Flash-Vision.strata`). Because `.strata` v1.0 loads directly without GGUF repacking, startup proceeds straight to tokenizer extraction and model loading once the download completes. + + On amd64, an AVX2-capable CPU, fast NVMe storage, and an NVIDIA driver from the R580 series or newer are required. This preset is sized for Olares One (24 GiB VRAM and 96 GiB of host RAM). See the listed resource requirements before installing. + + [Model documentation](https://huggingface.co/tencent/Hy4-flash) · [Quantized model](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Strata documentation](https://github.com/Niko1221/Strata) + developer: Tencent (model); Niko1221 (Strata engine) + website: https://huggingface.co/tencent/Hy4-flash + sourceCode: https://github.com/Niko1221/Strata + doc: https://github.com/Niko1221/Strata#readme + submitter: Niko1221 + featuredImage: https://cdn.olares.com/images/2026/11/11145c7d662ed1adb457e6cb2c64d29a.png + promoteImage: + - https://cdn.olares.com/images/2026/11/11145c7d662ed1adb457e6cb2c64d29a.png + - https://cdn.olares.com/images/2026/11/1ea008ed41225b16c41073798792fce1.png + locale: + - en-US + - zh-CN + - de-DE + - es-ES + - it-IT + - fr-FR + - ja-JP + license: + - text: Tencent HY Community License (model) + url: https://huggingface.co/tencent/Hy4-flash/blob/main/LICENSE + - text: MIT (Strata engine) + url: https://github.com/Niko1221/Strata/blob/main/LICENSE + accelerator: + - mode: nvidia + limitedCpu: '20' + requiredCpu: 1300m + requiredDisk: 160Gi + limitedDisk: 220Gi + requiredMemory: 57Gi + limitedMemory: 83Gi + requiredGPUMemory: 23Gi + limitedGPUMemory: 24Gi + supportArch: + - amd64 + runAsUser: true +permission: + appCache: true + appCommon: true +options: + apiTimeout: 0 + LLMGatewaySupported: true + shared: true + templateOnly: false + dependencies: + - name: olares + version: '>=1.12.7-0' + type: system +envs: +- envName: MODEL_SOURCE + required: true + type: string + editable: false + applyOnChange: false + default: hf://strata-engine/Hy4-Flash-Strata --include Hy4-Flash-SQ-96.strata,hf://strata-engine/Hy4-Flash-Strata --include Hy4-Flash-Engram-Q8.strata,hf://strata-engine/Hy4-Flash-Strata --include Hy4-Flash-Vision.strata + description: Three native .strata v1.0 single-file sources sharing one HF snapshot (SQ-96 weights, Engram-Q8 NVMe shard, and Vision shard); extras finish before the main model handoff. +- envName: MODEL_NAME + required: true + type: string + editable: false + applyOnChange: false + default: hy4-flash-sq-96 +- envName: MODEL_MODE + required: true + type: string + editable: false + applyOnChange: false + default: chat +- envName: MODEL_SUPPORTS + required: true + type: string + editable: false + applyOnChange: false + default: vision,thinking,tools +- envName: MODEL_REASONING_EFFORT + required: false + type: string + editable: false + applyOnChange: false + default: "high,max" + description: "The reasoning_effort levels Tencent Hy4-Flash accepts (high, max; none/off disables thinking), published on the model card for clients." +- envName: MODEL_REASONING_EFFORT_DEFAULT + required: false + type: string + editable: false + applyOnChange: false + default: "high" + description: "The reasoning_effort level Hy4-Flash uses when a request does not specify one." +- envName: ENGINE_ARGS + required: true + type: string + editable: true + applyOnChange: true + default: --context 131072 + description: Strata setup.py / strata-hy4 options. Model/source/host/port/GPU/vision are managed by the chart. Default context is 131072 tokens with built-in Tree-8 DFly2 speculative decoding (--draft dfly2; pass --draft off to disable), lossless expert routing (--tail-skip 0; optionally add --tail-skip 12 for higher open-ended prose throughput), and automatic dynamic VRAM + cgroup RAM expert placement. Saving engine_args in Model Console relaunches setup and the server without re-downloading weights. +- envName: LOG_LEVEL + required: true + type: string + editable: true + applyOnChange: true + default: info +- envName: HF_ENDPOINT + required: false + applyOnChange: true + valueFrom: + envName: OLARES_SYSTEM_HUGGINGFACE_SERVICE +- envName: HF_TOKEN + required: false + applyOnChange: true + valueFrom: + envName: OLARES_SYSTEM_HUGGINGFACE_TOKEN +- envName: STRATA_CPU_REQUEST + required: true + type: string + editable: false + applyOnChange: false + default: '1' +- envName: STRATA_MEMORY_REQUEST + required: true + type: string + editable: false + applyOnChange: false + default: 56Gi +- envName: STRATA_CPU_LIMIT + required: true + type: string + editable: true + applyOnChange: true + default: '19' + description: CPU limit for the Strata engine, in cores. The default is 19 so the total container CPU limit stays within the app ceiling (20). Saving this relaunches the engine. +- envName: STRATA_MEMORY_LIMIT + required: true + type: string + editable: false + applyOnChange: false + default: 80Gi +- envName: STRATA_REQUIRED_GPU_MEMORY + required: true + type: string + editable: false + applyOnChange: false + default: 23Gi diff --git a/stratahy4flashsq96/i18n/de-DE/OlaresManifest.yaml b/stratahy4flashsq96/i18n/de-DE/OlaresManifest.yaml new file mode 100644 index 000000000..56ec19fd2 --- /dev/null +++ b/stratahy4flashsq96/i18n/de-DE/OlaresManifest.yaml @@ -0,0 +1,35 @@ +metadata: + title: Hy4-Flash SQ-96 (Strata) + description: "Tencent Hy4-Flash SQ-96 für multimodalen Chat, Schlussfolgern und Tool-Aufrufe, lokal mit Strata" +spec: + upgradeDescription: | + Erstveröffentlichung von Tencent Hy4-Flash SQ-96 auf Strata v0.2.18 (strata-hy4 0.1.64) und Model Console (llm-init v1.7.26), abgestimmt auf Olares One (24 GiB NVIDIA-GPU + 96 GiB RAM). + + - Führt native `.strata`-v1.0-Gewichte (`SQ-96`, `89,58 GB`) mit dem gemeinsamen NVMe-Engram-Shard (`Engram-Q8`, `67,58 GB`) und dem nativen `Vision`-Shard (`0,93 GB`) aus – ohne GGUF-Konvertierungswartezeit beim ersten Start. + - Unterstützt Bildeingaben, Denkmodus (`high`/`max` Reasoning-Stufen), OpenAI-kompatible Tool-Aufrufe und eingebettetes 5-Layer-`DFly2`-Speculative-Decoding bei 131.072 Kontext-Token. + - Bietet ein bearbeitbares Standard-CPU-Limit von 19 Kernen (Plattformkontingent: 20 Kerne) mit 16 AVX-VNNI-CPU-Experten-Threads, 2-MiB-Hugepage-Arena-Verdichtung (`STRATA_CPUEXP_COLLAPSE=1`), 80 GiB Container-Speicherlimit (57 GiB Installationsanforderung) für voll dynamischen VRAM-`AdaptiveExpertCache` und direktem Cold-I/O (`STRATA_CPUEXP_COLD_IO=direct`). + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flash ist ein multimodales Mixture-of-Experts-KI-Modell mit 220 Milliarden Parametern (12B aktive Parameter pro Token sowie 63,4B Parameter in vier Engram-Lookup-Modulen) zum Beantworten von Fragen, Verstehen von Bildern, Schlussfolgern und Aufrufen von Werkzeugen. Diese App führt Stratas native `.strata`-v1.0-Quantisierung `SQ-96` lokal über die dedizierte C++/CUDA-Engine `strata-hy4` aus. + + Strata ist eine Open-Source-Inferenz-Engine für große lokale KI-Modelle. Bei Hy4-Flash hält sie den dichten Trunk, den MLA-KV-Cache und die aktivsten Experten im GPU-Speicher, legt die übrigen Experten im Arbeitsspeicher ab und liest die 4-KiB-ausgerichtete `Engram-Q8`-Tabelle mit einem 900-MiB-RAM-Cache direkt von der NVMe-SSD. Model Console verbindet die Engine mit Olares. + + **Hauptfunktionen** + + - Textantworten aus Text- und Bildeingaben erzeugen, inklusive Denkmodus (`high` / `max`) und Tool-Aufrufen in kompatiblen Anwendungen. + - Beschleunigte Generierung durch den eingebetteten 5-Layer-`DFly2`-Drafter (`0 B` zusätzlicher KV-Cache). + - Mit Model Console das Modell herunterladen, den Bereitschaftsstatus prüfen und Engine-Einstellungen anpassen. + - Kompatible Anwendungen über Olares Router oder die OpenAI-kompatible Chat-API verbinden. + + **Diese Ausgabe** + + Diese Ausgabe (`SQ-96`) unterstützt Text- und Bildeingaben (`Hy4-Flash-Vision.strata` läuft nativ in `strata-hy4`); Videoeingaben sind nicht aktiviert. Das voreingestellte Kontextlimit beträgt 131.072 Token bei einer gleichzeitigen Anfrage. Der verfügbare Kontext hängt vom Speicher und den Engine-Einstellungen ab. + + **Vor der ersten Nutzung** + + Beim ersten Start werden insgesamt 158,1 GB in drei `.strata`-v1.0-Dateien heruntergeladen (`Hy4-Flash-SQ-96.strata`, `Hy4-Flash-Engram-Q8.strata` und `Hy4-Flash-Vision.strata`). Da `.strata` v1.0 direkt ohne GGUF-Umpacken geladen wird, startet das Modell unmittelbar nach dem Download. + + Erforderlich sind eine AVX2-fähige CPU, schneller NVMe-Speicher und ein NVIDIA-Treiber ab Reihe R580. Diese Voreinstellung ist für Olares One (24 GiB VRAM und 96 GiB Host-RAM) ausgelegt. Prüfen Sie vor der Installation die angegebenen Ressourcenanforderungen. + + [Modelldokumentation](https://huggingface.co/tencent/Hy4-flash) · [Quantisiertes Modell](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Strata-Dokumentation](https://github.com/Niko1221/Strata) diff --git a/stratahy4flashsq96/i18n/en-US/OlaresManifest.yaml b/stratahy4flashsq96/i18n/en-US/OlaresManifest.yaml new file mode 100644 index 000000000..66da4989b --- /dev/null +++ b/stratahy4flashsq96/i18n/en-US/OlaresManifest.yaml @@ -0,0 +1,35 @@ +metadata: + title: Hy4-Flash SQ-96 (Strata) + description: "Tencent Hy4-Flash SQ-96 for multimodal chat, reasoning, and tool calling, powered locally by Strata" +spec: + upgradeDescription: | + Initial release of Tencent Hy4-Flash SQ-96 on Strata v0.2.18 (strata-hy4 0.1.64) and Model Console (llm-init v1.7.26), tuned for Olares One (24 GiB NVIDIA GPU + 96 GiB RAM). + + - Runs native `.strata` v1.0 `SQ-96` weights (`89.58 GB`) with the shared `Engram-Q8` NVMe lookup shard (`67.58 GB`) and native `Vision` shard (`0.93 GB`) — zero GGUF conversion wait on first startup. + - Enables multimodal image understanding, `high`/`max` reasoning effort control, OpenAI-compatible tool calling, and embedded 5-layer `DFly2` speculative decoding at 131,072 context tokens. + - Ships an editable 19-core default CPU limit (20-core platform quota) with 16 AVX-VNNI CPU expert worker threads, 2 MiB hugepage arena collapse (`STRATA_CPUEXP_COLLAPSE=1`), 80 GiB container memory ceiling (57 GiB install requirement) for full dynamic VRAM `AdaptiveExpertCache`, and direct cold I/O (`STRATA_CPUEXP_COLD_IO=direct`). + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flash is a 220B-parameter Mixture-of-Experts multimodal AI model (12B active parameters per token, with 63.4B parameters in 4 Engram lookup modules) for answering questions, understanding images, reasoning, and calling tools. This app runs Strata's native `.strata` v1.0 `SQ-96` quantized edition locally using the dedicated `strata-hy4` C++/CUDA engine. + + Strata is an open-source inference engine for running large AI models locally. For Hy4-Flash, it keeps the dense trunk, MLA KV cache, and hottest experts in GPU memory, holds the remaining experts in system RAM, and pages the 4-KiB-aligned `Engram-Q8` lookup table directly from NVMe storage with a 900 MiB RAM cache. Model Console connects the engine to Olares. + + **Key features** + + - Generate text responses from text and image inputs, with thinking (`high` / `max` reasoning effort) and tool calling in compatible applications. + - Accelerate generation with the embedded 5-layer `DFly2` speculative drafter (`0 B` additional KV cache). + - Use Model Console to download the model, monitor readiness, and adjust engine settings. + - Connect compatible applications through Olares Router or the OpenAI-compatible chat API. + + **This edition** + + This edition (`SQ-96`) supports text and image input (`Hy4-Flash-Vision.strata` runs natively inside `strata-hy4`); video input is not enabled. The default context limit is 131,072 tokens, with one request processed at a time. Available context depends on memory and engine settings. + + **Before first use** + + First startup downloads 158.1 GB across three `.strata` v1.0 files (`Hy4-Flash-SQ-96.strata`, `Hy4-Flash-Engram-Q8.strata`, and `Hy4-Flash-Vision.strata`). Because `.strata` v1.0 loads directly without GGUF repacking, startup proceeds straight to tokenizer extraction and model loading once the download completes. + + An AVX2-capable CPU, fast NVMe storage, and an NVIDIA driver from the R580 series or newer are required. This preset is sized for Olares One (24 GiB VRAM and 96 GiB of host RAM). See the listed resource requirements before installing. + + [Model documentation](https://huggingface.co/tencent/Hy4-flash) · [Quantized model](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Strata documentation](https://github.com/Niko1221/Strata) diff --git a/stratahy4flashsq96/i18n/es-ES/OlaresManifest.yaml b/stratahy4flashsq96/i18n/es-ES/OlaresManifest.yaml new file mode 100644 index 000000000..341a647ca --- /dev/null +++ b/stratahy4flashsq96/i18n/es-ES/OlaresManifest.yaml @@ -0,0 +1,35 @@ +metadata: + title: Hy4-Flash SQ-96 (Strata) + description: "Tencent Hy4-Flash SQ-96 para chat multimodal, razonamiento y herramientas, ejecutado localmente con Strata" +spec: + upgradeDescription: | + Lanzamiento inicial de Tencent Hy4-Flash SQ-96 con Strata v0.2.18 (strata-hy4 0.1.64) y Model Console (llm-init v1.7.26), optimizado para Olares One (GPU NVIDIA de 24 GiB + 96 GiB de RAM). + + - Ejecuta pesos nativos `.strata` v1.0 `SQ-96` (`89,58 GB`) junto con el fragmento compartido NVMe `Engram-Q8` (`67,58 GB`) y el fragmento nativo `Vision` (`0,93 GB`), sin espera de conversión GGUF en el primer inicio. + - Activa comprensión de imágenes, control de esfuerzo de razonamiento (`high`/`max`), llamadas a herramientas compatibles con OpenAI y decodificación especulativa integrada `DFly2` de 5 capas con 131.072 tokens de contexto. + - Incluye límite de CPU predeterminado editable de 19 núcleos (cuota de plataforma de 20 núcleos), 16 hilos AVX-VNNI de expertos en CPU, compactación de arena en páginas enormes de 2 MiB (`STRATA_CPUEXP_COLLAPSE=1`), límite de memoria de contenedor de 80 GiB (requisito de instalación de 57 GiB) para `AdaptiveExpertCache` dinámico completo en VRAM y E/S directa (`STRATA_CPUEXP_COLD_IO=direct`). + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flash es un modelo multimodal de IA Mixture-of-Experts de 220B parámetros (12B activos por token y 63,4B en 4 módulos de búsqueda Engram) diseñado para responder preguntas, analizar imágenes, razonar y llamar herramientas. Esta aplicación ejecuta localmente la edición cuantizada nativa `.strata` v1.0 `SQ-96` mediante el motor dedicado `strata-hy4` en C++/CUDA. + + Strata es un motor de inferencia de código abierto para ejecutar grandes modelos de IA localmente. En Hy4-Flash mantiene el tronco denso, la caché KV MLA y los expertos más frecuentes en la memoria de la GPU, aloja el resto de expertos en la RAM del sistema y pagina la tabla `Engram-Q8` alineada a 4 KiB directamente desde el almacenamiento NVMe con una caché RAM de 900 MiB. Model Console conecta el motor con Olares. + + **Funciones principales** + + - Generar respuestas a partir de texto e imágenes, con modo de razonamiento (`high` / `max`) y llamadas a herramientas en aplicaciones compatibles. + - Acelerar la generación mediante el borrador especulativo integrado `DFly2` de 5 capas (`0 B` de caché KV adicional). + - Usar Model Console para descargar el modelo, consultar su estado y ajustar la configuración del motor. + - Conectar aplicaciones compatibles mediante Olares Router o la API de chat compatible con OpenAI. + + **Esta edición** + + Esta edición (`SQ-96`) admite entradas de texto e imagen (`Hy4-Flash-Vision.strata` se ejecuta de forma nativa en `strata-hy4`); la entrada de vídeo no está habilitada. El límite de contexto predeterminado es de 131.072 tokens y se procesa una solicitud cada vez. El contexto disponible depende de la memoria y de la configuración del motor. + + **Antes del primer uso** + + En el primer inicio se descargan 158,1 GB repartidos en tres archivos `.strata` v1.0 (`Hy4-Flash-SQ-96.strata`, `Hy4-Flash-Engram-Q8.strata` y `Hy4-Flash-Vision.strata`). Dado que `.strata` v1.0 se carga directamente sin conversión GGUF, el modelo pasa directamente a la carga tras finalizar la descarga. + + Se requieren una CPU compatible con AVX2, almacenamiento NVMe rápido y un controlador NVIDIA de la serie R580 o posterior. Esta configuración está dimensionada para Olares One (24 GiB de VRAM y 96 GiB de RAM). Consulte los requisitos de recursos antes de instalar. + + [Documentación del modelo](https://huggingface.co/tencent/Hy4-flash) · [Modelo cuantizado](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Documentación de Strata](https://github.com/Niko1221/Strata) diff --git a/stratahy4flashsq96/i18n/fr-FR/OlaresManifest.yaml b/stratahy4flashsq96/i18n/fr-FR/OlaresManifest.yaml new file mode 100644 index 000000000..331f05a6a --- /dev/null +++ b/stratahy4flashsq96/i18n/fr-FR/OlaresManifest.yaml @@ -0,0 +1,35 @@ +metadata: + title: Hy4-Flash SQ-96 (Strata) + description: "Tencent Hy4-Flash SQ-96 pour chat multimodal, raisonnement et appels d'outils, en local avec Strata" +spec: + upgradeDescription: | + Version initiale de Tencent Hy4-Flash SQ-96 sur Strata v0.2.18 (strata-hy4 0.1.64) et Model Console (llm-init v1.7.26), calibrée pour Olares One (GPU NVIDIA 24 GiB + 96 GiB de RAM). + + - Exécute les poids natifs `.strata` v1.0 `SQ-96` (`89,58 GB`) avec le fragment NVMe partagé `Engram-Q8` (`67,58 GB`) et le fragment natif `Vision` (`0,93 GB`) — sans attente de conversion GGUF au premier démarrage. + - Active la compréhension d'images, le contrôle d'effort de raisonnement (`high`/`max`), les appels d'outils compatibles OpenAI et le décodage spéculatif intégré `DFly2` à 5 couches sur un contexte de 131 072 tokens. + - Propose une limite CPU modifiable de 19 cœurs par défaut (quota plateforme de 20 cœurs), 16 threads d'experts CPU AVX-VNNI, fusion d'arène en pages géantes de 2 MiB (`STRATA_CPUEXP_COLLAPSE=1`), plafond mémoire conteneur de 80 GiB (57 GiB requis à l'installation) pour le cache VRAM dynamique complet `AdaptiveExpertCache` et E/S directes (`STRATA_CPUEXP_COLD_IO=direct`). + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flash est un modèle d'IA multimodal Mixture-of-Experts de 220 milliards de paramètres (12B actifs par token et 63,4B dans 4 modules de recherche Engram) conçu pour répondre aux questions, analyser des images, raisonner et appeler des outils. Cette application exécute localement l'édition quantifiée native `.strata` v1.0 `SQ-96` avec le moteur C++/CUDA dédié `strata-hy4`. + + Strata est un moteur d'inférence open source permettant d'exécuter de grands modèles d'IA localement. Pour Hy4-Flash, il conserve le tronc dense, le cache KV MLA et les experts les plus sollicités en mémoire GPU, garde les autres experts en mémoire vive (RAM) et pagine la table `Engram-Q8` alignée sur 4 KiB directement depuis le SSD NVMe avec un cache RAM de 900 MiB. Model Console relie le moteur à Olares. + + **Principales fonctionnalités** + + - Générer des réponses à partir de texte et d'images, avec mode de raisonnement (`high` / `max`) et appels d'outils dans les applications compatibles. + - Accélérer la génération grâce au décodeur spéculatif intégré `DFly2` à 5 couches (`0 B` de cache KV supplémentaire). + - Utiliser Model Console pour télécharger le modèle, suivre son état et ajuster les paramètres du moteur. + - Connecter des applications compatibles via Olares Router ou l'API de chat compatible avec OpenAI. + + **Cette édition** + + Cette édition (`SQ-96`) prend en charge le texte et les images en entrée (`Hy4-Flash-Vision.strata` s'exécute nativement dans `strata-hy4`) ; l'entrée vidéo n'est pas activée. La limite de contexte par défaut est de 131 072 tokens, avec une seule requête traitée à la fois. Le contexte disponible dépend de la mémoire et des paramètres du moteur. + + **Avant la première utilisation** + + Au premier démarrage, 158,1 GB répartis en trois fichiers `.strata` v1.0 (`Hy4-Flash-SQ-96.strata`, `Hy4-Flash-Engram-Q8.strata` et `Hy4-Flash-Vision.strata`) sont téléchargés. Le format `.strata` v1.0 étant chargé directement sans conversion GGUF, le modèle démarre immédiatement après le téléchargement. + + Un processeur compatible AVX2, un stockage NVMe rapide et un pilote NVIDIA de la série R580 ou ultérieure sont requis. Ce préréglage est dimensionné pour Olares One (24 GiB de VRAM et 96 GiB de RAM hôte). Consultez les ressources requises avant l'installation. + + [Documentation du modèle](https://huggingface.co/tencent/Hy4-flash) · [Modèle quantifié](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Documentation de Strata](https://github.com/Niko1221/Strata) diff --git a/stratahy4flashsq96/i18n/it-IT/OlaresManifest.yaml b/stratahy4flashsq96/i18n/it-IT/OlaresManifest.yaml new file mode 100644 index 000000000..e5d6827ca --- /dev/null +++ b/stratahy4flashsq96/i18n/it-IT/OlaresManifest.yaml @@ -0,0 +1,35 @@ +metadata: + title: Hy4-Flash SQ-96 (Strata) + description: "Tencent Hy4-Flash SQ-96 per chat multimodale, ragionamento e strumenti, eseguito in locale con Strata" +spec: + upgradeDescription: | + Rilascio iniziale di Tencent Hy4-Flash SQ-96 con Strata v0.2.18 (strata-hy4 0.1.64) e Model Console (llm-init v1.7.26), ottimizzato per Olares One (GPU NVIDIA da 24 GiB + 96 GiB di RAM). + + - Esegue i pesi nativi `.strata` v1.0 `SQ-96` (`89,58 GB`) con lo shard NVMe condiviso `Engram-Q8` (`67,58 GB`) e lo shard nativo `Vision` (`0,93 GB`), senza attesa di conversione GGUF al primo avvio. + - Abilita comprensione delle immagini, controllo dello sforzo di ragionamento (`high`/`max`), chiamate a strumenti compatibili con OpenAI e decodifica speculativa integrata `DFly2` a 5 livelli con 131.072 token di contesto. + - Offre un limite CPU predefinito modificabile di 19 core (quota piattaforma di 20 core), 16 thread CPU AVX-VNNI per gli esperti, compattazione dell'arena in hugepage da 2 MiB (`STRATA_CPUEXP_COLLAPSE=1`), tetto di memoria del container da 80 GiB (57 GiB richiesti all'installazione) per `AdaptiveExpertCache` dinamico completo in VRAM e I/O diretto (`STRATA_CPUEXP_COLD_IO=direct`). + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flash è un modello multimodale di IA Mixture-of-Experts da 220 miliardi di parametri (12B attivi per token e 63,4B in 4 moduli di ricerca Engram) per rispondere a domande, comprendere immagini, ragionare e invocare strumenti. Questa applicazione esegue localmente l'edizione quantizzata nativa `.strata` v1.0 `SQ-96` tramite il motore dedicato `strata-hy4` in C++/CUDA. + + Strata è un motore di inferenza open source per eseguire grandi modelli di IA in locale. Con Hy4-Flash mantiene il tronco denso, la cache KV MLA e gli esperti più frequenti nella memoria della GPU, conserva gli esperti rimanenti nella RAM di sistema e legge la tabella `Engram-Q8` allineata a 4 KiB direttamente dallo storage NVMe con una cache RAM da 900 MiB. Model Console collega il motore a Olares. + + **Funzionalità principali** + + - Generare risposte da input testuali e immagini, con modalità di ragionamento (`high` / `max`) e chiamate a strumenti nelle applicazioni compatibili. + - Accelerare la generazione con il drafter speculativo integrato `DFly2` a 5 livelli (`0 B` di cache KV aggiuntiva). + - Usare Model Console per scaricare il modello, verificarne lo stato e regolare le impostazioni del motore. + - Collegare applicazioni compatibili tramite Olares Router o l'API di chat compatibile con OpenAI. + + **Questa edizione** + + Questa edizione (`SQ-96`) supporta input di testo e immagini (`Hy4-Flash-Vision.strata` viene eseguito nativamente in `strata-hy4`); l'input video non è abilitato. Il limite di contesto predefinito è di 131.072 token, con una richiesta elaborata alla volta. Il contesto disponibile dipende dalla memoria e dalle impostazioni del motore. + + **Prima del primo utilizzo** + + Al primo avvio vengono scaricati 158,1 GB suddivisi in tre file `.strata` v1.0 (`Hy4-Flash-SQ-96.strata`, `Hy4-Flash-Engram-Q8.strata` e `Hy4-Flash-Vision.strata`). Poiché il formato `.strata` v1.0 viene caricato direttamente senza conversione GGUF, l'avvio procede subito al caricamento del modello al termine del download. + + Sono necessari una CPU con supporto AVX2, archiviazione NVMe veloce e un driver NVIDIA della serie R580 o successiva. Questa configurazione è dimensionata per Olares One (24 GiB di VRAM e 96 GiB di RAM host). Consultare i requisiti di risorse indicati prima dell'installazione. + + [Documentazione del modello](https://huggingface.co/tencent/Hy4-flash) · [Modello quantizzato](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Documentazione di Strata](https://github.com/Niko1221/Strata) diff --git a/stratahy4flashsq96/i18n/ja-JP/OlaresManifest.yaml b/stratahy4flashsq96/i18n/ja-JP/OlaresManifest.yaml new file mode 100644 index 000000000..de95b45b2 --- /dev/null +++ b/stratahy4flashsq96/i18n/ja-JP/OlaresManifest.yaml @@ -0,0 +1,35 @@ +metadata: + title: Hy4-Flash SQ-96 (Strata) + description: "Strataでローカル実行する、画像理解・推論・ツール呼び出し対応のTencent Hy4-Flash SQ-96" +spec: + upgradeDescription: | + Strata v0.2.18(strata-hy4 0.1.64)およびModel Console(llm-init v1.7.26)上で動作するTencent Hy4-Flash SQ-96の初回リリースです。Olares One(24 GiB NVIDIA GPU + 96 GiB RAM)向けに最適化されています。 + + - ネイティブ `.strata` v1.0形式の `SQ-96` 重み(`89.58 GB`)、共有NVMeルックアップシャード `Engram-Q8`(`67.58 GB`)、ネイティブ `Vision` シャード(`0.93 GB`)を直接読み込み、初回起動時のGGUF変換待ち時間が不要です。 + - 画像入力の理解、`high`/`max` の推論強度制御、OpenAI互換ツール呼び出し、および131,072コンテキストトークンでの内蔵5層 `DFly2` 投機的デコーディングに対応します。 + - 編集可能な既定19コアのCPU上限(プラットフォーム割り当て上限20コア)、16スレッドのAVX-VNNI CPUエキスパートワーカー、2 MiBヒュージページへのアリーナ集約(`STRATA_CPUEXP_COLLAPSE=1`)、動的VRAM `AdaptiveExpertCache` を最大化する80 GiBコンテナメモリ上限(インストール要件57 GiB)、およびダイレクトI/O(`STRATA_CPUEXP_COLD_IO=direct`)を備えています。 + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flashは、質問応答、画像理解、推論、ツール呼び出しに対応する総パラメータ数220B(トークンあたり12B活性化、4つのEngramルックアップモジュールに63.4B)のマルチモーダルMixture-of-Experts AIモデルです。このアプリは、Strataのネイティブ `.strata` v1.0 `SQ-96` 量子化版を専用のC++/CUDAエンジン `strata-hy4` でローカル実行します。 + + Strataは、大規模なAIモデルをローカルで実行するためのオープンソース推論エンジンです。Hy4-Flashでは、密なトランク・MLA KVキャッシュ・高頻度エキスパートをGPUメモリに配置し、残りのエキスパートをシステムRAMに保持しつつ、4 KiB境界整列された `Engram-Q8` ルックアップテーブルを900 MiBのRAMキャッシュと組み合わせてNVMeストレージから直接ページングします。Model Consoleを通じてエンジンをOlaresに接続します。 + + **主な機能** + + - 対応するアプリで、テキストおよび画像入力からの応答生成、思考モード(`high` / `max`)、ツール呼び出しを利用できます。 + - 内蔵の5層 `DFly2` 投機的ドラフター(追加KVキャッシュ `0 B`)により生成を高速化します。 + - Model Consoleでモデルのダウンロード、準備状態の確認、エンジン設定の調整ができます。 + - Olares RouterまたはOpenAI互換のチャットAPIを通じて、対応するアプリを接続できます。 + + **このエディションについて** + + このエディション(`SQ-96`)はテキストと画像の入力に対応しています(`Hy4-Flash-Vision.strata` を `strata-hy4` 内でネイティブ実行)。動画入力は無効です。デフォルトのコンテキスト上限は131,072トークンで、一度に処理するリクエストは1件です。利用可能なコンテキストはメモリとエンジン設定によって異なります。 + + **初回利用前の確認事項** + + 初回起動時には3つの `.strata` v1.0ファイル(`Hy4-Flash-SQ-96.strata`、`Hy4-Flash-Engram-Q8.strata`、`Hy4-Flash-Vision.strata`、合計158.1 GB)をダウンロードします。`.strata` v1.0形式はGGUFの再パックなしで直接読み込まれるため、ダウンロード完了後はそのままトークナイザ展開とモデルロードに進みます。 + + AVX2対応CPU、高速なNVMeストレージ、およびR580シリーズ以降のNVIDIAドライバが必要です。このプリセットはOlares One(24 GiB VRAMおよび96 GiBホストRAM)向けに設計されています。インストール前に記載のリソース要件を確認してください。 + + [モデルのドキュメント](https://huggingface.co/tencent/Hy4-flash) · [量子化モデル](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Strataのドキュメント](https://github.com/Niko1221/Strata) diff --git a/stratahy4flashsq96/i18n/zh-CN/OlaresManifest.yaml b/stratahy4flashsq96/i18n/zh-CN/OlaresManifest.yaml new file mode 100644 index 000000000..fc7a423c4 --- /dev/null +++ b/stratahy4flashsq96/i18n/zh-CN/OlaresManifest.yaml @@ -0,0 +1,35 @@ +metadata: + title: Hy4-Flash SQ-96 (Strata) + description: "通过 Strata 本地运行的腾讯 Hy4-Flash SQ-96,支持图文理解、深度思考与工具调用" +spec: + upgradeDescription: | + 基于 Strata v0.2.18(strata-hy4 0.1.64)与 Model Console(llm-init v1.7.26)首发腾讯 Hy4-Flash SQ-96,专为 Olares One(24 GiB NVIDIA 显卡 + 96 GiB 内存)调优。 + + - 原生加载 `.strata` v1.0 格式 `SQ-96` 权重(`89.58 GB`)、共享 NVMe 查找表分片 `Engram-Q8`(`67.58 GB`)与原生 `Vision` 视觉分片(`0.93 GB`),首次启动无需漫长的 GGUF 转换等待。 + - 原生支持图像理解、`high`/`max` 推理强度调节、兼容 OpenAI 的工具调用,以及内置 5 层 `DFly2` 投机解码与 131,072 默认上下文。 + - 默认提供可编辑的 19 核 CPU 限制(平台配额上限 20 核)、16 个 AVX-VNNI CPU 专家工作线程、2 MiB 大页内存池折叠(`STRATA_CPUEXP_COLLAPSE=1`)、支持全动态显存 `AdaptiveExpertCache` 的 80 GiB 容器内存上限(57 GiB 安装需求),以及直接冷读取 I/O(`STRATA_CPUEXP_COLD_IO=direct`)。 + + [Strata v0.2.18](https://github.com/Niko1221/Strata/releases/tag/v0.2.18) + fullDescription: | + Tencent Hy4-Flash 是腾讯推出的 220B 总参数混合专家(MoE)多模态大模型(每 token 激活 12B 参数,其中 63.4B 参数位于 4 个 Engram 查找模块中),支持问答生成、图像理解、深度推理与工具调用。本应用通过专用 C++/CUDA 推理引擎 `strata-hy4` 在本地运行 Strata 原生 `.strata` v1.0 `SQ-96` 量化版本。 + + Strata 是用于在本地运行大型 AI 模型的开源推理引擎。针对 Hy4-Flash,它将稠密主干、MLA KV 缓存与高频热专家保留在 GPU 显存中,将其余专家常驻于系统内存,并通过 900 MiB 内存缓存从 NVMe 固态硬盘直接按 4 KiB 页对齐读取 `Engram-Q8` 查找表。Model Console 负责将引擎接入 Olares。 + + **主要功能** + + - 支持文本与图像多模态输入,并在兼容应用中支持深度思考(`high` / `max` 推理强度)与工具调用。 + - 内置 5 层 `DFly2` 投机解码草稿器(`0 B` 额外 KV 缓存开销),显著提升生成吞吐。 + - 通过 Model Console 下载模型、查看就绪状态并调整引擎参数。 + - 通过 Olares Router 或兼容 OpenAI 的聊天 API 接入各类应用。 + + **本版本说明** + + 本版本(`SQ-96`)支持文本与图像输入(`Hy4-Flash-Vision.strata` 在 `strata-hy4` 引擎内原生运行),未启用视频输入。默认上下文上限为 131,072 个 token,每次处理一个请求。实际可用上下文取决于内存余量与引擎设置。 + + **首次使用前** + + 首次启动将下载三个 `.strata` v1.0 文件(`Hy4-Flash-SQ-96.strata`、`Hy4-Flash-Engram-Q8.strata` 与 `Hy4-Flash-Vision.strata`,共约 158.1 GB)。由于 `.strata` v1.0 可直接加载而无需 GGUF 重打包,下载完成后即可直接提取分词器并加载模型。 + + 需要支持 AVX2 的 amd64 CPU、高速 NVMe 存储以及 R580 系列或更新版本的 NVIDIA 驱动。此预设专为 Olares One(24 GiB 显存与 96 GiB 主机内存)设计,安装前请确认列出的资源要求。 + + [模型文档](https://huggingface.co/tencent/Hy4-flash) · [量化模型](https://huggingface.co/strata-engine/Hy4-Flash-Strata) · [Strata 文档](https://github.com/Niko1221/Strata) diff --git a/stratahy4flashsq96/owners b/stratahy4flashsq96/owners new file mode 100644 index 000000000..3fed46050 --- /dev/null +++ b/stratahy4flashsq96/owners @@ -0,0 +1,2 @@ +owners: +- 'Niko1221' diff --git a/stratahy4flashsq96/templates/_helpers.tpl b/stratahy4flashsq96/templates/_helpers.tpl new file mode 100644 index 000000000..6f2f36f46 --- /dev/null +++ b/stratahy4flashsq96/templates/_helpers.tpl @@ -0,0 +1,39 @@ +{{- /* llmbase.gpuMiB: normalize a GPU-memory quantity to a BARE MiB integer for + HAMi's nvidia.com/gpumem. Its base unit is MiB and the value MUST be a + plain integer — a Mi/Gi suffix is misread by the scheduler (e.g. "6144Mi" + -> 6442450944). Accepts 8Gi / 8G / 8192Mi / 8192M / 8192 and returns MiB. + Usage: {{ include "llmbase.gpuMiB" ($oe.X_REQUIRED_GPU_MEMORY | default "4096") }} */ -}} +{{- define "llmbase.gpuMiB" -}} +{{- $g := trim . -}} +{{- if hasSuffix "Gi" $g -}} +{{- mul (int (trimSuffix "Gi" $g)) 1024 -}} +{{- else if hasSuffix "G" $g -}} +{{- mul (int (trimSuffix "G" $g)) 1024 -}} +{{- else if hasSuffix "Mi" $g -}} +{{- int (trimSuffix "Mi" $g) -}} +{{- else if hasSuffix "M" $g -}} +{{- int (trimSuffix "M" $g) -}} +{{- else -}} +{{- int $g -}} +{{- end -}} +{{- end -}} + +{{- define "strata.hfPath" -}} +/cache/hf/hub +{{- end -}} + +{{- define "strata.runStateSubpath" -}} +{{- /* Readiness, model_path and model-spec belong to one model identity. + Include MODEL_SOURCE (and any pinned revision) so an upgrade cannot + inherit an old ready sentinel or model card. Keep ENGINE_ARGS out: + tuning/restarts must preserve the user's card for the same model. + Both Deployments share this identity; legacy migration uses it too. */ -}} +{{- $oe := .Values.olaresEnv | default dict -}} +{{- $identity := list ($oe.MODEL_NAME | default "") ($oe.MODEL_SOURCE | default "") | toJson | sha256sum | trunc 20 -}} +{{- printf "llm-init-run/%s/model-%s" .Release.Name $identity -}} +{{- end -}} + +{{- define "strata.runStateHostPath" -}} +{{- $us := .Values.userspace | default dict -}} +{{- printf "%s/%s" ($us.appCommon | default "/olares/common") (include "strata.runStateSubpath" .) -}} +{{- end -}} diff --git a/stratahy4flashsq96/templates/llm-init.yaml b/stratahy4flashsq96/templates/llm-init.yaml new file mode 100644 index 000000000..a78de42cb --- /dev/null +++ b/stratahy4flashsq96/templates/llm-init.yaml @@ -0,0 +1,263 @@ +{{- $dom := .Values.domain | default dict -}} +{{- $us := .Values.userspace | default dict -}} +{{- $appCommon := $us.appCommon | default "/olares/common" -}} +{{- $appCache := $us.appCache | default "/olares/cache" -}} +{{- $strataclientDomainENV := split "," ($dom.strataclient | default "localhost") -}} +{{- $strataclientDomain := index $strataclientDomainENV "_0" -}} +{{- $oe := .Values.olaresEnv | default dict -}} +{{- $modelSource := $oe.MODEL_SOURCE | default "" -}} +{{- $modelName := $oe.MODEL_NAME | default "" -}} +{{- $modelMode := $oe.MODEL_MODE | default "" -}} +{{- /* MODEL_SUPPORTS is a multi-select of coarse capability GROUPS (vision / + tools / thinking). Expand each group one-to-many into the supports_* + keys llm-init validates against its gateway AllSupports mirror, then + re-join into the CSV the container env expects. "none" is the + required-field fallback (no extra capabilities); the legacy "embedding" + token is kept as an alias for it. Unknown tokens pass through verbatim + so a raw supports_* key still works. */ -}} +{{- $supportsGroups := dict + "vision" "supports_vision" + "tools" "supports_function_calling,supports_parallel_function_calling,supports_tool_choice" + "thinking" "supports_reasoning,supports_reasoning_effort" + "none" "" + "embedding" "" -}} +{{- $modelSupports := $oe.MODEL_SUPPORTS | default "" -}} +{{- $expandedSupports := list -}} +{{- range $tok := splitList "," $modelSupports -}} +{{- $tok = trim $tok -}} +{{- if $tok -}} +{{- if hasKey $supportsGroups $tok -}} +{{- $mapped := index $supportsGroups $tok -}} +{{- if $mapped -}} +{{- $expandedSupports = append $expandedSupports $mapped -}} +{{- end -}} +{{- else -}} +{{- $expandedSupports = append $expandedSupports $tok -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- $modelSupports = join "," $expandedSupports -}} +{{- /* Publish reasoning levels and the default on the model card for Router. */ -}} +{{- $reasoningEffort := $oe.MODEL_REASONING_EFFORT | default "" -}} +{{- $reasoningEffortDefault := $oe.MODEL_REASONING_EFFORT_DEFAULT | default "" -}} +{{- $engineArgs := $oe.ENGINE_ARGS | default "" -}} +{{- $logLevel := $oe.LOG_LEVEL | default "debug" -}} +{{- $hfEndpoint := $oe.HF_ENDPOINT | default "" -}} +{{- $hfToken := $oe.HF_TOKEN | default "" -}} +{{- $runStateHostPath := include "strata.runStateHostPath" . -}} +--- +# llm-init Pod (no GPU). Downloads the checkpoint, writes sentinel + model_path, +# serves progress UI + OpenAI /v1/* proxy on :8090, and reverse-proxies the +# engine at the URL it derives from ENGINE_KIND. +# +# ENGINE_KIND=strata routes to the strata Service on port 8080. +# The sidecar image must include native Strata support. +apiVersion: apps/v1 +kind: Deployment +metadata: + # Static name — engine Deployment uses {{ .Release.Name }} for allowMultipleInstall. + name: llminit + namespace: '{{ .Release.Namespace }}' + labels: + io.kompose.service: llm-init +spec: + replicas: {{ .Values.workloads.llminit.replicaCount }} + selector: + matchLabels: + io.kompose.service: llm-init + strategy: + type: Recreate + template: + metadata: + labels: + io.kompose.network/chrome-default: "true" + io.kompose.service: llm-init + spec: + restartPolicy: Always + enableServiceLinks: false + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + volumes: + - name: hf-cache + hostPath: + path: "{{ $appCommon }}/huggingface" + type: DirectoryOrCreate + - name: run-state + hostPath: + path: "{{ $runStateHostPath }}" + type: DirectoryOrCreate + - name: legacy-run-state + hostPath: + path: {{ printf "%s/%s" $appCache (include "strata.runStateSubpath" .) | quote }} + type: DirectoryOrCreate + initContainers: + # The first migration must run on the node holding this model's old Cache. + - name: migrate-run-state + image: docker.io/beclab/aboveos-busybox:1.37.0 + command: + - sh + - -ec + - | + mkdir -p /run/llm-init + chown 1000:1000 /run/llm-init + if [ -f /run/llm-init/model-spec.json ]; then + exit 0 + fi + if [ -f /legacy-run-state/model-spec.json ]; then + # Publish the config last so an interrupted copy can be retried. + stage=/run/llm-init/.legacy-migration + mkdir -p "$stage" + cp -a /legacy-run-state/. "$stage/" + mv "$stage/model-spec.json" /run/llm-init/.model-spec.migrating + cp -a "$stage/." /run/llm-init/ + rm -rf "$stage" + mv /run/llm-init/.model-spec.migrating /run/llm-init/model-spec.json + fi + volumeMounts: + - {name: legacy-run-state, mountPath: /legacy-run-state, readOnly: true} + - {name: run-state, mountPath: /run/llm-init} + securityContext: {runAsUser: 0} + resources: + requests: {cpu: 10m, memory: 16Mi} + limits: {cpu: 100m, memory: 64Mi} + # 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 + - -ec + - | + hub={{ include "strata.hfPath" . | quote }} + repo="$hub/models--strata-engine--Hy4-Flash-Strata" + # The engine's nested strata-data hostPath can create this parent as root. + # Fix only these known directories, never recursively chown shared models. + mkdir -p "$hub/.locks/models--strata-engine--Hy4-Flash-Strata" "$repo/blobs" "$repo/refs" "$repo/snapshots" + chown 1000:1000 "$hub" "$hub/.locks" "$hub/.locks/models--strata-engine--Hy4-Flash-Strata" "$repo" "$repo/blobs" "$repo/refs" "$repo/snapshots" /run/llm-init + volumeMounts: + - name: hf-cache + mountPath: {{ include "strata.hfPath" . }} + - name: run-state + mountPath: /run/llm-init + resources: + requests: {cpu: 10m, memory: 16Mi} + limits: {cpu: 100m, memory: 64Mi} + securityContext: + runAsUser: 0 + containers: + - name: llm-init + # Built with native ENGINE_KIND=strata support. + image: {{ .Values.images.llmInit | quote }} + imagePullPolicy: IfNotPresent + env: + - name: HF_HUB_CACHE + value: {{ include "strata.hfPath" . | quote }} + - name: ENGINE_KIND + value: strata + - name: MODEL_NAME + value: "{{ $modelName }}" + - name: MODEL_SOURCE + value: {{ $modelSource | quote }} + - name: MODEL_MODE + value: "{{ $modelMode }}" +{{- if $modelSupports }} + - name: MODEL_SUPPORTS + value: "{{ $modelSupports }}" +{{- end }} +{{- if $reasoningEffort }} + - name: MODEL_REASONING_EFFORT + value: "{{ $reasoningEffort }}" +{{- end }} +{{- if $reasoningEffortDefault }} + - name: MODEL_REASONING_EFFORT_DEFAULT + value: "{{ $reasoningEffortDefault }}" +{{- end }} + - name: ENGINE_ARGS + value: {{ $engineArgs | quote }} + # Enable Hugging Face Xet for >50 GB single-file .strata downloads (SQ-96 89.6 GB, Engram-Q8 67.6 GB). + - name: HF_ENABLE_XET + value: "true" +{{- if $hfEndpoint }} + - name: HF_ENDPOINT + value: "{{ $hfEndpoint }}" +{{- end }} +{{- if $hfToken }} + - name: HF_TOKEN + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-secrets + key: HF_TOKEN +{{- end }} + - name: RUN_DIR + value: /run/llm-init + - name: PORT + value: "8090" + - name: LOG_LEVEL + value: "{{ $logLevel }}" + - name: LOG_FORMAT + value: json + - name: APP_URL + value: "https://{{ $strataclientDomain }}" + ports: + - name: http + containerPort: 8090 + livenessProbe: + httpGet: + path: /livez + port: 8090 + periodSeconds: 30 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: /livez + port: 8090 + initialDelaySeconds: 3 + periodSeconds: 5 + timeoutSeconds: 3 + failureThreshold: 3 + volumeMounts: + - name: hf-cache + mountPath: {{ include "strata.hfPath" . }} + - name: run-state + mountPath: /run/llm-init + resources: + requests: + cpu: 200m + memory: 256Mi + limits: + # The .strata files stream to disk with a bounded footprint, + # while huggingface_hub / Xet runs inside this 2Gi cgroup. + cpu: "1" + memory: 2Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: download-svc + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: llm-init +spec: + selector: + io.kompose.service: llm-init + ports: + - name: http + port: 8090 + targetPort: 8090 + type: ClusterIP +--- +apiVersion: v1 +kind: Service +metadata: + name: sharedentrances-api + namespace: {{ .Release.Namespace }} + labels: + io.kompose.service: llm-init +spec: + selector: + io.kompose.service: llm-init + ports: + - name: http + port: 80 + targetPort: 8090 + type: ClusterIP diff --git a/stratahy4flashsq96/templates/secret.yaml b/stratahy4flashsq96/templates/secret.yaml new file mode 100644 index 000000000..b641803b1 --- /dev/null +++ b/stratahy4flashsq96/templates/secret.yaml @@ -0,0 +1,15 @@ +{{- $oe := .Values.olaresEnv | default dict -}} +{{- $hfToken := $oe.HF_TOKEN | default "" -}} +{{- if $hfToken }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-secrets + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: stratahy4flashsq96 + app.kubernetes.io/instance: {{ .Release.Name }} +type: Opaque +stringData: + HF_TOKEN: {{ $hfToken | quote }} +{{- end }} diff --git a/stratahy4flashsq96/templates/strata.yaml b/stratahy4flashsq96/templates/strata.yaml new file mode 100644 index 000000000..d4c83c6d8 --- /dev/null +++ b/stratahy4flashsq96/templates/strata.yaml @@ -0,0 +1,149 @@ +{{- $oe := .Values.olaresEnv | default dict -}} +{{- $us := .Values.userspace | default dict -}} +{{- $appCommon := $us.appCommon | default "/olares/common" -}} +{{- $gpuMiB := include "llmbase.gpuMiB" ($oe.STRATA_REQUIRED_GPU_MEMORY | default "23Gi") -}} +{{- $runStateHostPath := include "strata.runStateHostPath" . -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + namespace: {{ .Release.Namespace }} + annotations: + applications.app.bytetrade.io/gpu-inject: strata +spec: + replicas: {{ .Values.workloads.stratahy4flashsq96.replicaCount }} + selector: + matchLabels: {io.kompose.service: strata} + strategy: {type: Recreate} + template: + metadata: + labels: + io.kompose.service: strata + annotations: + checksum/wrappers: {{ include (print $.Template.BasePath "/wrappers.yaml") . | sha256sum }} + spec: + enableServiceLinks: false + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + terminationGracePeriodSeconds: 60 + volumes: + - name: hf-cache + hostPath: + path: "{{ $appCommon }}/huggingface" + type: DirectoryOrCreate + - name: run-state + hostPath: + path: {{ $runStateHostPath | quote }} + type: DirectoryOrCreate + - name: strata-data + hostPath: + # Keep extracted tokenizer, SHA-256 .done marks, and runtime state beside + # the HF weights. Mount only this app's subdirectory writable at /data; + # the shared HF cache remains read-only in the engine container. + path: "{{ $appCommon }}/huggingface/models--strata-engine--Hy4-Flash-Strata/strata-data" + type: DirectoryOrCreate + - name: wrappers + configMap: + name: llm-init-wrappers + defaultMode: 0555 + initContainers: + - name: init-permissions + image: docker.io/beclab/aboveos-busybox:1.37.0 + command: [sh, -ec, "chown 1000:1000 /data"] + securityContext: {runAsUser: 0} + volumeMounts: + - {name: strata-data, mountPath: /data} + resources: + requests: {cpu: 10m, memory: 16Mi} + limits: {cpu: 100m, memory: 64Mi} + containers: + - name: strata + image: {{ .Values.images.strata | quote }} + imagePullPolicy: IfNotPresent + # bash job control gives the supervisor a process group even without a tty. + command: [/bin/bash, /llm-init/wrappers/strata.sh] + env: + - name: HF_HUB_CACHE + value: {{ include "strata.hfPath" . | quote }} + - {name: ENGINE_KIND, value: strata} + - {name: WRAPPER_COMMON, value: /run/llm-init/wrappers/common.sh} + - {name: WAIT_TIMEOUT, value: "86400"} + - {name: WRAPPER_COMMON_WAIT, value: "86400"} + - {name: STRATA_PORT, value: "8080"} + - name: STRATA_ALLOWED_HOSTS + value: strata + - {name: STRATA_DATA, value: /data} + - {name: XDG_CONFIG_HOME, value: /data/config} + - {name: XDG_CACHE_HOME, value: /data/cache} + - {name: XDG_STATE_HOME, value: /data/state} + - {name: HOME, value: /data/home} + - {name: PYTHONUNBUFFERED, value: "1"} + - {name: PYTHONNOUSERSITE, value: "1"} + - {name: STRATA_READ_AHEAD, value: "1"} + # Collapse the ~72 GB CPU expert arena into 2 MiB transparent hugepages at load to eliminate 4 KiB DTLB misses. + - {name: STRATA_CPUEXP_COLLAPSE, value: "1"} + # Bypass cgroup page cache on any cold expert SSD reads. + - {name: STRATA_CPUEXP_COLD_IO, value: "direct"} + - name: MODEL_NAME + value: {{ $oe.MODEL_NAME | quote }} + - name: ENGINE_ARGS + value: {{ $oe.ENGINE_ARGS | default "" | quote }} + - name: OMP_NUM_THREADS + value: {{ .Values.strata.cpuThreads | quote }} + - name: HY4_CPU_THREADS + value: {{ .Values.strata.cpuThreads | quote }} +{{- if $oe.HF_ENDPOINT }} + - name: HF_ENDPOINT + value: {{ $oe.HF_ENDPOINT | quote }} +{{- end }} +{{- if $oe.HF_TOKEN }} + - name: HF_TOKEN + valueFrom: + secretKeyRef: {name: {{ .Release.Name }}-secrets, key: HF_TOKEN} +{{- end }} + ports: + - {name: http, containerPort: 8080} + # Olares waits for startupProbe before completing installation. + # The wrapper can be started while llm-init is still downloading; + # readiness below remains gated on the fully loaded model. + # No liveness probe: a Model Console relaunch may legitimately take minutes. + startupProbe: + exec: + command: [/bin/bash, -ec, 'kill -0 1; test -r /run/llm-init/wrappers/common.sh'] + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 8640 + # Dual-layout readiness probe: works on both Beclab (/opt/strata/.venv/bin/python) + # and upstream ghcr.io (/opt/strata/terminal/python/bin/python3) images. + readinessProbe: + exec: + command: [/bin/sh, /llm-init/wrappers/strata-healthcheck.sh] + periodSeconds: 5 + timeoutSeconds: 5 + failureThreshold: 1 + volumeMounts: + - {name: hf-cache, mountPath: {{ include "strata.hfPath" . }}, readOnly: true} + - {name: run-state, mountPath: /run/llm-init, readOnly: true} + - {name: strata-data, mountPath: /data} + - {name: wrappers, mountPath: /llm-init/wrappers, readOnly: true} + resources: + requests: + cpu: {{ $oe.STRATA_CPU_REQUEST | default "1" | quote }} + memory: {{ $oe.STRATA_MEMORY_REQUEST | default "56Gi" | quote }} + nvidia.com/gpumem: {{ $gpuMiB }} + limits: + cpu: {{ $oe.STRATA_CPU_LIMIT | default "19" | quote }} + memory: {{ $oe.STRATA_MEMORY_LIMIT | default "80Gi" | quote }} + nvidia.com/gpumem: {{ $gpuMiB }} +--- +apiVersion: v1 +kind: Service +metadata: + name: strata + namespace: {{ .Release.Namespace }} +spec: + selector: {io.kompose.service: strata} + ports: + - {name: http, port: 8080, targetPort: 8080} + type: ClusterIP diff --git a/stratahy4flashsq96/templates/wrappers.yaml b/stratahy4flashsq96/templates/wrappers.yaml new file mode 100644 index 000000000..8a61f739b --- /dev/null +++ b/stratahy4flashsq96/templates/wrappers.yaml @@ -0,0 +1,714 @@ +# Scripts are embedded here, matching the Beclab Strata chart layout. +# The ConfigMap mounts them under /llm-init/wrappers in the engine container. +# Supports BOTH container layouts out of the box: +# a) Beclab layout: /opt/strata/.venv/bin/python + /opt/strata/{setup.py,serve/server.py} +# b) Upstream ghcr.io: /opt/strata/terminal/python/bin/python3 + /opt/strata/terminal/{setup.py,serve/server.py} +apiVersion: v1 +kind: ConfigMap +metadata: + name: llm-init-wrappers + namespace: {{ .Release.Namespace }} +data: + strata.sh: | + #!/bin/sh + set -eu + + ENGINE=strata + WRAPPER_COMMON=${WRAPPER_COMMON:-"$(dirname "$0")/common.sh"} + # Snapshot the shared helper locally; a cross-node update may briefly fail to open. + _common_copy=$(mktemp "${TMPDIR:-/tmp}/strata-common.XXXXXX") + _wc=0 + while ! cp "$WRAPPER_COMMON" "$_common_copy" 2>/dev/null; do + if [ "$_wc" -ge "${WRAPPER_COMMON_WAIT:-3600}" ]; then + rm -f "$_common_copy" + printf '[wrapper] %s could not be read\n' "$WRAPPER_COMMON" >&2 + exit 1 + fi + printf '[wrapper] waiting for %s (elapsed=%ss)\n' "$WRAPPER_COMMON" "$_wc" + sleep 5 + _wc=$((_wc + 5)) + done + # shellcheck source=common.sh + . "$_common_copy" + rm -f "$_common_copy" + unset _wc _common_copy + + python_usable() { + [ -f "$1" ] || return 1 + [ -x "$1" ] && return 0 + "$1" -c 'pass' 2>/dev/null + } + + resolve_python() { + if [ -n "${STRATA_PYTHON:-}" ] && python_usable "$STRATA_PYTHON"; then + printf '%s\n' "$STRATA_PYTHON" + return 0 + fi + for cand in \ + /opt/strata/.venv/bin/python \ + /opt/strata/.venv/bin/python3 \ + /opt/strata/terminal/python/bin/python3 \ + /opt/strata/python/bin/python3 \ + "$(command -v python3 2>/dev/null || true)"; do + if [ -n "$cand" ] && python_usable "$cand"; then + printf '%s\n' "$cand" + return 0 + fi + done + printf '[wrapper] FATAL: no usable Python interpreter found under /opt/strata\n' >&2 + return 1 + } + + resolve_root() { + if [ -n "${STRATA_ROOT:-}" ] && [ -f "$STRATA_ROOT/setup.py" ]; then + printf '%s\n' "$STRATA_ROOT" + return 0 + fi + for cand in /opt/strata /opt/strata/terminal; do + if [ -f "$cand/setup.py" ] && [ -f "$cand/serve/server.py" ]; then + printf '%s\n' "$cand" + return 0 + fi + done + printf '[wrapper] FATAL: neither /opt/strata nor /opt/strata/terminal contains setup.py + serve/server.py\n' >&2 + return 1 + } + + wait_for_sentinel + wait_for_engine_args_handoff + MODEL_PATH=$(read_model_path) + STRATA_PYTHON=$(resolve_python) + STRATA_ROOT=$(resolve_root) + export MODEL_PATH STRATA_PYTHON STRATA_ROOT + + run_strata() { + load_engine_args_from_handoff + export ENGINE_ARGS + exec "$STRATA_PYTHON" \ + "${STRATA_LAUNCHER:-/llm-init/wrappers/prepare-strata.py}" "$@" + } + + supervise_engine run_strata "$@" + prepare-strata.py: | + #!/usr/bin/env python3 + """Prepare Tencent Hy4-Flash SQ-96 (.strata v1.0) across Beclab & upstream Strata layouts, then exec serve/server.py.""" + import hashlib + import json + import os + from pathlib import Path + import shlex + import signal + import subprocess + import sys + + STRATA_MAGICS = (b'STRATA\x00\x01', b'STRATA1\x00') + STRATA_MAGIC = STRATA_MAGICS[0] + + # Exact byte sizes and whole-file SHA-256 digests from Strata 0.2.18 (strata_control/hy4_family.py). + EXPECTED_FILES = { + 'Hy4-Flash-SQ-96.strata': (89_577_742_336, '3b1c5755a220c69892b3d2dbad506b8593a30be24b17a390ecbd1642c0c1e14c'), + 'Hy4-Flash-Engram-Q8.strata': (67_584_905_216, 'ab0cf9b3f9c64bd25f6212d4508e7443ab8b9bc133fbccc7bdfb83510a20c2c1'), + 'Hy4-Flash-Vision.strata': (934_092_800, 'ef09bceff8f01b8d226d2dc56aef09cec719b21b45783ee9b5d64e7241b72a09'), + } + + # Optional HF commit SHA pin; set once strata-engine/Hy4-Flash-Strata revision is frozen. + EXPECTED_REVISION = os.environ.get('STRATA_EXPECTED_REVISION', '').strip() + + # Flags owned by the chart's download, networking, and model contract. + MANAGED = { + '--family', '--model', '--native', '--engram', '--data-dir', '--models-dir', + '--gguf-dir', '--host', '--port', '--api-key', '--backend', '--vision', + '--gpu', '--gpus', '--prebuilt', '--build', '--setup', '--yes', '--no-start', + '--check', '--update', '--inspect', '--browser', '--no-browser', '--skip-build', + '--rollback-engine', '--cuda', '--serve', '--export-tokenizer', '--info', + } + + # Direct strata-hy4 runtime flags that are merged into server.json's args/drafting + # rather than passed to setup.py's ArgumentParser. + HY4_VALUE_FLAGS = { + '--draft', '--max-context', '--ctx', '--chunk', '--spec-k', '--spec-cut', + '--spec-rv', '--spec-inv', '--spec-exact', '--det', '--mla-blocks', '--mla-inv', + '--session-reuse', '--image-max-pixels', '--index-topk', '--tail-skip', + '--vram-experts-gb', '--ram-experts-gb', '--engram-cache-mib', + } + HY4_BOOL_FLAGS = { + '--spec-fixed', '--spec-debug', '--spec-check', '--spec-nodraft', + '--no-index', '--no-engram', '--knobs16', '--dfly-warm', + } + + + def resolve_strata_root(env=None): + """Locate setup.py + serve/server.py across Beclab (/opt/strata) and upstream (/opt/strata/terminal) layouts.""" + env = os.environ if env is None else env + explicit = env.get('STRATA_ROOT', '').strip() + app_base = Path(env.get('STRATA_APP', '/opt/strata')) + candidates = [] + if explicit: + p = Path(explicit) + candidates.extend([p, p / 'terminal']) + candidates.extend([app_base, app_base / 'terminal']) + seen = set() + for cand in candidates: + key = str(cand) + if key in seen: + continue + seen.add(key) + if (cand / 'setup.py').is_file() and (cand / 'serve' / 'server.py').is_file(): + return cand + raise FileNotFoundError( + f'Could not locate Strata setup.py + serve/server.py under {[str(c) for c in candidates]}') + + + def bridge_components_dir(app_base, data_root, env=None): + """Create a writable STRATA_COMPONENTS_DIR under /data/components linked to read-only image components.""" + env = os.environ if env is None else env + writable = Path(data_root) / 'components' + writable.mkdir(parents=True, exist_ok=True) + src_candidates = [] + if env.get('STRATA_COMPONENTS_DIR'): + src_candidates.append(Path(env['STRATA_COMPONENTS_DIR'])) + src_candidates.append(Path(app_base) / 'components') + for src in src_candidates: + try: + if not src.is_dir() or src.resolve() == writable.resolve(): + continue + except OSError: + continue + eng_src = src / 'engine' + eng_dst = writable / 'engine' + if eng_src.is_dir() and not eng_dst.exists(): + eng_dst.symlink_to(eng_src, target_is_directory=True) + shapes_src = src / 'shapes' + if shapes_src.is_dir(): + for shape_dir in sorted(shapes_src.iterdir()): + if not shape_dir.is_dir(): + continue + dst_pkg_parent = writable / 'shapes' / shape_dir.name / 'engine' + src_pkg_parent = shape_dir / 'engine' + if src_pkg_parent.is_dir(): + dst_pkg_parent.mkdir(parents=True, exist_ok=True) + for pkg in sorted(src_pkg_parent.iterdir()): + if pkg.is_dir(): + link = dst_pkg_parent / pkg.name + if not link.exists(): + link.symlink_to(pkg, target_is_directory=True) + return writable + + + def find_hy4_engine(root, components_dir, app_base): + """Locate strata-hy4 across signed shape components and flat Beclab /opt/strata/engine layouts. + + Returns (exe_path_or_None, is_shape_component, lib_dirs). + """ + exe_names = ('strata-hy4.exe', 'strata-hy4') if os.name == 'nt' else ('strata-hy4',) + # 1. Signed/packaged shape component: /shapes/hy4/engine//strata-hy4 + for comp_root in (Path(components_dir), Path(app_base) / 'components', Path(root) / 'components'): + shape_eng = comp_root / 'shapes' / 'hy4' / 'engine' + if shape_eng.is_dir(): + for pkg in sorted(shape_eng.iterdir(), reverse=True): + if not pkg.is_dir(): + continue + for ename in exe_names: + cand = pkg / ename + if cand.is_file(): + has_manifest = (pkg / 'engine-component.json').is_file() + libs = [str(pkg)] + [str(d) for d in sorted(pkg.iterdir()) if d.is_dir()] + return cand, has_manifest, libs + + # 2. Bundled inside /engine//strata-hy4 or flat /engine/strata-hy4 + flat_dirs = [] + for comp_root in (Path(components_dir), Path(app_base) / 'components', Path(root) / 'components'): + eng_dir = comp_root / 'engine' + if eng_dir.is_dir(): + flat_dirs.extend(sorted((d for d in eng_dir.iterdir() if d.is_dir()), reverse=True)) + flat_dirs.append(eng_dir) + flat_dirs.extend([Path(root) / 'engine', Path(app_base) / 'engine']) + + seen = set() + for d in flat_dirs: + key = str(d) + if key in seen or not d.is_dir(): + continue + seen.add(key) + for ename in exe_names: + cand = d / ename + if cand.is_file(): + libs = [str(d)] + [str(sub) for sub in sorted(d.iterdir()) if sub.is_dir()] + return cand, False, libs + + return None, False, [] + + + def verify_snapshot(model_path, expected_files=None, expected_revision=None): + """Verify all 3 .strata files exist in the HF snapshot with exact byte sizes and STRATA1\\0 magic.""" + expected_files = EXPECTED_FILES if expected_files is None else expected_files + expected_revision = EXPECTED_REVISION if expected_revision is None else expected_revision + source = Path(model_path) + if source.is_file(): + source = source.parent + if not source.is_dir(): + raise ValueError(f'MODEL_PATH directory does not exist: {source}') + + if expected_revision: + # Handle both snapshots//file and snapshots//subdir/file + snap_name = None + if source.parent.name == 'snapshots': + snap_name = source.name + elif source.parent.parent.name == 'snapshots': + snap_name = source.parent.name + if snap_name and snap_name != expected_revision: + raise ValueError( + f'Wrong HF revision {snap_name}; expected {expected_revision}. ' + 'Download the pinned Hy4-Flash model in Model Console before starting.') + + missing = [name for name in expected_files if not (source / name).is_file()] + if missing: + raise ValueError( + f'Incomplete Hy4-Flash snapshot in {source}; llm-init must download all 3 .strata files. Missing: {missing}') + + for name, spec in expected_files.items(): + exp_size = spec[0] if isinstance(spec, tuple) else int(spec) + fpath = source / name + actual_size = fpath.stat().st_size + if actual_size != exp_size: + raise ValueError( + f'Size mismatch for {name} in {source}: got {actual_size:,} bytes, expected {exp_size:,} bytes') + if actual_size >= len(STRATA_MAGIC): + with fpath.open('rb') as fp: + head = fp.read(len(STRATA_MAGIC)) + if head not in STRATA_MAGICS: + raise ValueError( + f'Invalid .strata header in {fpath}: expected {STRATA_MAGIC!r}, got {head!r}') + + return source + + + def parse_engine_args(raw): + """Validate ENGINE_ARGS against MANAGED flags and split into setup.py flags vs strata-hy4 overrides.""" + tokens = shlex.split(raw or '') + for tok in tokens: + flag = tok.split('=', 1)[0] + if flag in MANAGED: + raise ValueError(f'{tok}: managed by the Strata chart, not ENGINE_ARGS') + + setup_flags = [] + hy4_args = [] + draft_override = None + has_context = False + + i = 0 + while i < len(tokens): + tok = tokens[i] + flag, eq, inline_val = tok.partition('=') + + def take_val(): + nonlocal i + if eq: + return inline_val + if i + 1 >= len(tokens): + raise ValueError(f'{flag} in ENGINE_ARGS requires a value') + i += 1 + return tokens[i] + + if flag == '--context': + val = take_val() + if not val.isdigit() or int(val) <= 0: + raise ValueError(f'--context requires a positive integer, got {val!r}') + setup_flags.extend(['--context', val]) + has_context = True + elif flag in ('--max-context', '--ctx'): + val = take_val() + if not val.isdigit() or int(val) <= 0: + raise ValueError(f'{flag} requires a positive integer, got {val!r}') + setup_flags.extend(['--context', val]) + hy4_args.extend(['--max-context', val]) + has_context = True + elif flag in ('--draft', '--drafting'): + val = take_val().lower() + if val not in ('off', 'dfly2', 'auto'): + raise ValueError(f'{flag} for Hy4-Flash must be one of off, dfly2, auto (got {val!r})') + draft_override = val + hy4_args.extend(['--draft', val]) + elif flag == '--parallel': + val = take_val() + if val != '1': + raise ValueError( + f'--parallel {val}: strata-hy4 processes one request at a time (--parallel 1 only)') + elif flag in HY4_VALUE_FLAGS: + val = take_val() + hy4_args.extend([flag, val]) + elif flag in HY4_BOOL_FLAGS: + if eq: + raise ValueError(f'{tok}: boolean flag takes no value') + hy4_args.append(flag) + else: + # Pass other non-managed setup.py flags through (e.g. --kv fp16). + if eq: + setup_flags.append(tok) + else: + setup_flags.append(tok) + if i + 1 < len(tokens) and not tokens[i + 1].startswith('-'): + i += 1 + setup_flags.append(tokens[i]) + i += 1 + + if not has_context: + setup_flags = ['--context', '131072', *setup_flags] + + return setup_flags, hy4_args, draft_override + + + def merge_hy4_args(base_args, overrides): + """Merge strata-hy4 override flags over setup.py's generated args without duplicating single-value flags.""" + out = list(base_args or []) + i = 0 + while i < len(overrides): + flag = overrides[i] + if flag in HY4_VALUE_FLAGS and i + 1 < len(overrides): + val = overrides[i + 1] + if flag in out: + idx = out.index(flag) + if idx + 1 < len(out): + out[idx + 1] = val + else: + out.append(val) + else: + out.extend([flag, val]) + i += 2 + else: + if flag not in out: + out.append(flag) + i += 1 + return out + + + def engine_build_identity(root, app_base, hy4_exe): + """Read engine build metadata so cache keys rotate cleanly on image/engine upgrades.""" + candidates = [] + if hy4_exe is not None: + candidates.extend([hy4_exe.parent / 'engine-component.json', hy4_exe.parent / 'BUILD.json']) + candidates.extend([ + Path(root) / 'engine' / 'BUILD.json', + Path(app_base) / 'engine' / 'BUILD.json', + Path(root) / 'VERSION', + Path(root) / 'COMMIT', + ]) + comp_eng = Path(app_base) / 'components' / 'engine' + if comp_eng.is_dir(): + for pkg in sorted(comp_eng.iterdir()): + if pkg.is_dir(): + candidates.extend([pkg / 'engine-component.json', pkg / 'BUILD.json']) + parts = [] + for c in candidates: + if c.is_file(): + try: + parts.append(c.read_text(encoding='utf-8', errors='replace').strip()) + except OSError: + pass + return '|'.join(parts) if parts else 'strata-0.2.18-hy4' + + + def link_model_files(source, hy4_dir, expected_files=None): + """Symlink the 3 read-only HF .strata blobs into writable /models/hy4-flash/.""" + expected_files = EXPECTED_FILES if expected_files is None else expected_files + hy4_dir.mkdir(parents=True, exist_ok=True) + paths = {} + for name, spec in expected_files.items(): + exp_sha = spec[1] if isinstance(spec, tuple) and len(spec) > 1 else None + target_blob = (source / name).resolve() + link = hy4_dir / name + done_mark = hy4_dir / (name + '.done') + if not link.is_symlink() or link.resolve() != target_blob: + link.unlink(missing_ok=True) + done_mark.unlink(missing_ok=True) + link.symlink_to(target_blob) + # When huggingface_hub content-addressed the blob under blobs/ matching + # Strata's pinned SHA-256, prime the .done marker so first start skips redundant + # 158 GB re-hashing; otherwise setup.py hashes once and writes .done itself. + if exp_sha and not done_mark.is_file() and target_blob.name.lower() == exp_sha.lower(): + done_mark.write_text(f'sha256 {exp_sha}\n', encoding='utf-8') + paths[name] = link + return paths + + + def ensure_tokenizer(root, model_file, tok_dir, hy4_exe, lib_dirs): + """Ensure serve's tokenizer directory contains vocab.json + chat_template.jinja.""" + if (tok_dir / 'vocab.json').is_file() and (tok_dir / 'chat_template.jinja').is_file(): + return tok_dir + tok_dir.parent.mkdir(parents=True, exist_ok=True) + tools_dir = str(Path(root) / 'tools') + if tools_dir not in sys.path: + sys.path.insert(0, tools_dir) + import hy4_tokenizer # bundled in Strata 0.2.18 terminal/tools/hy4_tokenizer.py + try: + hy4_tokenizer.convert_manifest(hy4_tokenizer.read_manifest(model_file), tok_dir) + return tok_dir + except RuntimeError: + pass + if hy4_exe is None or not Path(hy4_exe).is_file(): + raise RuntimeError( + 'Tokenizer extraction requires either Python zstd or strata-hy4 --export-tokenizer, ' + 'but strata-hy4 was not found') + raw = tok_dir.with_name(tok_dir.name + '-export') + raw.mkdir(parents=True, exist_ok=True) + env = dict(os.environ) + if lib_dirs: + var = 'PATH' if os.name == 'nt' else 'LD_LIBRARY_PATH' + existing = [d for d in lib_dirs if Path(d).is_dir()] + if existing: + env[var] = os.pathsep.join(existing + ([env[var]] if env.get(var) else [])) + res = subprocess.run( + [str(hy4_exe), '--export-tokenizer', str(model_file), str(raw)], + env=env, cwd=str(Path(hy4_exe).parent), check=False) + if res.returncode != 0: + raise RuntimeError(f'strata-hy4 --export-tokenizer exited with status {res.returncode}') + hy4_tokenizer.convert_files(raw / 'tokenizer.hf.json', raw / 'chat_template.jinja', tok_dir) + return tok_dir + + + def tune_cpu_threads_for_cgroup(env=None): + """Cap HY4_CPU_THREADS and OMP_NUM_THREADS if the user lowered STRATA_CPU_LIMIT in Model Console.""" + env = os.environ if env is None else env + configured = int(env.get('HY4_CPU_THREADS') or env.get('OMP_NUM_THREADS') or '16') + cgroup_cores = None + cpu_max = Path('/sys/fs/cgroup/cpu.max') + if cpu_max.is_file(): + try: + parts = cpu_max.read_text(encoding='utf-8').strip().split() + if len(parts) == 2 and parts[0] != 'max': + quota, period = int(parts[0]), int(parts[1]) + if quota > 0 and period > 0: + cgroup_cores = max(1, quota // period) + except (OSError, ValueError): + pass + if cgroup_cores is not None: + # Leave up to 2 cores for CUDA dispatch/HTTP server when >=4 cores are assigned. + safe_cap = max(1, cgroup_cores - 2) if cgroup_cores >= 4 else cgroup_cores + effective = min(configured, safe_cap) + else: + effective = configured + return str(max(1, effective)) + + + def run_setup(command, cwd, env): + """Run setup.py in its own process group so SIGTERM stops any child helper cleanly.""" + kwargs = {'cwd': str(cwd), 'env': env} + if os.name != 'nt': + kwargs['start_new_session'] = True + child = subprocess.Popen(command, **kwargs) + + def stop(signum, _frame): + if os.name != 'nt': + os.killpg(child.pid, signal.SIGTERM) + else: + child.terminate() + try: + child.wait(timeout=10) + except subprocess.TimeoutExpired: + if os.name != 'nt': + os.killpg(child.pid, signal.SIGKILL) + else: + child.kill() + child.wait() + raise SystemExit(128 + signum) + + signals = [signal.SIGTERM, signal.SIGINT] + old = {sig: signal.signal(sig, stop) for sig in signals} + try: + if child.wait() != 0: + raise RuntimeError('Strata setup failed; refusing to start with stale configuration') + finally: + for sig, handler in old.items(): + signal.signal(sig, handler) + + + def publish_model_name(cfg, env=None): + """Publish canonical model_name and Model Console's public MODEL_NAME alias.""" + env = os.environ if env is None else env + public = env.get('MODEL_NAME', '').strip() or 'hy4-flash-sq-96' + native = str(cfg.get('model_name') or '').strip() or 'hy4-flash-sq-96' + cfg['model_name'] = native + cfg['aliases'] = [public] + + + def prepare_server_config(env=None, expected_files=None): + """Validate snapshot, run setup.py in writable /data, and write /data//server.json. + + Returns (root, target_config_path, port, exec_argv). + """ + env = dict(os.environ if env is None else env) + app_base = Path(env.get('STRATA_APP', '/opt/strata')) + root = resolve_strata_root(env) + source = verify_snapshot(env['MODEL_PATH'], expected_files=expected_files) + setup_flags, hy4_overrides, draft_override = parse_engine_args(env.get('ENGINE_ARGS', '')) + + data_base = Path(env.get('STRATA_DATA', '/data')) + data_base.mkdir(parents=True, exist_ok=True) + components_dir = bridge_components_dir(app_base, data_base, env=env) + hy4_exe, is_shape_component, lib_dirs = find_hy4_engine(root, components_dir, app_base) + + identity = str(source.resolve()) + '|' + engine_build_identity(root, app_base, hy4_exe) + key = hashlib.sha256(identity.encode('utf-8')).hexdigest()[:20] + data = data_base / key + models_dir = data / 'models' + hy4_dir = models_dir / 'hy4-flash' + install_dir = data / 'install' + for d in (data, models_dir, hy4_dir, install_dir): + d.mkdir(parents=True, exist_ok=True) + + linked = link_model_files(source, hy4_dir, expected_files=expected_files) + port = env.get('STRATA_PORT', '8080').strip() or '8080' + + generated = install_dir / 'strata-hy4-flash-sq-96.json' + generated.unlink(missing_ok=True) + (root / 'strata-hy4-flash-sq-96.json').unlink(missing_ok=True) if os.access(root, os.W_OK) else None + + setup_env = dict(env) + setup_env['STRATA_CONTROL_INSTALL'] = '1' + setup_env['STRATA_INSTALL_DIR'] = str(install_dir) + setup_env['STRATA_COMPONENTS_DIR'] = str(components_dir) + if hy4_exe is not None and not is_shape_component: + # Flat /opt/strata/engine/strata-hy4 layout: skip network feed lookup in setup.py + # and bind the resolved binary directly into server.json below. + setup_env['STRATA_ALLOW_NO_ENGINE'] = '1' + + command = [ + sys.executable, str(root / 'setup.py'), + '--setup', '--yes', '--no-start', '--no-browser', + '--family', 'hy4-flash', '--model', 'SQ-96', '--backend', 'cuda', + '--gpu', '0', '--vision', 'yes', '--data-dir', str(data), + '--models-dir', str(models_dir), '--host', '0.0.0.0', '--port', port, + *setup_flags, + ] + print('[strata] preparing Hy4-Flash SQ-96 (.strata v1.0) runtime configuration', flush=True) + run_setup(command, root, setup_env) + + # Refresh engine discovery in case setup.py fetched shapes/hy4 into writable components_dir. + if hy4_exe is None: + hy4_exe, is_shape_component, lib_dirs = find_hy4_engine(root, components_dir, app_base) + if hy4_exe is None: + raise FileNotFoundError( + f'strata-hy4 engine binary not found under {components_dir}, {app_base}, or {root}') + + cfg_candidates = [ + generated, + root / 'strata-hy4-flash-sq-96.json', + *sorted(install_dir.glob('strata-*.json'), key=lambda p: p.stat().st_mtime, reverse=True), + ] + cfg_file = next((p for p in cfg_candidates if p.is_file()), None) + if cfg_file is not None: + cfg = json.loads(cfg_file.read_text(encoding='utf-8-sig')) + else: + ctx_val = setup_flags[setup_flags.index('--context') + 1] if '--context' in setup_flags else '131072' + cfg = { + 'exe': 'component:strata-hy4' if is_shape_component else str(hy4_exe), + 'args': [ + '--native', str(linked['Hy4-Flash-SQ-96.strata']), + '--engram', str(linked['Hy4-Flash-Engram-Q8.strata']), + '--max-context', str(ctx_val), + '--vision', str(linked['Hy4-Flash-Vision.strata']), + ], + 'cwd': str(root), + 'tokenizer': str(data / 'packs' / 'hy4-flash-sq-96' / 'tokenizer'), + 'model_name': 'hy4-flash-sq-96', + 'arch': 'hy4flash', + 'port': int(port), + 'drafting': 'dfly2', + } + + # Ensure tokenizer exists (covers flat engine layout when Python lacks zstd). + tok_dir = Path(cfg.get('tokenizer') or (data / 'packs' / 'hy4-flash-sq-96' / 'tokenizer')) + if (Path(root) / 'tools' / 'hy4_tokenizer.py').is_file(): + ensure_tokenizer(root, linked['Hy4-Flash-SQ-96.strata'], tok_dir, hy4_exe, lib_dirs) + cfg['tokenizer'] = str(tok_dir) + + # Bind executable & library search paths cleanly for both layouts. + if is_shape_component: + cfg['exe'] = 'component:strata-hy4' + else: + cfg['exe'] = str(hy4_exe) + if lib_dirs: + cfg['lib_dirs'] = lib_dirs + + cfg['arch'] = 'hy4flash' + cfg['args'] = merge_hy4_args(cfg.get('args') or [], hy4_overrides) + if hy4_overrides: + cfg['user_args'] = list(hy4_overrides) + cfg['drafting'] = draft_override if draft_override is not None else (cfg.get('drafting') or 'dfly2') + publish_model_name(cfg, env=env) + cfg['log'] = str(data / 'engine.log') + cfg['open_browser'] = False + cfg['allowed_hosts'] = ['*'] + cfg.pop('api_key', None) # internal ClusterIP only; Olares authenticates the entrance. + + threads = tune_cpu_threads_for_cgroup(env=env) + cfg_env = dict(cfg.get('env') or {}) + cfg_env.setdefault('STRATA_CPUEXP_COLLAPSE', env.get('STRATA_CPUEXP_COLLAPSE', '1')) + cfg_env.setdefault('STRATA_CPUEXP_COLD_IO', env.get('STRATA_CPUEXP_COLD_IO', 'direct')) + cfg_env['HY4_CPU_THREADS'] = threads + cfg_env['OMP_NUM_THREADS'] = threads + cfg['env'] = cfg_env + + target = data / 'server.json' + temporary = target.with_suffix('.tmp') + temporary.write_text(json.dumps(cfg, indent=2), encoding='utf-8') + temporary.replace(target) + + os.environ['STRATA_COMPONENTS_DIR'] = str(components_dir) + os.environ['HY4_CPU_THREADS'] = threads + os.environ['OMP_NUM_THREADS'] = threads + + exec_argv = [ + sys.executable, str(root / 'serve' / 'server.py'), + '--engine', 'strata', '--config', str(target), + '--host', '0.0.0.0', '--port', port, + ] + return root, target, port, exec_argv + + + def main(): + root, _target, _port, exec_argv = prepare_server_config() + os.chdir(root) + os.execv(sys.executable, exec_argv) + + + if __name__ == '__main__': + main() + strata-healthcheck.sh: | + #!/bin/sh + set -eu + for cand in \ + "${STRATA_PYTHON:-}" \ + /opt/strata/.venv/bin/python \ + /opt/strata/.venv/bin/python3 \ + /opt/strata/terminal/python/bin/python3 \ + /opt/strata/python/bin/python3 \ + "$(command -v python3 2>/dev/null || true)"; do + if [ -n "$cand" ] && [ -f "$cand" ]; then + exec "$cand" /llm-init/wrappers/strata-healthcheck.py + fi + done + exit 1 + strata-healthcheck.py: | + #!/usr/bin/env python3 + import json + import os + import sys + import urllib.request + + + def healthy(state): + return isinstance(state, dict) and state.get('status') == 'ok' and state.get('loaded') is True + + + def main(): + opener = urllib.request.build_opener(urllib.request.ProxyHandler({})) + try: + with opener.open('http://127.0.0.1:' + os.environ.get('STRATA_PORT', '8080') + '/health', timeout=3) as response: + return 0 if healthy(json.load(response)) else 1 + except (OSError, ValueError): + return 1 + + + if __name__ == '__main__': + sys.exit(main()) diff --git a/stratahy4flashsq96/values.yaml b/stratahy4flashsq96/values.yaml new file mode 100644 index 000000000..a24dfed7c --- /dev/null +++ b/stratahy4flashsq96/values.yaml @@ -0,0 +1,13 @@ +# Default image points to Strata's official GHCR CUDA 13 image (bundling strata-hy4 0.1.64 sm_75..sm_120); +# Beclab's promotion bot mirrors upstream images to docker.io/beclab/* automatically, and templates/wrappers.yaml +# supports both upstream /opt/strata/components and Beclab /opt/strata/.venv layouts seamlessly. +images: + strata: ghcr.io/niko1221/strata:0.2.18-cuda13 + llmInit: docker.io/beclab/llm-init:v1.7.26 +workloads: + llminit: + replicaCount: 1 + stratahy4flashsq96: + replicaCount: 1 +strata: + cpuThreads: 16