Model Export & Serving Runtime API Reference
k3_node.export.onnx_exporter.export_onnx(model_or_task, output_path, dummy_inputs=None, opset=17, dynamic_axes=True, input_names=None, output_names=None, verbose=False)
Exports a K3-Node GNN model or task to high-performance ONNX format.
Supports arbitrary Graph Neural Networks (GCN, GAT, GraphSAGE, GIN, SchNet, materials models, and task estimators) with dynamic graph sizing (varying numbers of nodes and edges).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_or_task
|
Any
|
A K3-Node task instance (e.g. |
required |
output_path
|
Union[str, Path]
|
Target path for the |
required |
dummy_inputs
|
Optional[Any]
|
Optional sample input data (e.g., PyG |
None
|
opset
|
int
|
ONNX operator set version. (default: |
17
|
dynamic_axes
|
bool
|
Whether node and edge dimensions should be dynamic. (default: |
True
|
input_names
|
Optional[List[str]]
|
Optional custom names for input tensors. |
None
|
output_names
|
Optional[List[str]]
|
Optional custom names for output tensors. |
None
|
verbose
|
bool
|
Whether to print verbose export progress. (default: |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path object pointing to the generated |
k3_node.export.tflite_exporter.export_tflite(model_or_task, output_path, dummy_inputs=None, quantization=None, representative_dataset=None, verbose=False)
Exports a K3-Node GNN model or task to an optimized TensorFlow Lite flatbuffer.
Supports float32, float16 (FP16), and dynamic range INT8 quantization for low-latency deployment on edge, mobile, and embedded hardware.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_or_task
|
Any
|
A K3-Node task instance or model instance. |
required |
output_path
|
Union[str, Path]
|
Target path for the |
required |
dummy_inputs
|
Optional[Any]
|
Optional sample input data (e.g., PyG |
None
|
quantization
|
Optional[str]
|
Quantization strategy:
- |
None
|
representative_dataset
|
Optional[Callable[[], Generator[List[ndarray], None, None]]]
|
Generator of representative calibration inputs for |
None
|
verbose
|
bool
|
Whether to print verbose progress. (default: |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path object pointing to the generated |
k3_node.export.tensorrt_exporter.export_tensorrt(model_or_task_or_onnx, output_path, dummy_inputs=None, precision='fp16', workspace_gb=1, min_shapes=None, opt_shapes=None, max_shapes=None, verbose=False)
Compiles a K3-Node model or ONNX file into an ultra-low latency NVIDIA TensorRT engine.
Uses the Python tensorrt API if available on the GPU host, or invokes NVIDIA's
trtexec binary directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_or_task_or_onnx
|
Any
|
K3-Node model/task, or an existing |
required |
output_path
|
Union[str, Path]
|
Target path for the compiled |
required |
dummy_inputs
|
Optional[Any]
|
Optional input sample to determine shapes and topology. |
None
|
precision
|
str
|
Precision mode: |
'fp16'
|
workspace_gb
|
int
|
Max GPU memory in GB allocated for TensorRT engine building. (default: |
1
|
min_shapes
|
Optional[Dict[str, Tuple[int, ...]]]
|
Optional minimum dynamic shapes dictionary (e.g. |
None
|
opt_shapes
|
Optional[Dict[str, Tuple[int, ...]]]
|
Optional optimal dynamic shapes dictionary (e.g. |
None
|
max_shapes
|
Optional[Dict[str, Tuple[int, ...]]]
|
Optional maximum dynamic shapes dictionary (e.g. |
None
|
verbose
|
bool
|
Whether to log engine building progress. (default: |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path object pointing to the compiled TensorRT |
k3_node.export.tensorrt_exporter.generate_triton_config(model_name, output_dir, in_channels, out_channels, backend='onnxruntime', max_batch_size=0)
Generates a complete Triton Inference Server model repository directory structure and config.pbtxt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Name of the model in Triton (e.g., |
required |
output_dir
|
Union[str, Path]
|
Root path for the model repository folder. |
required |
in_channels
|
int
|
Number of node input features. |
required |
out_channels
|
int
|
Number of output features or classes. |
required |
backend
|
str
|
Backend engine ( |
'onnxruntime'
|
max_batch_size
|
int
|
Maximum batch size (default: |
0
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the generated |
k3_node.export.runtime.ONNXModel
High-performance serving wrapper for exported ONNX GNN models.
Requires only onnxruntime and numpy. Completely decoupled from Keras,
PyTorch, and TensorFlow for lightweight production microservices.
Example
__init__(model_path, providers=None, session_options=None)
Initializes the ONNX runtime inference session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
Union[str, Path]
|
Path to the |
required |
providers
|
Optional[List[str]]
|
Execution providers list (e.g. |
None
|
session_options
|
Optional[Any]
|
Optional custom ONNX Runtime SessionOptions. |
None
|
predict(data=None, *args, **kwargs)
Runs low-latency inference on graph data.
Accepts
- PyG / K3-Node
Dataobject - Dictionary of tensors
- Positional numpy arrays
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input graph Data, dictionary, or array. |
None
|
*args
|
Any
|
Additional positional inputs. |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Numpy array containing model predictions or logits. |
k3_node.export.runtime.TFLiteModel
Lightweight serving wrapper for TensorFlow Lite flatbuffer GNN models.
Requires only standard tensorflow or tflite_runtime. Ideal for mobile,
Raspberry Pi, and edge embedded devices.
Example
__init__(model_path)
Initializes the TFLite interpreter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
Union[str, Path]
|
Path to the |
required |
predict(data=None, *args, **kwargs)
Runs inference using the TFLite interpreter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input graph Data, dict, or numpy array. |
None
|
*args
|
Any
|
Additional positional inputs. |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Numpy array containing prediction results. |