OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
Running converted GGUF models
convert() returns a stateless graph with llama.cpp-style inputs. adapt_to_genai() turns a
converted model into the stateful models with the OpenVINO GenAI interface. Multimodal projector
files use their own encoder contract.
Split GGUF files
The native frontend loads split models directly without writing a merged GGUF. Pass any shard
with the standard model-00001-of-00003.gguf filename; the loader reads split.count and
split.no and opens the other expected shards in the same directory. All shards of the
chosen quantization must be available locally.
from openvino.frontend import FrontEndManager
frontend = FrontEndManager().load_by_framework("gguf")
model = frontend.convert(frontend.load(
"Q4_K_M/Qwen3.5-122B-A10B-Q4_K_M-00001-of-00003.gguf"
))
For renamed shards or files in different directories, supply a complete list of string paths.
List order does not matter; the loader uses split.no to select shard zero's model metadata.
model = frontend.convert(frontend.load([
"/models/part-a.gguf", "/other-disk/part-b.gguf", "/models/part-c.gguf"
]))
C++ accepts a std::vector<std::string> or std::vector<std::filesystem::path>, and also
separate path arguments to load():
auto input = frontend->load(std::vector<std::string>{
"/models/part-a.gguf", "/other-disk/part-b.gguf", "/models/part-c.gguf"});
auto model = frontend->convert(input);
An explicit list must contain every shard; the loader does not fill in omitted entries. Inputs must belong to one split model. Missing shards, duplicate shard indices or tensor names, conflicting metadata and inconsistent total tensor counts produce load errors. Each shard keeps its own mapping; quantized weights use the same repacking as single-file inputs. This avoids a merged disk copy but does not reduce conversion or compilation memory requirements or extend architecture and quantization coverage.
Stateless contract
The default decoder graph mirrors the llama.cpp backend interface:
| Input | Meaning |
|---|---|
inp_tokens [1,1,1,T] i32 |
Token IDs of this step |
inp_pos [1,1,1,T] i32 |
Positions; four sections per token for interleaved M-RoPE (qwen35, qwen35moe) |
inp_out_ids [1,1,1,N] i32 |
Rows whose logits are produced |
self_kq_mask [1,1,T,KV] f32, self_kq_mask_swa |
Additive causal mask; the second one for sliding-window layers |
inp_kv_idx, token_len_per_seq |
KV write slots and per-sequence length, when the graph consumes them |
cache_k_*, cache_v_*, recurrent states |
Previous cache/state, returned as matching outputs |
The output is logits. run_gguf_model is a
working Python driver for two steps. This is the only route available from Python: the GGUF passes
below have no Python bindings, and DecoderTransformationExtension cannot be constructed from Python.
Stateful and GenAI conversion
Convert without GenAI-specific extensions, then pass the result to
adapt_to_genai(). It returns the named
models GenAI uses; callers do not register or order individual passes. The same call adapts a
projector file.
#include <openvino/frontend/gguf/adapt_to_genai.hpp>
#include <openvino/frontend/manager.hpp>
using namespace ov::frontend::gguf;
ov::frontend::FrontEndManager manager;
auto frontend = manager.load_by_framework("gguf");
auto models = adapt_to_genai(frontend->convert(frontend->load("model.gguf")));
auto language = models.at("language");
adapt_to_genai() modifies and returns the converted decoder as language, and throws for a
model that is already adapted. GenAIExtension is deprecated: it calls adapt_to_genai() at
the end of convert() and returns language.
Internally, GGUFMakeStateful replaces each KV cache
Parameter/Result pair with a Variable, adds beam_idx and reorders caches by it. It accepts both
the frontend's cache-write operation and its lowered stateless form, so it runs on a converted model. Sliding-window
caches can be left stateless with skip_caches. Recurrent states are declared through the
gguf_recurrent_states rt_info key.
AdaptToGenAI then exposes GenAI's
interface. Select the mode with GenAIAdaptOptions::input:
| Mode | Inputs | Output |
|---|---|---|
IDS_TO_LOGITS (default) |
input_ids [B,T], attention_mask [B,KV], position_ids [B,T], beam_idx [B] |
logits [B,N,vocab] |
EMBEDS_TO_LOGITS |
inputs_embeds [B,T,D] instead of input_ids; see multimodal language models |
logits [B,N,vocab] |
EMBEDS_TO_LOGITS also returns the token lookup as text_embeddings and, for architectures with
per-layer token embeddings, text_embeddings_per_layer.
- The number of output rows
Ndepends on the model and attention backend. Standard SDPA decoders generally select the last token per sequence; PagedAttention can expose a row for each token. - The leading dimensions are derived from the live inputs, so one graph serves both SDPA and
ov::pass::SDPAToPagedAttention. - The LM head is connected directly to the logits Result with a rank-3 input, so GenAI's slice-before-matmul optimization projects only the sampled rows during prefill. A scalar output scale is moved to the activation input when the head has no other consumers; softcap output chains remain recognizable without expanding compressed weights.
- Sliding-window masks use the
gguf_swa_window_sizert_info value when the file records a window length. Noncausal sliding-window attention is not supported by GenAI adaptation. - Gated-DeltaNet states (
qwen35,qwen35moe) and LFM2 short-convolution states (lfm2,lfm2moe) get a dynamic batch, followbeam_idxand mask left padding. Mamba 2 andnemotron_hstates stay at one sequence: greedy, batch-1 decoding only. A consumer must reset, not trim, the states listed ingguf_recurrent_states. - The pass does not create a tokenizer, sampler or pipeline, and it does not adapt encoder models.
GGUFMakeStateful remains independently available through DecoderTransformationExtension
for consumers that keep GGUF IO. The llama.cpp backend uses its own stateful lowering for its
cache-slot and fixed-mask semantics, without GenAI adaptation.
Tokenizer metadata
Conversion attaches the file's tokenizer.ggml.* and tokenizer.chat_template values to the
model's rt_info as GGUFTokenizerMetadata,
under gguf_tokenizer_metadata_key(), when the decoder provides them. Values are strings, string vectors or tensors. A consumer such
as GenAI can build the tokenizer from it without reopening the file. The attribute is intentionally
in-memory only: it is dropped on clone() and not written to IR, so read it from the converted model.
Internal operations and serialization
SetRows is a conversion placeholder for
GGML_OP_SET_ROWS. GGUFMakeStateful consumes cache writes; LowerSetRowsStateless lowers the rest.
It never survives into the converted model.
These core ov::op::internal operations can remain in the converted model:
| Operation | Emitted for | Alternative |
|---|---|---|
SelectiveSSM |
SSM_SCAN, Mamba 2 scalar decay |
None |
GatedDeltaNet |
GATED_DELTA_NET, scalar gate |
Loop reference path for per-key gating or force_ref; not available with split_outputs |
GatherMatmul |
MUL_MAT_ID, eligible constant expert weights |
Generic Gather/MatMul for other weights |
See ssm_scan.cpp, gated_delta_net.cpp
and mul_mat_id.cpp for exact selection conditions.
Internal operations are outside the public IR opsets. Saving IR can succeed and still produce a file the IR frontend cannot read back, so test the save/read round trip. Compiled-model export, import and caching are plugin-specific; test them on the target device. In-process conversion needs no IR.
A new internal-op path should keep a public-op reference path where practical, test both against the same oracle and update the table above. Frontend placeholders need a normalization lowering.