OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# Verifies the GGUF frontend against real .gguf checkpoints downloaded from the Hugging Face
# Hub, one per architecture listed in src/frontends/gguf/docs/supported_models.md.
#
# Each test downloads one .gguf file, converts it, compiles it, and runs two forward steps,
# feeding the cache/state outputs of the first step into the second. The checks cover finite,
# correctly shaped logits and populated, changing KV caches. It does not compare tokens or logits
# with a reference; see the OV_GGUF_ACCURACY_DATA replay in tests/test_data/arch_accuracy/README.md.
#
# gguf_models_precommit lists the small (<=~4B parameter) architectures, run on every commit.
# gguf_models_nightly lists the rest (up to ~30B), run nightly given their download size.
import os
import pytest
from models_hub_common.constants import clean_hf_cache_dir, hf_cache_dir
from models_hub_common.utils import cleanup_dir
from utils import assert_valid_logits, parse_gguf_model_list, run_gguf_embedding_model, run_gguf_model
class TestGGUF:
def teardown_method(self):
if clean_hf_cache_dir:
cleanup_dir(hf_cache_dir)
def run(self, arch, repo_id, filename, mark, reason, ie_device):
assert mark in (None, "skip", "xfail"), f"Unknown mark {mark!r} for {arch}"
if mark == "skip":
pytest.skip(reason)
if mark == "xfail":
pytest.xfail(reason)
if arch == "llama-embed":
run_gguf_embedding_model(repo_id, filename, device=ie_device)
return
logits = run_gguf_model(repo_id, filename, device=ie_device)
assert_valid_logits(logits)
@pytest.mark.parametrize(
"arch,repo_id,filename,mark,reason",
parse_gguf_model_list(os.path.join(os.path.dirname(__file__), "gguf_models_precommit")))
@pytest.mark.precommit
def test_gguf_precommit(self, arch, repo_id, filename, mark, reason, ie_device):
self.run(arch, repo_id, filename, mark, reason, ie_device)
@pytest.mark.parametrize(
"arch,repo_id,filename,mark,reason",
parse_gguf_model_list(os.path.join(os.path.dirname(__file__), "gguf_models_nightly")))
@pytest.mark.nightly
def test_gguf_nightly(self, arch, repo_id, filename, mark, reason, ie_device):
self.run(arch, repo_id, filename, mark, reason, ie_device)