콘텐츠로 이동

qbcompiler.configs.compile_config

Attributes

Name Description
logger

logger

logger = get_logger(__name__)

CompileConfig

class CompileConfig(ConfigABC)

Attributes

Name Description
optional
py_to_cpp_name
min_max_check
inference_scheme_types
sample_dtypes Unified compilation configuration object for Mobilint MXQ compilation.

optional

optional = False

py_to_cpp_name

py_to_cpp_name = {
    "calib_data_path": "calibData",
    "save_path": "savePath",
    "model_nickname": "modelNickname",
    "save_msgpack_name": "saveMsgpackName",
    "model_path": "modelPath",
    "inference_scheme": "inferenceScheme",
    "save_sample": "saveSample",
    "cpu_offload": "cpuOffload",
    "optimize_option": "optimizeOption",
    "sample_dtype": "sampleDtype",
    "version": "version",
}

min_max_check

min_max_check = {"optimize_option": [0, None]}

inference_scheme_types

inference_scheme_types = ["single", "multi", "global", "global4", "global8", "all"]

sample_dtypes

sample_dtypes = ["float", "int8"]

Unified compilation configuration object for Mobilint MXQ compilation.

This config consolidates compilation-related parameters and sub-config class into a single structure.

Methods

Name Description
__init__ Unified compilation configuration object for Mobilint MXQ compilation.
default_config Create default config with optional parameter overrides.
from_json Load config from JSON file and merge with additional kwargs.
check_valid_str_configs
to_dict

__init__

def __init__(
    self,
    calib_data_path: str | None,
    use_random_calib: bool,
    save_path: str,
    model_nickname: str,
    save_msgpack_name: str | None,
    model_path: str | None,
    inference_scheme: str,
    save_sample: bool,
    cpu_offload: bool,
    optimize_option: int,
    sample_dtype: str,
    buffer_mode: int,
    version: str,
    input_shape_dict: dict,
    resource_management: ResourceManagementConfig,
    quantization: QuantizationConfig,
    advanced_quantization: AdvancedQuantizationConfig,
    llm_config: LlmConfig,
    input_process: InputProcessConfig,
    optional: bool = optional,
)

Unified compilation configuration object for Mobilint MXQ compilation.

Parameters

  • calib_data_path — str | None. Path to calibration dataset. Accepts either:
    - a directory containing pre-processed NumPy samples, or
    - a .txt/.json meta file listing NumPy sample file paths.
    If use_random_calib is True, this may be None. Otherwise, a valid path is expected for quantized compilation workflows.
  • use_random_calib — bool. When True, uses randomly generated calibration samples (typically for smoke testing and compilability validation). When False, calib_data_path is used as the calibration source.
  • save_path — str. Output MXQ filename/path to generate.
  • model_nickname — str. Model nickname used as a fallback identifier when intermediate results need to be saved. It is recommended to set this to the filename component of save_path.
  • save_msgpack_name — str | None. filename/path to save an intermediate serialized representation (msgpack) of the high-level compiled model/graph. Primarily intended for debugging and is now rarely used.
  • model_path — str | None. (deprecated) Outdated argument. Please refer to the model usage in the mxq_compile function.
  • inference_scheme — str. NPU inference scheme string. Must be one of:
    "single", "multi", "global", "global4", "global8" ("global" and "global8" behave identically).
  • save_sample — bool. When True, saves representative input/output tensors for debugging.
  • cpu_offload — bool. Enables CPU offload for unsupported operator groups/segments during NPU inference. This is a beta feature and is recommended only for special cases.
  • optimize_option — int. Compiler optimization selector.
  • sample_dtype — string. Data type for saved sample inference outputs: "float" or "int8". Primarily intended for debugging and is now rarely used.
  • buffer_mode — int. Buffer serialization mode for saving .mblt file. Common conventions:
    - 0: naïve buffer serialization
    - 1: mmap-backed buffer serialization
  • version — str. qbcompiler version.
  • input_shape_dict — dict. Optional HWC input shape dictionary used for multi-shape compilation (for example {"input0": [[224, 224, 3], [256, 256, 3]]}).
  • resource_management — ResourceManagementConfig. Resource management configuration class.
  • quantization — QuantizationConfig. Quantization configuration class (e.g., calibration strategy, bit-widths, per-tensor/per-channel settings, quantization scheme/policies).
  • advanced_quantization — AdvancedQuantizationConfig. Advanced quantization configuration block for fine-grained or experimental controls beyond the basic quantization settings.
  • llm_config — LlmConfig. LLM-specific configuration class.
  • input_process — InputProcessConfig. Unified input processing configuration containing uint8 input handling, image channels, and preprocessing pipeline settings. optional bool. Indicates whether this config is optional. Use the default value defined as a class variable.

default_config

def default_config(cls, **kwargs)

Create default config with optional parameter overrides.

Args: **kwargs: Parameters to override defaults

from_json

def from_json(cls, json_path: str, **kwargs)

Load config from JSON file and merge with additional kwargs.

Args: json_path: Path to JSON configuration file **kwargs: Additional compile-time parameters (calib_data_path, save_path, etc.)

check_valid_str_configs

def check_valid_str_configs(self)

to_dict

def to_dict(self)

Functions

Name Description
get_compile_config Create Compilation Config with partial parameters merged with defaults.

get_compile_config

def get_compile_config(
    calib_data_path=None,
    use_random_calib=False,
    save_path="./tmp.mxq",
    save_msgpack_name=None,
    model_nickname="temporary",
    model_path=None,
    inference_scheme="single",
    save_sample=False,
    cpu_offload=False,
    optimize_option=1,
    sample_dtype="float",
    buffer_mode=1,
    input_shape_dict=dict(),
    resource_management_config: Optional[ResourceManagementConfig] = None,
    quantization_config: Optional[QuantizationConfig] = None,
    llm_config: Optional[LlmConfig] = None,
    advanced_quantization_config: Optional[AdvancedQuantizationConfig] = None,
    input_process_config: Optional[InputProcessConfig] = None,
    version=__version__,
    **kwargs,
)

Create Compilation Config with partial parameters merged with defaults.