Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

10.3 KB
Raw Blame

Building and validating the GGUF frontend

Run commands from the repository root. Shorthand paths below are relative to src/frontends/gguf/.

Use the repository build prerequisites. GGUF defaults to enabled (ENABLE_OV_GGUF_FRONTEND=ON); C++ tests require ENABLE_TESTS=ON and a shared-library build. This Linux single-configuration example puts binaries and libraries in an explicit directory:

cmake -S . -B build-gguf -DCMAKE_BUILD_TYPE=Release \
  -DENABLE_OV_GGUF_FRONTEND=ON -DENABLE_TESTS=ON -DBUILD_SHARED_LIBS=ON \
  -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
  -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="$PWD/build-gguf/bin" \
  -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$PWD/build-gguf/bin"
cmake --build build-gguf --target ov_gguf_frontend_tests ov_gguf_architecture_library_tests --parallel
./build-gguf/bin/ov_gguf_frontend_tests
./build-gguf/bin/ov_gguf_architecture_library_tests

For an existing build, use its configured output directory. OpenVINO normally writes under the source tree's bin/<architecture>/<configuration>, not necessarily under the CMake build tree. Multi-configuration generators can add a configuration subdirectory.

Select coverage

Change Coverage
Converter or op_case Relevant GGUFOps tests, then the full frontend binary for the operation-coverage gate
Architecture/shared decoder blocks GGUFArchConversion, GGUFArchitectureAccuracy, relevant adaptation/state tests
mmproj GGUFMMProj, GGUFMMProjAccuracy, GGUFMMProjDynamicAccuracy; relevant real-checkpoint tests
Extension API or packaging Builder/extension tests plus the separate architecture-library binary and actual shipped plugin
Weight conversion Weight/dequantization tests and checkpoint comparisons with recorded precision settings
GGUF parsing or shard discovery GGUFParser, GGUFShards, then the full frontend binary

Use --gtest_list_tests for exact parameterized names; filter while iterating, for example --gtest_filter='GGUFOps.Scale*'. A narrowed filter skips the operation-coverage gate. That gate runs in environment teardown, so inspect the process exit status even if no individual test failed. Shared changes require the affected architecture/projector numerical and structural regressions.

The Cohere2 and Gemma3n PagedAttention parity tests require FP16 KV caches and skip on ARM64, whose CPU PagedAttention executor does not support that cache precision. Their architecture conversion and stateful SDPA tests still run there. FP32-cache ARM64 PA equivalence is not established by these tests.

GGUFShards covers discovery from either shard, unordered explicit lists, renamed files in different directories, metadata-only first shards, mapping lifetime, invalid or incomplete shard sets, repeated scalar/array metadata, and conversion equivalence with a single-file model, including Unicode filenames. Its generated fixtures use the standard split.no (u16), split.count (u16) and split.tensors.count (i32) metadata.

Fixtures and oracles

Regenerate the Q8_1 weight fixtures with a clean llama.cpp checkout at 476c01efe88aad7880a8132d5d3a415f2ca75139 and its freshly built libggml-base:

python3 src/frontends/gguf/tests/gen_q8_1_accuracy.py \
  --llama-cpp /path/to/llama.cpp --library /path/to/libggml-base.so

The generator calls ggml's Q8_1 reference quantizer, then copies each block's F16 scale and signed codes into Q8_0 blocks for real ggml dequantization. Q8_1 has no to_float callback. The committed arrays and provenance JSON require no ggml dependency in unit tests.

Small NPZ/NPY numerical references are committed and work offline. Missing numerical references fail their tests. Architecture header fixtures are generated separately; if none are present, GGUFArchConversion skips, while a partially generated set fails. Generate them before claiming architecture fingerprint coverage.

The generator requires NumPy and the gguf Python package (llama.cpp's gguf-py) in the active environment, plus Git, CMake, and a C/C++ compiler. --fetch does not install Python dependencies.

python3 src/frontends/gguf/tests/gen_arch_fixtures.py --fetch

This fetches/builds the pinned llama.cpp generator and writes headers plus the manifest under tests/test_data/arch_fixtures. Review manifest changes. --llama-src /path/to/llama.cpp uses an existing checkout; see the script's pinned revision and prerequisites. The optional Python fingerprint suite also skips unless GGUF_FINGERPRINT_MODELS=name=path[=hash];... is set. Fingerprints are structural checks, not proof of numerical equivalence.

Regenerate numerical fixtures using their own contracts and reference revisions:

Real checkpoints

Use a Python environment containing the matching OpenVINO build with the GGUF frontend. From the repository root, install the test dependencies and run the selected model-hub scope:

python3 -m pip install -r tests/requirements_gguf
TEST_DEVICE=CPU PYTHONPATH="$PWD/tests/model_hub_tests${PYTHONPATH:+:$PYTHONPATH}" \
  python3 -m pytest tests/model_hub_tests/gguf -m precommit -v

Use -m nightly for the larger list, or select test_gguf.py / test_gguf_mmproj.py. Decoder model-hub tests check finite, shaped outputs and state updates; they do not compare tokens/logits against a reference. The native reference-token replay instead uses OV_GGUF_ACCURACY_DATA (and OV_GGUF_EMBEDDING_DATA for llama-embed) as described in the decoder fixture README. Run this separately: the variable replaces the selected synthetic fixture with a local checkpoint.

mmproj model-hub tests compare real checkpoint encoders against llama.cpp on an F32 copy of the represented weights. They use generated test inputs, not a full media application. Downloads, a C/C++ compiler, Git, CMake, and Ninja are needed. Reference builds are cached under GGUF_LLAMA_CPP_CACHE (default ~/.cache/openvino_gguf_llama_cpp). GGUF_MMPROJ_ORACLE selects a prebuilt oracle, but the pinned checkout is still needed for gguf-py. HF_HUB_CACHE controls checkpoint caching. To use local files, point GGUF_MMPROJ_LIST at a replacement precommit list:

gemma3,,/absolute/path/mmproj-gemma3.gguf
voxtral,,/absolute/path/mmproj-voxtral.gguf

The list format, skip reasons, and tolerance overrides live in precommit and nightly.

Acceptance

Keep registration, structural conversion, numerical agreement, and application functionality as separate evidence. A new architecture needs a nonzero oracle fixture and a real-checkpoint comparison; exercise relevant positions, sizes, cache appends/resets, and adaptation paths.

For each model architecture, a working F32/F16 reference path establishes architecture support. Implemented quantized formats remain enabled even when their checkpoint comparison falls below the numerical or greedy agreement thresholds. Record those failed comparisons as accuracy limitations; do not relabel them as parity passes. Unsupported tensor encodings and graph/runtime errors remain failures.

Check Numerical parity threshold and limit
Native decoder F32 fixture Full-logit normalized MSE below 1e-5; Gemma3n uses 2e-5 (3e-4 on ARM64) with every-step greedy equality; F32 inference, F16 KV, activation quantization disabled
Native real decoder replay Same first prediction and at least 90% matching greedy choices over prefill plus 12 reference-token steps; record full-logit errors
mmproj fixture Raw and adapted embeddings, normalized MSE below 1e-5; dynamic cases reuse one compiled model
mmproj real checkpoint CPU NMSE below 1e-5 unless an explicit model-list override documents the reason; other devices are not calibrated to the CPU limit

Use quantization controls consistently. Report checkpoint, revisions, device, precision, inputs, thresholds, skips, and failures. A represented-F32 reference does not erase a failed comparison against quantized CPU arithmetic, and coherent generated text does not establish encoder accuracy or broad answer quality.

CI runs the two C++ binaries through Smart CI's GGUF component gate. The jobs invoke GTest directly and upload XML reports. Fixture availability and conversion expectations are checked by the architecture suite itself. Run the same binaries locally with --gtest_filter while editing; use GHA for broader coverage and inspect test counts and skips in its artifacts. Model-hub CI runs checkpoint lists; llama.cpp compatibility CI records the backend revision, operator tests, state scenarios, and exclusions. These validate different contracts.

GenAI acceptance CI uses this workflow's OpenVINO package and wheels and a pinned companion GenAI commit on a 4-core/16-GB runner. Precommit runs generated tiny decoder, MoE and recurrent models across SDPA, PA, AUTO and continuous batching, plus tiny GGUF tokenizer, input, beam-search, streaming and saved-IR regressions. The multimodal pytest harness builds an independent pinned llama.cpp CPU oracle, converts pinned tiny checkpoints, and runs square/JPEG, SDPA/PA, single/multiple media, video/audio, chat, cancellation/reset and beam-search cases. Separate checks cover Optimum directory/map loading. Scheduled runs also enable the real Qwen3.5 pure Q4_0 fixture through run-real-models; precommit uses tiny models only. Acceptance reports record required coverage and source/precision provenance; Q4_K_M is excluded from accuracy gates pending the plugin fix. Known Gemma4 window and Unified prefix-cache parity gaps remain documented in mmproj.md.