frontend.py File Reference#
|
Mobilint SDK qb Compiler v1.2
MCS002-EN
|
Go to the source code of this file.
Classes | |
| class | qbcompiler.frontend.Model_Dict |
| Wrapper around the Mobilint compiler to support compilation and inference workflows. More... | |
Functions | |
| object | qbcompiler.frontend._to_config_manager_unset_V2 (object value) |
| Translate frontend-local _UNSET values to ConfigManager UNSET. | |
| qbcompiler.frontend._resolve_deprecated_kwargs (*, calibration_config, optq_config, mod_config, equivalent_transformation_config, search_weight_scale_config, uint8_input_config, preprocessing_config, save_sample_config, **kwargs) | |
| Extract and resolve deprecated parameters from kwargs into modern equivalents. | |
| QuantizeRequest_V2 | qbcompiler.frontend._normalize_quantize_request_V2 (*, model, Union[str, List[str]] save_path=_UNSET, str backend="onnx", Optional[str] target_device=None, feed_dict=None, dynamic_axes=None, in_dformats=None, bool yolo_decode_include=False, bool exclude_first_subgraph=False, int save_subgraph_type=0, str output_subgraph_path="", Union[str, List[str]] calib_data_path=_UNSET, device=_UNSET, inference_scheme=_UNSET, use_random_calib=_UNSET, cpu_offload=_UNSET, optimize_option=_UNSET, buffer_mode=_UNSET, input_shape_dict=_UNSET, force_npu_input_reposition=_UNSET, force_npu_output_reposition=_UNSET, image_channels=_UNSET, split_blocks=_UNSET, split_parts=_UNSET, Optional[str] config_preset=None, Optional[CompileConfig|str] compile_config=None, Optional[ResourceManagementConfig] resource_management_config=None, Optional[CalibrationConfig] calibration_config=None, Optional[BitConfig] bit_config=None, Optional[LlmConfig] llm_config=None, Optional[OptqConfig] optq_config=None, Optional[ModConfig] mod_config=None, Optional[EquivalentTransformationConfig] equivalent_transformation_config=None, Optional[SearchWeightScaleConfig] search_weight_scale_config=None, Optional[SaveSampleConfig] save_sample_config=None, Optional[Uint8InputConfig] uint8_input_config=None, Optional[PreprocessingConfig] preprocessing_config=None, **kwargs) |
| Build a canonical V2 quantize request without executing side effects. | |
| MbltCompileRequest_V2 | qbcompiler.frontend._normalize_mblt_compile_request_V2 (*, str|object model, str mblt_save_path, str backend="onnx", Optional[str] target_device=None, object device=_UNSET, feed_dict=None, dynamic_axes=None, in_dformats=None, bool yolo_decode_include=False, object cpu_offload=_UNSET, bool exclude_first_subgraph=False, Optional[str] config_preset=None, Optional[CompileConfig|str] compile_config=None, Optional[str] compilation_mode=None, **kwargs) |
| Build a canonical V2 compile-to-mblt request without side effects. | |
| bool | qbcompiler.frontend._is_existing_mblt_input_V2 (object model) |
| Return True when model is a readable existing .mblt file. | |
| None | qbcompiler.frontend._validate_mblt_for_mxq_compile_V2 (str model, object cpu_offload) |
| Validate an existing .mblt used as an mxq_compile input. | |
| None | qbcompiler.frontend._execute_quantize_request_V2 (ResolvedQuantizeRequest_V2 request) |
| Execute a resolved V2 quantize request via the CompilerV2 pipeline. | |
| None | qbcompiler.frontend._execute_mblt_compile_request_V2 (ResolvedMbltCompileRequest_V2 request) |
| Execute a resolved V2 compile-to-mblt request via the CompilerV2 pipeline. | |
| qbcompiler.frontend.mxq_compile (model, str target_device, Union[str, List[str]] calib_data_path=_UNSET, int save_subgraph_type=0, output_subgraph_path="", Union[str, List[str]] save_path=_UNSET, backend="onnx", feed_dict=None, dynamic_axes=None, in_dformats=None, yolo_decode_include=False, exclude_first_subgraph=False, device=_UNSET, inference_scheme=_UNSET, use_random_calib=_UNSET, cpu_offload=_UNSET, optimize_option=_UNSET, buffer_mode=_UNSET, input_shape_dict=_UNSET, force_npu_input_reposition=_UNSET, force_npu_output_reposition=_UNSET, image_channels=_UNSET, split_blocks=_UNSET, split_parts=_UNSET, Optional[str] config_preset=None, Optional[CompileConfig] compile_config=None, Optional[ResourceManagementConfig] resource_management_config=None, Optional[CalibrationConfig] calibration_config=None, Optional[BitConfig] bit_config=None, Optional[LlmConfig] llm_config=None, Optional[OptqConfig] optq_config=None, Optional[ModConfig] mod_config=None, Optional[EquivalentTransformationConfig] equivalent_transformation_config=None, Optional[SearchWeightScaleConfig] search_weight_scale_config=None, Optional[SaveSampleConfig] save_sample_config=None, Optional[Uint8InputConfig] uint8_input_config=None, Optional[PreprocessingConfig] preprocessing_config=None, **kwargs) | |
| Compile a model into a Mobilint eXeCUtable (MXQ) package for execution on Mobilint NPUs. | |
| qbcompiler.frontend.mblt_compile (str|Any model, str mblt_save_path, str target_device, backend="onnx", device="cpu", feed_dict=None, dynamic_axes=None, in_dformats=None, yolo_decode_include=False, cpu_offload=False, exclude_first_subgraph=False, **kwargs) | |
| Export a model to the Mobilint .mblt format without producing an MXQ package. | |
| None | qbcompiler.frontend.mxq_compile_V2 (model, str target_device, Union[str, List[str]] calib_data_path=_UNSET, int save_subgraph_type=0, output_subgraph_path="", Union[str, List[str]] save_path=_UNSET, backend="onnx", feed_dict=None, dynamic_axes=None, in_dformats=None, yolo_decode_include=False, exclude_first_subgraph=False, device=_UNSET, inference_scheme=_UNSET, use_random_calib=_UNSET, cpu_offload=_UNSET, optimize_option=_UNSET, buffer_mode=_UNSET, input_shape_dict=_UNSET, force_npu_input_reposition=_UNSET, force_npu_output_reposition=_UNSET, image_channels=_UNSET, split_blocks=_UNSET, split_parts=_UNSET, Optional[str] config_preset=None, Optional[CompileConfig|str] compile_config=None, Optional[ResourceManagementConfig] resource_management_config=None, Optional[CalibrationConfig] calibration_config=None, Optional[BitConfig] bit_config=None, Optional[LlmConfig] llm_config=None, Optional[OptqConfig] optq_config=None, Optional[ModConfig] mod_config=None, Optional[EquivalentTransformationConfig] equivalent_transformation_config=None, Optional[SearchWeightScaleConfig] search_weight_scale_config=None, Optional[SaveSampleConfig] save_sample_config=None, Optional[Uint8InputConfig] uint8_input_config=None, Optional[PreprocessingConfig] preprocessing_config=None, **kwargs) |
| V2 compile/quantize entry point backed only by ConfigManager resolution. | |
| None | qbcompiler.frontend.mblt_compile_V2 (str|object model, str target_device, str mblt_save_path, backend="onnx", object device=_UNSET, feed_dict=None, dynamic_axes=None, in_dformats=None, yolo_decode_include=False, object cpu_offload=_UNSET, exclude_first_subgraph=False, Optional[str] config_preset=None, Optional[CompileConfig|str] compile_config=None, Optional[str] compilation_mode=None, **kwargs) |
| V2 compile-to-mblt entry point backed only by ConfigManager resolution. | |
| None | qbcompiler.frontend.mblt_compile_with_callback_V2 (str model, str target_device, str mblt_save_path, str backend="onnx", Optional[str] device=None, Optional[bool] cpu_offload=None, Optional[str] config_preset=None, Optional[CompileConfig|str] compile_config=None, Optional[str] compilation_mode=None, *, Callable[[int, str], None] progress_callback) |
| V2 compile-to-mblt entry point with progress callbacks. | |
| None | qbcompiler.frontend.mxq_compile_with_callback_V2 (str model, str target_device, str save_path, str backend="onnx", Optional[str] device=None, Optional[Union[str, List[str]]] calib_data_path=None, Optional[bool] use_random_calib=None, Optional[str] config_preset=None, Optional[CompileConfig|str] compile_config=None, *, Callable[[int, str], None] progress_callback) |
| V2 compile/quantize entry point with progress callbacks. | |
| qbcompiler.frontend.run_mblt_model (str path_to_mblt, bool save_all_outputs=True, Optional[str] inference_output_path=None, Optional[int] target_subgraph=None) | |
Variables | |
| qbcompiler.frontend.logger = get_logger(__name__) | |
| qbcompiler.frontend._UNSET = object() | |
Function Documentation
◆ _to_config_manager_unset_V2()
|
protected |
Translate frontend-local _UNSET values to ConfigManager UNSET.
Definition at line 48 of file frontend.py.
◆ _resolve_deprecated_kwargs()
|
protected |
Extract and resolve deprecated parameters from kwargs into modern equivalents.
Mutates kwargs by popping consumed deprecated keys. Returns a tuple of resolved sub-config values.
Definition at line 55 of file frontend.py.
◆ _normalize_quantize_request_V2()
|
protected |
Build a canonical V2 quantize request without executing side effects.
Definition at line 152 of file frontend.py.
◆ _normalize_mblt_compile_request_V2()
|
protected |
Build a canonical V2 compile-to-mblt request without side effects.
Definition at line 242 of file frontend.py.
◆ _is_existing_mblt_input_V2()
|
protected |
Return True when model is a readable existing .mblt file.
Definition at line 282 of file frontend.py.
◆ _validate_mblt_for_mxq_compile_V2()
|
protected |
Validate an existing .mblt used as an mxq_compile input.
Only weight-bearing, properly partitioned .mblt files produced by mblt_compile() can be quantized. This surfaces actionable guidance for the common failure modes up front instead of a cryptic downstream error:
- No weights, or a single subgraph carrying unsupported ops -> error (a preview export is not a runnable artifact; regenerate with mblt_compile()).
- cpu_offload=False with more than one subgraph -> error (the graph cannot run without CPU offloading).
- cpu_offload=True with a single subgraph -> error (nothing to offload; recompile with cpu_offload=False).
Definition at line 287 of file frontend.py.
◆ _execute_quantize_request_V2()
|
protected |
Execute a resolved V2 quantize request via the CompilerV2 pipeline.
Routing:
- .mblt input on disk → single-stage pipeline of :class:MxqCompileStage (the dominant quantize CLI case).
- Raw model input → two-stage pipeline (:class:MBLTCompileStage writes an intermediate .mblt into the pipeline's tempdir; :class:MxqCompileStage picks it up via ctx.artifacts["mblt_path"]).
Definition at line 367 of file frontend.py.
◆ _execute_mblt_compile_request_V2()
|
protected |
Execute a resolved V2 compile-to-mblt request via the CompilerV2 pipeline.
Imported lazily so the pipeline module is only loaded on first use.
Definition at line 419 of file frontend.py.
Variable Documentation
◆ logger
| qbcompiler.frontend.logger = get_logger(__name__) |
Definition at line 42 of file frontend.py.
◆ _UNSET
|
protected |
Definition at line 44 of file frontend.py.
Generated by