Reference#
This chapter is a reference for the current qbcompiler command line, Python API, configuration schema, supported inputs, and related terms. The source of truth is the current qbcompiler implementation.
CLI Reference#
Run the CLI as:
python -m qbcompiler <command> [options]
The current command set is compile, parse, quantize, dump-config, info, check, presets, validate, and extract-body. The table below covers the five this manual builds its examples on; presets is described under Compile Configuration.
Command |
Purpose |
Main options |
|---|---|---|
|
End-to-end model to |
|
|
Convert an input model to |
|
|
Convert a runnable |
|
|
Write a default or preset-derived |
|
|
Print the provenance recorded in a |
|
--backend defaults to onnx. --calib-data-path is repeatable. --compile-config accepts JSON, YAML, or YML and is the extension point for settings that do not have dedicated CLI flags. dump-config chooses JSON or YAML from the output file suffix.
For subprocess integrations, the CLI has an opt-in JSONL protocol. Set QBCOMPILER_JSONL=1, true, yes, or on to emit structured status, progress, result, log, and error messages on stdout. Without that environment variable, normal logs are written to stderr.
Python API Reference#
Public functions are available from qbcompiler.
API |
Purpose |
|---|---|
|
Main Python entry point. Compiles a model or runnable |
|
Parses a source model (ONNX / PyTorch / TensorFlow / TF Lite / TorchScript), then compiles it to |
|
Compiles an existing |
|
|
|
|
|
Returns the provenance record of a |
|
Exports a model to |
|
Returns preset metadata dictionaries. |
|
Writes a |
|
Writes a |
The main mxq_compile parameters are:
from qbcompiler import mxq_compile
mxq_compile(
model="model.onnx",
target_device="aries-rb",
calib_data_path="calib",
save_path="model.mxq",
backend="onnx",
device="gpu",
config_preset="classification",
compile_config=None,
)
Important parameters include model, target_device, calib_data_path, save_path, backend, feed_dict, dynamic_axes, in_dformats, yolo_decode_include, exclude_first_subgraph, device, inference_scheme, use_random_calib, cpu_offload, layer_bias_correction, buffer_mode, input_shape_dict, force_npu_input_reposition, force_npu_output_reposition, image_channels, split_blocks, split_parts, config_preset, compile_config, config_save_path, model_part, model_part_options, and sub-config objects such as calibration_config, bit_config, llm_config, hessian_quant_config, layer_bias_correction_config, mod_config, equivalent_transformation_config, search_weight_scale_config, uint8_input_config, preprocessing_config, and save_sample_config.
config_save_path, model_part and model_part_options are new in qbcompiler 1.3:
config_save_pathwrites the fully resolvedCompileConfig— the normalized configuration after every layer of the precedence order below has been applied — before compilation starts. A.yamlor.ymlsuffix writes YAML, any other suffix writes JSON, and parent directories are created. Because it is written up front, the record survives a compile that fails after it starts, and the file can be passed straight back ascompile_config=to reproduce the compile. It is written by the quantize phase, so acompilethat fails while parsing produces nothing. The CLI exposes it as--config-save-pathonquantizeandcompile.model_partnames which part of a multi-part torch model to parse ("vision","language","encoder", and so on), andmodel_part_optionspasses extra arguments that part needs, such as{"mel_frames": 100}. A model declaring exactly one part resolves it fromNone; a model declaring several requires a name. List them withavailable_parts(model)fromqbcompiler.model_dict.parser.patcher.parts. These replace the removedhf_configargument, which now raisesValueError.
Configuration resolution priority (highest wins): explicit arguments → sub-config objects → compile_config file or config_preset, whichever is given → defaults. Passing both uses the preset and ignores the file. For details and usage examples, see Compile Configuration — Config Resolution Priority.
CompileConfig Schema#
CompileConfig is a Pydantic model with extra="forbid" and aliases enabled. Use alias names in JSON/YAML files. A full template can be generated with:
python -m qbcompiler dump-config --output compile_config.yaml
python -m qbcompiler dump-config --preset yolo_640 --output yolo_640.yaml
Top-level fields:
Alias |
Python field |
Default |
Meaning |
|---|---|---|---|
|
|
|
Model path list. Usually supplied by API/CLI instead. |
|
|
|
Calibration dataset path list. |
|
|
|
MXQ output path list. |
|
|
|
Generate random calibration data. |
|
|
|
Compile-time NPU core-assignment scheme used by the generated MXQ. See inferenceScheme. |
|
|
|
Enable CPU offloading for unsupported groups. |
|
|
|
Force input reposition operations onto NPU. |
|
|
|
Force output reposition operations onto NPU. |
|
|
|
Buffer serialization mode. |
|
|
|
Multi-shape compile specification for supported models. |
|
|
|
Compilation compute device: |
|
|
|
Computation dtype metadata. |
|
|
|
Enable debug mode. |
|
|
|
Enable trace mode. |
|
|
|
Number of image channels; |
|
|
|
Config schema version. |
|
|
|
LLM multi-MXQ split points by block index. |
|
|
|
Split LLM transformer blocks into N parts. |
Nested sections:
Alias |
Type |
Purpose |
|---|---|---|
|
|
Treat model inputs as uint8, optionally by input name. |
|
|
Input preprocessing pipeline such as resize, letterbox, crop, normalize, and format conversion. |
|
|
Weight dtype, GPU calibration policy, and weight-memory method. |
|
|
Quantization method, output quantization, calibration mode, clipping/statistics, and layer overrides. |
|
|
Quantization precision settings. |
|
|
HessianQuant optimization settings, including |
|
|
Calibration-derived per-channel bias correction folded into integer convolution biases. |
|
|
MOD training/optimization settings. |
|
|
LLM sequence/cache/runtime/debug settings. If |
|
|
Sparse MoE calibration expert selection. |
|
|
SmoothQuant-like, rotation, and FFN equivalent transformations. |
|
|
Weight-scale search. |
|
|
Load externally supplied scale entries. |
|
|
Internal runtime metadata. |
|
|
Save sample data for inspection/debugging. |
CompileConfig.from_file() accepts .json, .yaml, and .yml. For compatibility, it also flattens grouped keys such as quantization.calibration, quantization.bit, advancedQuantization.hessianQuant, advancedQuantization.mod, advancedQuantization.EquivalentTransformation, advancedQuantization.searchWeightScale, advancedQuantization.loadScale, and advancedQuantization.layerBiasCorrection, which 1.3 adds. That grouped spelling is also the one the tool writes — dump-config and --config-save-path both emit it. Flattening overwrites rather than merges, so a top-level calibration block added beside a quantization.calibration one is discarded with no message: do not mix the two spellings in one file.
inferenceScheme#
inferenceScheme selects how NPU core work is assigned when qb Runtime uses the MXQ for inference. Because the compiled MXQ is prepared for the selected core-assignment scheme, an MXQ built only for one mode cannot later be switched arbitrarily to another mode at runtime. One built with all carries every mode the model and target support, but the caller must name one: qb Runtime’s default CoreMode::Auto accepts only an MXQ with exactly one mode, so an all build needs an explicit setSingleCoreMode() or setGlobal4CoreMode() — see ARIES ModelConfig Configuration.
Available choices are single, multi, global4, global8, and all. single uses independent Local Cores, multi is the cluster-level 4-batch mode, and global4/global8 use 4 or 8 Local Cores together for one input. all prepares the MXQ for every core mode supported by the selected model and target. Support can vary by model, target, and compiler version. REGULUS targets have a single NPU core, so MXQ files compiled for REGULUS can use only single mode. From qbcompiler 1.3 this is enforced rather than left to fail later: multi, global4 and global8 are rejected outright on a single-core target, and all narrows to single there. The check runs before quantization regardless of whether the scheme or the target device was set first. global is a legacy/compatibility value; use global4 or global8 for new settings.
If llm.attributes.runtime.batchSize is greater than 1, LLM/KV-cache transformer compilation accepts single, global4 and global8, and rejects multi and all rather than narrowing them — each segment compiles under exactly one scenario, and guessing which one was meant would build for a core set nobody asked for. Vision batch inference and LLM batch inference do not use the same core-mode rule.
For what each mode means, see ARIES Core Mode. For runtime core/cluster selection, see ARIES ModelConfig Configuration.
RuntimeOptions#
RuntimeOptions currently contains only:
Field |
Default |
Meaning |
|---|---|---|
|
|
Compiler/runtime version metadata. |
This section is runtime metadata rather than a normal user tuning surface. Prefer the compile, calibration, preprocessing, LLM, and optimization sections for user-controlled behavior.
Preset List#
Preset |
Extends |
Behavior |
|---|---|---|
|
none |
Image classification defaults: |
|
none |
Object detection defaults: |
|
|
Enables uint8 input and standard Torchvision preprocessing: resize shortest side to 256, center crop 224x224, normalize ImageNet mean/std, |
|
|
Enables uint8 input and 640x640 letterbox preprocessing with pad value 114, |
|
|
Enables uint8 input and 1280x1280 letterbox preprocessing with pad value 114, |
|
none |
Enables LLM config with |
|
|
Turns off those six equivalent transformations and full-sequence-length calibration, trading accuracy for compile time. |
|
none |
Transformer-oriented calibration/bit settings. |
|
none |
Enables LLM handling and uses |
Supported Frameworks#
The public backend strings are:
Backend |
Input |
|---|---|
|
ONNX model path. This is the primary path and is used by |
|
TensorFlow SavedModel or supported TensorFlow/Keras model path. |
|
TensorFlow Lite model path. |
|
TorchScript module/model. |
|
PyTorch model or HuggingFace/transformers model path/object flows. HuggingFace LLMs use this backend path, not a separate |
Supported Target Device#
Use these target device strings in CLI and Python API calls:
target device |
Meaning |
|---|---|
|
REGULUS RA target. |
|
ARIES RB target. |
|
REGULUS RB target. |
|
REGULUS RB target connected over USB. From qbcompiler 1.3. |
The validator accepts the public strings above. Internal enum names use underscores, but user-facing values use hyphens.
Supported Operators#
Mobilint IR Operations List lists the operations Mobilint hardware runs natively. It is not the whole answer: an operation outside that list may still compile through a graph-level transformation, and whether any given one runs natively also depends on the model, backend, shapes and target device, which the parser and target-device allocation logic settle per compile.
Available reference paths:
For non-ONNX backends, parse/compile the model and inspect unsupported groups with
.mbltand CPU offloading workflows.If a model contains unsupported groups,
cpuOffload/cpu_offloadcan partition those groups for CPU execution where the runtime flow supports it.
Glossary#
Term |
Meaning |
|---|---|
|
Mobilint executable package produced by quantization/compilation and run on Mobilint NPUs. |
|
Mobilint intermediate model format used between parsing and MXQ generation. |
|
Convert a source model into |
|
Convert a runnable |
|
End-to-end parse plus quantize flow. |
|
Source model framework identifier such as |
|
Mobilint NPU target device string such as |
NPU Chip |
Mobilint NPU product name such as ARIES or REGULUS. |
target device |
Compile target such as |
|
Representative input tensors used to derive quantization scales/statistics. |
|
Partitioning unsupported graph groups for CPU execution while supported body subgraphs run on NPU. |
|
The largest NPU-runnable supported subgraph extracted from a partitioned |
|
Built-in partial |
License#
See License for the open-source license notices included with this manual.