build_from_gguf()¶
Build an ONNX ModelPackage from a GGUF model file.
from mobius import build_from_gguf
Note: Requires the optional
ggufpackage:pip install mobius-onnx[gguf]
Signature¶
def build_from_gguf(
gguf_path: str | Path,
*,
task: str | None = None,
dtype: str | None = None,
keep_quantized: bool = False,
) -> ModelPackage:
Parameters¶
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
Path to a |
|
|
|
Override the model task (e.g. |
|
|
|
Override model dtype (e.g. |
|
|
|
When |
Returns¶
ModelPackage — A dict-like collection of named ir.Model objects.
Examples¶
from mobius import build_from_gguf
# Basic conversion (dequantizes to float)
pkg = build_from_gguf("llama-3.2-1b-q4_0.gguf")
pkg.save("output/llama/")
# Preserve quantization (Q4_0/Q4_1/Q8_0 → MatMulNBits)
pkg = build_from_gguf("llama-3.2-1b-q4_0.gguf", keep_quantized=True)
pkg.save("output/llama-q4/")
# Via CLI
mobius build-gguf llama-3.2-1b-q4_0.gguf --output output/llama/
Behavior¶
Reads GGUF metadata to detect architecture and config
Maps GGUF tensor names to HuggingFace weight names
Dequantizes quantized tensors to float (or repacks into MatMulNBits when
keep_quantized=True)Applies architecture-specific tensor processors (e.g. Q/K permute)
Builds the ONNX graph using the same pipeline as
build()Runs
preprocess_weights()(HF → ONNX name mapping)Applies weights to the graph
Supported GGUF Architectures¶
The GGUF builder maps GGUF architecture names (e.g. llama, qwen2,
gemma) to the same model classes used by build(). Most decoder-only
LLM architectures are supported.