Skip to content

QERLIO v0.3.0 — Native GGUF Inference Engine

Choose a tag to compare

@ZAQERIS ZAQERIS released this 22 Nov 21:58
fea4e7a

Correction Notice (Added with Release v0.3.1):

  • The v0.3.0 release was merged, tagged, and published prior to management review.
  • See Release v0.3.1 for the corrected and cleaned release.
  • Corrections to v0.3.0 notes:
    1. The registry count is corrected from 5 tested to 1 tested (seed_36b) / 183 experimental (184 total): qwen35 (prior 4-token run used an unofficial UD quant) and ZAQERIS catalog entries (zaqeris_axiom, zqn_12b, zaqeris_7b, lacking official >= 64-token runs) do not meet the tested criteria.
    2. Pytest suites tests/test_t4_to_t10_engine.py and tests/test_qwen35_engine.py execute deterministic synthetic toy fixtures, not real multi-billion-parameter weights.
    3. v0.3.0 lacked root LICENSE, pyproject.toml, and CODE_OF_CONDUCT.md and had uncleaned /v1/models stubs and broken relative doc links; resolved in v0.3.1.

QERLIO v0.3.0 — From-Scratch Native GGUF Inference Engine (seed_oss + qwen35)

What's New

  • From-Scratch GGUF v2/v3 Loader (core/inference/gguf_loader.py): Binary GGUF header/metadata/tensor parser, alignment handling, memory-mapped tensor access, row-level dequantized lookup (get_tensor_rows_f32), and corrupt/truncated file rejection.
  • 16 GGML Dequantization Kernels (core/inference/dequant.py): Native decoders for F32, F16, BF16, Q4_0, Q4_1, Q5_0, Q5_1, Q8_0, Q2_K, Q3_K, Q4_K, Q5_K, Q6_K, IQ4_NL, IQ3_S, and IQ4_XS verified within < 1e-6 absolute error.
  • Native Byte-Level BPE Tokenizer (core/inference/tokenizer.py): Reads vocabulary, merges, and special/control tokens directly from GGUF metadata with NFC normalization, seed-coder / qwen35 / gpt2 pre-tokenization, and exact encode/decode round-trip.
  • SeedOssForCausalLM & Qwen35ForCausalLM Native Engines (core/inference/seed_oss_model.py, core/inference/qwen35_model.py): From-scratch execution for Hermes 4.3 36B (seed_oss: RMSNorm, half-split RoPE, GQA with QKV biases, post_attention_norm, SwiGLU MLP, dynamic GGUF config) and hybrid Qwen3.5/Qwen3.8 (qwen35: Gated DeltaNet + Gated Full-Attention + Qwen35HybridCache), with KV cache, sampling, stop sequences, and cancellation.
  • From-Scratch C11 SIMD Quantized GEMM & Streaming (include/qerlio/native_gemm.h, core/inference/native_gemm.c, core/inference/native_gemm.py): AVX2+FMA+F16C kernels with portable scalar fallback for Q4_K, Q6_K, Q8_0, and F32, double-buffered sequential streaming (SequentialTensorStreamer), and batched SeedOssEngine.forward_batch().
  • Live Local API Gateway & CLI (server/local_api/server.py, tools/qerlio_cli.py): /v1/models/load, /v1/models/unload, /v1/chat/completions, /v1/messages, and qerlio hermes chat --model-path running the native engine with "simulated": false when a GGUF model is loaded.

Verified Results (NousResearch/Hermes-4.3-36B-GGUF)

Verified on the official models/hermes-4_3_36b-Q4_K_M.gguf checkpoint (21,762,145,216 bytes, SHA-256 17823599694fa3503ef54bf748d5078c6ce881f4d01616cafa255dc05d215a08):

  • T1–T3 (Loader / Dequant / Tokenizer): 27 KVs and 771 tensors matched tests/fixtures/hermes_4_3_36b_q4_k_m_metadata.json; 21 gguf-py 0.19.0 dequant cases matched (max_abs_err=0.00e+00); 64/64 tokenizer cases matched tokenizers 0.23.3 with exact round-trip.
  • T4 & T5 (Logits & 64-Token Greedy vs transformers 5.20.1): Batched prefill in 47.87s; top-1 matched on 5/5 prompts, top-5 overlap 5/5, max top-20 logit diff 2.10e-05, and 320/320 greedy tokens matched identically (2362.87s). Single-pass C GEMM latency on 'The capital of France is': 50.75s (vs 419.43s NumPy-only path).
  • T6 (KV Cache Parity): Cached vs uncached recomputation matched with max_abs_diff=7.58e-05 and identical top-1 token (1371).
  • T7–T9 (Chat, Thinking, Tools & Robustness): Two-turn chat ('The capital of France is Paris.', 'The Seine River flows through Paris.'), thinking=True closed </think> with answer 4 and keep_cots verification, model-generated <tool_call> mapped to OpenAI tool_calls and Anthropic tool_use, plus context-overflow, KV budget, stop-sequence, and cancellation guards (active_sessions=0).
  • T10 & Automated Suite: All 184 pytest tests pass (0 failed, 0 skipped), and C++20 builds (ubuntu, windows, macos) + AddressSanitizer/UndefinedBehaviorSanitizer (including core/inference/native_gemm.c and tests/cpp_safety_test.cpp) pass in GitHub Actions CI.

Runtime Dependencies

  • core/inference/: Python standard library + NumPy + optional from-scratch C11 shared library (native_gemm.c, C standard library only). Zero torch, transformers, tokenizers, gguf, llama_cpp, vllm, sglang, onnxruntime, or psutil runtime dependencies inside core/inference/.
  • Offline reference generators live strictly under tests/reference/.

Known Limitations

  • CPU execution only; CUDA/Metal/Vulkan GPU acceleration is not implemented.
  • qwen35 still runs on the NumPy path (610.40s recorded on Qwen3.8-27B-UD-Q4_K_M.gguf); vision encoders and MoE architectures are not implemented.
  • 36B CPU inference latency is non-interactive (2362.87s for the 320-token batched run; hours for the full thinking run); peak memory was not measured.
  • The thinking=True greedy verification output was completed in two deterministic segments from an exact saved 160-token prefix.

Reproduce

python -m pytest
python tools/qerlio_cli.py hermes download --quant Q4_K_M --output-dir models
python scripts/verify_hermes_36b_real.py --model-path models/hermes-4_3_36b-Q4_K_M.gguf --reference-fixture tests/fixtures/hermes_4_3_36b_transformers_reference.json