Downloads · 30 days
0
cstr/Kokoro-82M-encoder-hailo10h
Kokoro-82M-encoder-hailo10h is a feature extraction model from cstr. Use it when you need embeddings to search or compare text. It is set up for hailo. The card lists the license as apache-2.0.
⚠️ Experimental / early-stage research artifact. This HEF is the ALBERT phoneme encoder subgraph of hexgrad/Kokoro-82M (StyleTTS2-based TTS), compiled for the Hailo-10H accelerator. Reproducibility is the headline; pr…
Downloads · 30 days
0
Access
Public
Updated Aug 2, 2026
Repo size
117 MB
Likes
0
Public
Click a slice to open those files.
.hef69 MB · 59%
From the Hugging Face model README
⚠️ Experimental / early-stage research artifact. This HEF is the ALBERT phoneme encoder subgraph of
hexgrad/Kokoro-82M(StyleTTS2-based TTS), compiled for the Hailo-10H accelerator. Reproducibility is the headline; production audio quality is not evaluated yet — only the encoder block's INT8 numerical fidelity. See "Known limits" below.
This repo contains a HEF for the ALBERT phoneme encoder subgraph of Kokoro-82M on Hailo-10H (target architecture mercury) using DFC 5.3.0.
| HEF | kokoro-albert-encoder.hef (65.83 MiB) |
| Target | Hailo-10H (hailo10h / mercury) |
| DFC | 5.3.0 |
| Source model | hexgrad/Kokoro-82M (Apache-2.0, 82M total params; this HEF covers the ~67M phoneme-encoder subgraph) |
| Source ONNX | onnx-community/Kokoro-82M-v1.0-ONNX model.onnx (fp32, 311 MiB) |
| Subgraph cut | start_node=/encoder/bert/embeddings/LayerNorm/LayerNormalization_output_0, end_node=/encoder/bert_encoder/MatMul_output_0 — i.e. the embedding-hidden-mapping projection + 12-layer ALBERT transformer + the final encoder MatMul (which projects 768 → 512 for the duration predictor). |
| Sequence length | 128 phoneme tokens (static) |
| Input | [1, 128, 128] NWC — output of CPU-side embedding + LayerNorm (FP32) |
| Output | [1, 128, 512] NWC — encoder MatMul output, feeds the duration predictor downstream |
| Quantization | INT8 (with ew_add* raised to a16_w16; ALBERT-specific Pow(x, 3.0) rewritten to Mul(Mul(x,x), x)) |
| Cosine vs FP32 | ~0.72 mean cosine on emulator (SDK_QUANTIZED vs SDK_FP_OPTIMIZED) over 16 random-Gaussian inputs |
| Compile wall | 2 h 25 min on Kaggle CPU (30 GB RAM session, after 10 iterations of Kaggle-side debugging) |
multiproc_policy=disabled) plus two ALBERT-specific ONNX surgeries:
Pow(x, 3.0) → Mul(Mul(x,x), x) — ALBERT's tanh-approximation GELU contains a cubic that DFC's Pow op refuses (only Pow with even integer exponent ≤ 2 is supported).extract_model — Kokoro's ONNX has Shape(input_ids) nodes whose values flow through Concat/Reshape deeper in the graph; without folding them, onnx.utils.extract_model refuses to extract the encoder subgraph.crisphailo-kokoro-compile.py because no labelled phoneme corpus was wired into the bringup path). A real-phoneme calibration set might shift the cosine number — could be either direction.optimization_level=2 / compression_level=4 (the levels that fit in 30 GB RAM during bringup). optimization_level=4 (full QAT) was not attempted due to RAM/time budget.cstr/all-MiniLM-L6-v2-hailo10h) and this Kokoro ALBERT-base (66.89M, no-mask). The plateau is independent of model size, mask presence, or BERT vs ALBERT family — it's the noise floor of (matmul_correction zp_comp_block + ew_add a16_w16 + neg_exp rank=1) on Hailo-10H.[-8.22, +7.55], INT8 emulator range [-7.40, +7.46]. Mild clipping in the tails. MSE 0.93 on a value-range ~16 ≈ 6% relative.--seq).[B, T, 512] tensor, not [B, T, 768].Prereqs:
hailo_platform, plus the upstream Kokoro pipeline (you need the CPU embedding + LayerNorm + duration predictor + decoder — this HEF is the encoder block only)misaki for English, espeak-ng under the hood)End-to-end inference is not turn-key yet. The integration would look like:
# 1. Text -> phonemes (CPU, misaki/espeak)
from misaki.en import G2P
g2p = G2P()
phonemes, _ = g2p("Hello world.")
ids = tokenize_to_kokoro_ids(phonemes, max_length=128) # [1, 128] int64
# 2. CPU embedding + LayerNorm in FP32
import onnxruntime as ort
pre = ort.InferenceSession("kokoro-pre.onnx") # extracted subgraph
layernorm_out = pre.run(["/encoder/bert/embeddings/LayerNorm/LayerNormalization_output_0"],
{"input_ids": ids})[0] # [1, 128, 128] float32
# 3. Encoder on Hailo-10H
from hailo_platform import HEF, VDevice, ConfigureParams, ...
hef = HEF("kokoro-albert-encoder.hef")
# ... configure, infer with layernorm_out reshaped to [1, 1, 128, 128] NHWC ...
encoder_out = run_hef(hef, layernorm_out) # [1, 128, 512] float32
# 4. CPU duration predictor + iSTFTNet decoder (FP32) -> waveform
post = ort.InferenceSession("kokoro-post.onnx")
audio = post.run(..., feeds_with(encoder_out, style, speed))[0]
The "kokoro-pre" and "kokoro-post" subgraphs are NOT included here — extracting them is left to the integrator. The starting point is model.onnx from onnx-community/Kokoro-82M-v1.0-ONNX and the cut nodes documented above.
This compile is RAM-heavy (~14 GB peak) and slow (~2.5 h on Kaggle CPU). The bundled Kaggle kernel script handles the full pipeline end-to-end.
# Option A — Kaggle (recommended for low-RAM environments)
# Mirror the kernel chr1str/crisphailo-kokoro-phoneme-encoder-compile from
# recipe/crisphailo-kokoro-compile.py. The kernel handles:
# - apt: python3.10-venv, libgraphviz-dev, ...
# - DFC venv (Python 3.10 is required for the wheel ABI)
# - Clone CrispHailo (private repo OK — uses GH_TOKEN from a Kaggle dataset)
# - Download Kokoro ONNX from HF
# - Run make_kokoro_encoder_only.py + replace_pow3_with_mul.py
# - Run compile_moonshine_ruvector.py (which is the generic ALBERT/BERT compile)
# Inputs to attach: chr1str/hailo-dfc-wheel-530, chr1str/crispasr-hf-token
# Wall: ~2.5 h, output: hefs/kokoro-albert-encoder.hef + .har
# Option B — local Linux box (need >= 16 GB RAM)
python3.10 -m venv dfcvenv
. dfcvenv/bin/activate
pip install hailo_dataflow_compiler-5.3.0-py3-none-linux_x86_64.whl
pip install numpy onnx onnxruntime onnxsim huggingface_hub
# 1. Download upstream Kokoro ONNX (fp32, 311 MiB)
python -c "from huggingface_hub import hf_hub_download; \
hf_hub_download('onnx-community/Kokoro-82M-v1.0-ONNX', 'onnx/model.onnx', \
local_dir='work/kokoro')"
# 2. Extract encoder subgraph (shape-fix + onnxsim + extract_model)
python recipe/make_kokoro_encoder_only.py \
--in work/kokoro/onnx/model.onnx \
--out work/kokoro/kokoro_albert_encoder_seq128.onnx \
--seq 128
# 3. Rewrite Pow(x, 3.0) -> Mul (ALBERT tanh-approximation GELU)
python recipe/replace_pow3_with_mul.py \
--in work/kokoro/kokoro_albert_encoder_seq128.onnx \
--out work/kokoro/kokoro_albert_encoder_nopow3.onnx
# 4. Compile (no real calib — uses random-normal, as in production bringup)
python recipe/compile_moonshine_ruvector.py \
--onnx work/kokoro/kokoro_albert_encoder_nopow3.onnx \
--input-node "/encoder/bert/embeddings/LayerNorm/LayerNormalization_output_0" \
--seq-len 128 --channels 128 --input-layout NWC \
--hef-out kokoro-albert-encoder.hef \
--har-out kokoro-albert-encoder.har \
--model-name kokoro_albert
For the cosine fidelity check at the end, use recipe/eval-kokoro.py (a Kaggle kernel script that runs SDK_FP_OPTIMIZED vs SDK_QUANTIZED and emits the JSON shipped here as kokoro-eval_results.json). Wall: ~15 min on Kaggle CPU.
kokoro-eval_results.json summary:
{
"input_shape": [-1, 1, 128, 128],
"output_shape": [16, 1, 128, 512],
"n_samples": 16,
"cos_mean": 0.72425,
"cos_min": 0.54747,
"cos_max": 0.80045,
"mse_mean": 0.93454,
"fp_range": [-8.224, +7.549],
"q_range": [-7.398, +7.456]
}
Method: 16 random-Gaussian inputs N(0,1) shaped [1, 1, 128, 128] fed to both the SDK_FP_OPTIMIZED and SDK_QUANTIZED emulator contexts on the same HAR, per-sample cosine + MSE computed on the flattened [N, 1, 128, 512] outputs.
kokoro-albert-encoder.hef ← compiled HEF (65.83 MiB)
kokoro-eval_results.json ← FP32 vs INT8 emulator cosine (16 samples)
source/
kokoro_albert_encoder_seq128.onnx ← post-extract ONNX (23.11 MiB)
kokoro_albert_encoder_nopow3.onnx ← post-Pow3-surgery ONNX (23.12 MiB; the DFC input)
recipe/
make_kokoro_encoder_only.py ← shape-fix + onnxsim + extract_model
replace_pow3_with_mul.py ← universal Pow(x,3) → Mul rewrite
compile_moonshine_ruvector.py ← generic ALBERT/BERT compile driver
crisphailo-kokoro-compile.py ← Kaggle bootstrap kernel (end-to-end)
eval-kokoro.py ← Kaggle eval kernel (FP32 vs INT8)
hexgrad/Kokoro-82M — Apache-2.0. StyleTTS2 architecture, by hexgrad. ONNX export by onnx-community.compile-encoder-hef.py (MIT, Copyright (c) 2025 rUv) for the Keras-serializable monkey-patch + multiproc_policy=disabled pattern. ALBERT-specific extensions (Pow(x,3) rewrite, shape-fix + onnxsim for cut extraction) are original to this work.cstr/all-MiniLM-L6-v2-hailo10h — sister HEF for sentence-transformers/all-MiniLM-L6-v2, same recipe family, same cosine plateau.@misc{kokoro-encoder-hailo10h,
title = {Kokoro-82M phoneme encoder Hailo-10H HEF (experimental)},
author = {CrispHailo project},
year = {2026},
howpublished = {\url{https://huggingface.co/cstr/Kokoro-82M-encoder-hailo10h}}
}
Bringup log dates: research session 4, Kaggle compile completed 2026-05-27, eval completed 2026-05-29. Compile wall: 2 h 25 min on Kaggle CPU at optimization_level=2 / compression_level=4. Emulator eval wall: 80 min total (DFC venv setup + 16-sample INT8 eval at 834 s; SDK_QUANTIZED is ~22× slower than SDK_FP_OPTIMIZED on the 12-layer ALBERT graph).
hexgrad.apache-2.0. This repository redistributes under the same terms; it grants no rights the upstream licence does not.