← Back to Blog
SpacemiT K1

SpacemiT K1 Runs ONNX Runtime int4 LLM via IME Matrix Extension

Overview

SpacemiT's K1 SoC — the 8-core X60 RISC-V chip at 1.6 GHz with 2 TOPS AI acceleration — has achieved a notable milestone: running ONNX Runtime with int4-quantized LLM inference using the X60 core's IME (Integrated Matrix Extension). Community benchmarks show approximately 80 ms per token for Qwen2.5-0.5B in int4 format, a result that places RISC-V firmly in the conversation for on-device generative AI at the edge.

This isn't a vendor demo. It's a community-validated port of Microsoft's ONNX Runtime, leveraging a RISC-V matrix extension that is currently under active standardization at RISC-V International. The work was shared on the SpacemiT community forum and represents one of the first public demonstrations of int4 LLM inference on a production RISC-V SoC.

Key takeaway: The K1's IME matrix extension enables efficient int4/int8 MatMulNBits operations in ONNX Runtime, delivering ~80ms/token for a 0.5B parameter model without requiring a dedicated NPU — using only the CPU's vector-matrix units.

What is the IME Matrix Extension?

RISC-V's approach to AI acceleration is intentionally modular. Rather than bolting on a fixed-function NPU, the architecture defines several competing matrix extension proposals that reuse the existing vector register file. The four main contenders, as surveyed by the CCF TF RISC-V SIG, are:

ExtensionApproachBest For
BDPStateless batch dot-productUltra-low-power sensor inference
IMEIntegrated matrix, reuses vector registersEdge SoCs with existing vector units
VMEVector-matrix with dedicated accumulatorsMid-range AI acceleration
AMEDiscrete matrix engineDatacenter / HPC training

The IME (Integrated Matrix Extension) is particularly well-suited to the SpacemiT X60 core because it builds directly on the RVV 1.0 vector extension already present in the K1. Instead of adding new register files or memory interfaces, IME treats matrix operations as structured sequences of vector instructions — matrix multiply becomes a series of vector dot-products with explicit accumulator management.

This design choice has two practical benefits for the K1:

  • No silicon overhead: IME reuses the existing 256-bit vector ALU and register file. No extra area, no extra power domain.
  • Compiler-friendly: Because IME is expressed in terms of vector instructions, existing RVV compiler infrastructure (LLVM, GCC) can target it with incremental changes rather than a wholly new backend.

ONNX Runtime on K1

Microsoft's ONNX Runtime is the de facto standard for cross-platform ML inference. The SpacemiT community port focuses on the CPU execution provider with RVV + IME acceleration for the critical path: matrix multiplication in quantized linear layers.

The porting work involved several layers:

  1. RVV 1.0 intrinsics: Vectorized kernels for element-wise ops, layer normalization, and attention softmax.
  2. IME MatMul kernel: A custom kernel for MatMulNBits (the ONNX operator for quantized matrix multiply with N-bit weights) that dispatches to IME instructions when available.
  3. int4 weight dequantization: On-the-fly unpacking of 4-bit weights to 8-bit activations during the matrix multiply, avoiding full dequantization memory overhead.
  4. Threading: Parallelization across the K1's 8 X60 cores using ONNX Runtime's built-in thread pool.
# Build ONNX Runtime for K1 with RVV+IME
git clone https://github.com/microsoft/onnxruntime.git
cd onnxruntime
# Apply SpacemiT K1 patch set (community maintained)
git apply patches/spacemit-k1-rvv-ime-v2.patch

# Build with RVV+IME flags
./build.sh \
  --config Release \
  --build_shared_lib \
  --parallel \
  --cmake_extra_defines \
  CMAKE_C_FLAGS="-march=rv64gcv_zve64x_zvl256b -DSPACEMIT_IME" \
  CMAKE_CXX_FLAGS="-march=rv64gcv_zve64x_zvl256b -DSPACEMIT_IME"

int4 Quantization & MatMulNBits

int4 quantization compresses model weights to 4 bits per parameter (16 values per byte), reducing memory bandwidth by 8x compared to fp32 and 2x compared to int8. For a 0.5B parameter model, this means:

FormatModel SizeMemory Bandwidth per Token
fp322.0 GB~2 GB/s at 10 tok/s
int80.5 GB~0.5 GB/s at 10 tok/s
int40.25 GB~0.25 GB/s at 10 tok/s

The K1's memory subsystem (LPDDR4X at ~34 GB/s) is not bandwidth-starved for a 0.5B model, but int4 still helps significantly with cache efficiency and power consumption. The real win is computational: MatMulNBits with int4 weights and int8 activations maps cleanly to the IME's dot-product-with-accumulate pattern.

Note: int4 quantization requires careful calibration. The community benchmark used block-wise quantization (128-weight blocks with separate per-block scales) to minimize accuracy loss. Expect ~1-2% perplexity degradation versus fp16 for a 0.5B model — acceptable for most edge applications.

Performance Numbers

Community-reported benchmarks on the SpacemiT K1-8B (8GB RAM) dev board:

ModelQuantizationSequence LengthLatency / TokenThroughput
Qwen2.5-0.5Bint4 (block 128)512~80 ms~12.5 tok/s
Qwen2.5-0.5Bint8512~110 ms~9.1 tok/s
Qwen2.5-1.5Bint4512~210 ms~4.8 tok/s
Qwen2.5-0.5Bfp16 (CPU)512~450 ms~2.2 tok/s

The int4 result is approximately 5.6x faster than fp16 on the same CPU, with the speedup coming from two sources: reduced memory bandwidth (8x weight compression) and IME-accelerated MatMulNBits kernels (2-3x compute speedup over scalar RV64GC).

For context, 12.5 tok/s for a 0.5B model is in the same ballpark as:

  • Raspberry Pi 5 (ARM Cortex-A76) running the same model via llama.cpp Q4_0: ~10-14 tok/s
  • Apple M1 (ARM NEON) with Core ML int4: ~15-20 tok/s
  • Qualcomm QCS6490 (Hexagon DSP) int4: ~20-30 tok/s

The K1 is not winning on absolute performance, but it is competitive — and doing so with an open ISA, mainline Linux, and no proprietary SDK requirements.

What This Means for Edge AI

This benchmark matters for three reasons beyond the raw numbers:

1. RISC-V is now a viable target for edge LLM deployment. Before this work, running quantized LLMs on RISC-V meant falling back to scalar C++ reference implementations in ONNX Runtime or llama.cpp — usable for prototyping, too slow for products. The IME-accelerated path changes the calculus.

2. The matrix extension standardization is gaining real-world validation. IME is one of four competing proposals. Having a production SoC (K1) with working silicon, a community port, and public benchmarks gives the RISC-V Matrix SIG concrete data to evaluate against VME, AME, and BDP.

3. It validates the K1's positioning as an edge-AI gateway SoC. The K1 was designed for routers, industrial gateways, and edge boxes — not AI accelerators. That it can run a 0.5B LLM at interactive speeds (12+ tok/s) using only its CPU vector units means developers can add lightweight AI features (local intent parsing, small-model agents, offline summarization) without adding a separate NPU or switching to a different chip.

Bottom line: The SpacemiT K1 + ONNX Runtime + IME combination proves that RISC-V edge SoCs can run modern quantized LLMs at practical speeds. For developers building AI-enabled gateways, industrial controllers, or smart appliances, this removes a key barrier to choosing RISC-V over ARM.

Last updated: 2026-09-04. Benchmarks are community-reported and may vary with software versions. For the latest K1 AI SDK and ONNX Runtime patches, visit the SpacemiT community forum.

概述

SpacemiT K1 SoC —— 8核 X60 RISC-V 芯片,主频 1.6 GHz,带 2 TOPS AI 加速 —— 最近取得了一项重要进展:通过 X60 核心的 IME(Integrated Matrix Extension,集成矩阵扩展),实现了 ONNX Runtime 搭载 int4 量化 LLM 推理。社区测试显示,Qwen2.5-0.5B 的 int4 格式达到约 80 毫秒/token,这一结果让 RISC-V 在边缘生成式 AI 领域占据了一席之地。

这不是厂商演示,而是社区验证的 ONNX Runtime 移植。工作在 SpacemiT 社区论坛上分享,代表了生产级 RISC-V SoC 上 int4 LLM 推理的首批公开演示之一。

核心要点:K1 的 IME 矩阵扩展使 ONNX Runtime 中的 int4/int8 MatMulNBits 操作高效运行,对于 0.5B 参数模型达到约 80ms/token,且不需要专用 NPU,仅使用 CPU 的矩阵向量单元。

什么是 IME 矩阵扩展?

RISC-V 对 AI 加速的方法故意设计为模块化。不是挪上一个固定功能的 NPU,而是定义了多个竞争的矩阵扩展方案,复用现有的向量寄存器。CCF TF RISC-V SIG 的调查显示,主要有四种方案:

扩展方法最适合
BDP无状态批量点积超低功耗传感器推理
IME集成矩阵,复用向量寄存器带现有向量单元的边缘 SoC
VME向量矩阵,带专用累加器中端 AI 加速
AME离散矩阵引擎数据中心 / HPC 训练

IME(Integrated Matrix Extension) 特别适合 SpacemiT X60 核心,因为它直接在 K1 已有的 RVV 1.0 向量扩展上构建。IME 不添加新的寄存器文件或内存接口,而是将矩阵运算表示为向量指令的结构化序列。

这种设计对 K1 有两个实际好处:

  • 无额外硅面面积:IME 复用现有的 256 位向量 ALU 和寄存器文件。没有额外面积,没有额外功耗域。
  • 编译器友好:由于 IME 以向量指令表示,现有的 RVV 编译器基础设施(LLVM、GCC)可以通过渐进式修改而不是全新后端来针对它。

K1 上的 ONNX Runtime

微软的 ONNX Runtime 是跨平台 ML 推理的事实标准。SpacemiT 社区移植版本专注于 CPU 执行提供者,并针对关键路径(量化线性层中的矩阵乘法)进行 RVV + IME 加速。

移植工作涉及多个层次:

  1. RVV 1.0 内联函数:用于逐元素运算、层归一化和 attention softmax 的向量化内核。
  2. IME MatMul 内核:用于 MatMulNBits(ONNX 中量化矩阵乘法的运算符)的自定义内核,在可用时调度到 IME 指令。
  3. int4 权重反量化:在矩阵乘法过程中将 4 位权重即时解包为 8 位激活,避免全量化的内存开销。
  4. 多线程:使用 ONNX Runtime 内置线程池在 K1 的 8 个 X60 核心上并行化。

int4 量化与 MatMulNBits

int4 量化将模型权重压缩到每参数 4 位(每字节 16 个值),相比 fp32 减少 8 倍内存带宽,相比 int8 减少 2 倍。对于 0.5B 参数模型:

格式模型大小每 Token 内存带宽
fp322.0 GB约 2 GB/s @ 10 tok/s
int80.5 GB约 0.5 GB/s @ 10 tok/s
int40.25 GB约 0.25 GB/s @ 10 tok/s

K1 的内存子系统(LPDDR4X,约 34 GB/s)对于 0.5B 模型并不是带宽瓶颈,但 int4 仍然显著提升了缓存效率和降低了功耗。真正的收益是计算:带 int4 权重和 int8 激活的 MatMulNBits 清晰地映射到 IME 的点积累加模式。

注意:int4 量化需要仔细的校准。社区测试使用了块量化(128 权重块,带独立的每块缩放比例)以最小化精度损失。对于 0.5B 模型,预期相对于 fp16 有约 1-2% 的困惑度下降 —— 对大多数边缘应用来说可以接受。

性能数据

SpacemiT K1-8B(8GB RAM)开发板上的社区报告测试:

模型量化序列长度延迟/Token吞吐量
Qwen2.5-0.5Bint4 (block 128)512约 80 ms约 12.5 tok/s
Qwen2.5-0.5Bint8512约 110 ms约 9.1 tok/s
Qwen2.5-1.5Bint4512约 210 ms约 4.8 tok/s
Qwen2.5-0.5Bfp16 (CPU)512约 450 ms约 2.2 tok/s

int4 结果比同一 CPU 上的 fp16 快约 5.6 倍,速度提升来自两个方面:减少的内存带宽(8 倍权重压缩)和 IME 加速的 MatMulNBits 内核(相比标量 RV64GC 有 2-3 倍计算加速)。

作为对比,0.5B 模型达到 12.5 tok/s 与以下平台处于同一数量级:

  • 树莓派 5 (ARM Cortex-A76) 通过 llama.cpp Q4_0 运行同样模型:约 10-14 tok/s
  • 苹果 M1 (ARM NEON) 带 Core ML int4:约 15-20 tok/s
  • 高通 QCS6490 (Hexagon DSP) int4:约 20-30 tok/s

K1 在绝对性能上并非领先,但是 有竞争力 —— 而且做到这一点的同时,使用的是开放 ISA、主线 Linux,且没有专有 SDK 要求。

对边缘 AI 的意义

这项测试超出原始数字的三个原因:

1. RISC-V 现在是边缘 LLM 部署的可行目标。在此之前,在 RISC-V 上运行量化 LLM 意味着回退到 ONNX Runtime 或 llama.cpp 中的标量 C++ 参考实现 —— 可用于原型设计,但对产品来说太慢。IME 加速路径改变了这个计算。

2. 矩阵扩展标准化获得了真实世界的验证。IME 是四个竞争方案之一。拥有带工作硅片(K1)、社区移植和公开测试结果的生产 SoC 为 RISC-V Matrix SIG 提供了相对于 VME、AME 和 BDP 的具体评估数据。

3. 验证了 K1 作为边缘 AI 网关 SoC 的定位。K1 的设计目标是路由器、工业网关和边缘盒子 —— 而不是 AI 加速器。它能够仅使用 CPU 向量单元以交互速度(12+ tok/s)运行 0.5B LLM,意味着开发者可以添加轻量级 AI 功能(本地意图解析、小模型智能体、离线摘要)而不需要添加单独的 NPU 或切换到不同的芯片。

结论:SpacemiT K1 + ONNX Runtime + IME 组合证明,RISC-V 边缘 SoC 可以以实用速度运行现代量化 LLM。对于构建 AI 网关、工业控制器或智能家电的开发者来说,这消除了选择 RISC-V 而非 ARM 的一个关键障碍。

最后更新:2026-09-04。测试结果为社区报告,可能因软件版本而异。获取最新 K1 AI SDK 和 ONNX Runtime 补丁,请访问 SpacemiT 社区论坛

Обзор

SoC SpacemiT K1 — 8-ядерный чип X60 RISC-V с частотой 1,6 ГГц и 2 TOPS AI-ускорением — достиг значимого рубежа: запуск ONNX Runtime с int4-квантованным LLM-выводом с использованием IME (Integrated Matrix Extension) ядра X60. Тесты сообщества показывают примерно 80 мс на токен для Qwen2.5-0.5B в формате int4 — результат, который прочно вводит RISC-V в число конкурентов для генеративного AI на краю.

Ключевой вывод: Расширение IME в K1 позволяет эффективно выполнять операции MatMulNBits int4/int8 в ONNX Runtime, достигая ~80 мс/токен для модели 0,5B параметров без выделенного NPU.

Что такое расширение IME?

RISC-V использует модульный подход к AI-ускорению. Вместо фиксированного NPU архитектура определяет несколько конкурирующих предложений матричных расширений, которые переиспользуют существующий векторный регистровый файл. IME (Integrated Matrix Extension) особенно хорошо подходит для ядра X60, потому что оно строится напрямую на расширении RVV 1.0, уже присутствующем в K1.

ONNX Runtime на K1

Порт ONNX Runtime от сообщества SpacemiT фокусируется на CPU-провайдере с ускорением RVV + IME для критического пути: матричного умножения в квантованных линейных слоях.

Квантование int4 и MatMulNBits

Квантование int4 сжимает веса модели до 4 бит на параметр, уменьшая память в 8 раз по сравнению с fp32. Для модели 0,5B параметров это 0,25 ГБ вместо 2 ГБ.

Производительность

МодельКвантованиеДлина последовательностиЗадержка/токенПропускная способность
Qwen2.5-0.5Bint4 (block 128)512~80 мс~12,5 ток/с
Qwen2.5-0.5Bint8512~110 мс~9,1 ток/с
Qwen2.5-0.5Bfp16 (CPU)512~450 мс~2,2 ток/с

Результат int4 примерно в 5,6 раз быстрее fp16 на том же CPU. Это сопоставимо с Raspberry Pi 5 (~10-14 ток/с) и Apple M1 (~15-20 ток/с).

Что это значит для Edge AI

Этот бенчмарк важен по трём причинам:

  1. RISC-V теперь жизнеспособная платформа для краевых LLM.
  2. Стандартизация матричных расширений получает реальную валидацию.
  3. Подтверждается позиционирование K1 как edge-AI SoC.

Итог: Комбинация SpacemiT K1 + ONNX Runtime + IME доказывает, что RISC-V edge SoC могут запускать современные квантованные LLM на практических скоростях.

Обновлено: 2026-09-04. Бенчмарки от сообщества и могут отличаться в зависимости от версий ПО.

Resumen

El SoC SpacemiT K1 — chip RISC-V X60 de 8 núcleos a 1,6 GHz con aceleración AI de 2 TOPS — ha logrado un hito notable: ejecutar ONNX Runtime con inferencia LLM cuantizada en int4 utilizando la extensión IME (Integrated Matrix Extension) del núcleo X60. Los benchmarks de la comunidad muestran aproximadamente 80 ms por token para Qwen2.5-0.5B en formato int4.

Punto clave: La extensión IME en K1 permite operaciones MatMulNBits int4/int8 eficientes en ONNX Runtime, alcanzando ~80 ms/token para un modelo de 0,5B parámetros sin necesidad de NPU dedicado.

¿Qué es la Extensión de Matriz IME?

El enfoque de RISC-V para aceleración AI es intencionalmente modular. En lugar de añadir un NPU de función fija, la arquitectura define varias propuestas de extensión de matriz que reutilizan el archivo de registros vectorial existente. IME (Integrated Matrix Extension) es particularmente adecuado para el núcleo X60 porque se construye directamente sobre la extensión vectorial RVV 1.0 ya presente en el K1.

ONNX Runtime en K1

El port de la comunidad SpacemiT se enfoca en el proveedor de ejecución CPU con aceleración RVV + IME para la ruta crítica: multiplicación de matrices en capas lineales cuantizadas.

Cuantización int4 y MatMulNBits

La cuantización int4 comprime los pesos del modelo a 4 bits por parámetro, reduciendo el ancho de banda de memoria 8x en comparación con fp32. Para un modelo de 0,5B parámetros, esto significa 0,25 GB en lugar de 2,0 GB.

Rendimiento

ModeloCuantizaciónLongitud de secuenciaLatencia/TokenRendimiento
Qwen2.5-0,5Bint4 (bloque 128)512~80 ms~12,5 tok/s
Qwen2.5-0,5Bint8512~110 ms~9,1 tok/s
Qwen2.5-0,5Bfp16 (CPU)512~450 ms~2,2 tok/s

El resultado int4 es aproximadamente 5,6x más rápido que fp16 en la misma CPU. Para contexto, 12,5 tok/s está en el mismo rango que Raspberry Pi 5 (~10-14 tok/s) y Apple M1 (~15-20 tok/s).

Implicaciones para Edge AI

Este benchmark importa por tres razones:

  1. RISC-V es ahora un objetivo viable para despliegue de LLM en el edge.
  2. La estandarización de extensiones de matriz gana validación del mundo real.
  3. Valida el posicionamiento del K1 como SoC edge-AI gateway.

Conclusión: La combinación SpacemiT K1 + ONNX Runtime + IME demuestra que los SoC edge RISC-V pueden ejecutar LLMs cuantizados modernos a velocidades prácticas.

Actualizado: 2026-09-04. Los benchmarks son reportados por la comunidad y pueden variar según la versión del software.