PipelineProto#
- class onnx_light.onnx.PipelineProto(*args, **kwargs)#
Bundles LLM models whose transferred values use identical output and input names.
- CopyFrom(self, arg: onnx_light.onnx_py._onnxpyprotoop.PipelineProto, /) None#
Copies one instance into this one.
- Equals(self, other: onnx_light.onnx_py._onnxpyprotoop.PipelineProto) bool#
Compares message fields directly without serialization.
- HasField(self, field_name: str) bool#
Checks if a field is set, following the protobuf HasField API.
- ParseFromFile(self, name: str, options: object | None = None, external_data_file: str = '') None#
Parses a binary file to fill this instance.
- ParseFromString(self, data: bytes, options: object | None = None) None#
- ParseFromString(self, data: str, options: object | None = None) None
Overloaded function.
ParseFromString(self, data: bytes, options: object | None = None) -> None
Parses a sequence of bytes to fill this instance.
ParseFromString(self, data: str, options: object | None = None) -> None
Parses a string to fill this instance.
- SerializeSize(self, options: object | None = None) onnx_light.onnx_py._onnxpyprotoop.SerializeSizeResult#
Returns the size once serialized without serializing.
- SerializeToFile(self, name: str, options: object | None = None, external_data_file: str = '') None#
Serializes this instance into a file. Standalone messages require single-file ONNX output. If
external_data_fileis not empty, big weights are stored in this (depending onoptions.raw_data_threshold). When writing to two files, temporary external-data metadata is cleared so the model’s values and metadata stay unchanged. Borrowed buffers not proven independent of files are first snapshotted in the source, even if a later write fails; their addresses and ownership may change.
- SerializeToFileDescriptor(self, fd: int, options: object | None = None) None#
Serializes this instance into an open file descriptor without closing it.
- SerializeToOStream(self, output: object) None#
Alias for SerializeToOstream (capital S) for protobuf API compatibility. Serializes this instance to a Python file-like object that has a write() method.
- SerializeToOstream(self, output: object) None#
Serializes this instance to a Python file-like object that has a write() method.
- SerializeToString(self, options: object | None = None) bytes#
Serializes this instance into a sequence of bytes.
- add_decode(self) onnx_light.onnx_py._onnxpyprotoop.ModelProto#
Sets an empty value.
- add_embedding(self) onnx_light.onnx_py._onnxpyprotoop.ModelProto#
Sets an empty value.
- add_prefill(self) onnx_light.onnx_py._onnxpyprotoop.ModelProto#
Sets an empty value.
- property attention_mask_name#
Name of the optional attention-mask input.
- property decode#
Optional model processing one generated token and updated decode state.
- property doc_string#
Human-readable pipeline documentation. Markdown is allowed.
- property domain#
Reverse-domain namespace qualifying the pipeline.
- property embedding#
Optional model mapping token IDs to embeddings.
- property eos_token_ids#
Tokens that terminate generation; an empty list disables EOS stopping.
- property input_ids_name#
Name of the token ID input.
- property logits_name#
Name of the logits output.
- property max_new_tokens#
Maximum number of tokens generated after the prompt.
- property metadata_props#
Named metadata values; keys must be distinct.
- property name#
Human-readable pipeline name.
- property pad_token_id#
Token emitted for already-finished batch rows.
- property pipeline_version#
Version of the pipeline definition.
- property position_ids_name#
Name of the optional position-ID input.
- property prefill#
Required model processing the prompt and producing logits or decode state.
- property producer_name#
Name of the framework or tool that produced the pipeline.
- property producer_version#
Version of the framework or tool that produced the pipeline.
- property seed#
Optional nonnegative random seed.
- property temperature#
Sampling temperature. Zero selects greedy decoding.
- property top_k#
Number of highest-scoring tokens retained before sampling. Zero disables top-k.
- property top_p#
Cumulative probability retained for nucleus sampling, in the interval (0, 1].
PipelineProto bundles the ONNX models used by a text-generation pipeline.
prefill is required; embedding and decode are optional. Tensor
interfaces and token-generation settings are stored directly on the pipeline.
A value transferred between two models must have the same name on the source
output and target input; the pipeline does not contain a connection or
renaming graph.
Native generation#
The C++ Generate overload runs prefill for the prompt, then decode
for each subsequent token when supplied. Without decode, the prefill model
continues to run as before. A separate decode graph receives one token per row,
the complete growing attention mask, and the current position IDs. An optional
embedding graph runs before either language-model stage. Sampling, EOS, padding
and step observation use the same generation loop.
Both language-model interfaces are checked before execution, even when zero tokens are requested. They must agree on generated input names, element types and ranks, logits metadata, and persistent input/output binding names and types. Fixed dimensions must agree; missing shapes and symbolic or unspecified dimensions are wildcards, not equations between separately exported models. Sequence dimensions may be specialized for the prompt versus single-token decode; cache feature dimensions and vocabulary dimensions must remain compatible. Persistent state is carried by transferring retained buffers and their append capacity, without copying cache payloads to change models. Both persistent binding sets may also be empty; an explicit decode graph still receives only one token per row. Each generation call starts with fresh state; generation is not resumable across calls.
LoadedRuntimePipeline loads and prepares every stage once, then shares its
static preparation store with fresh generation sessions across calls. Initializer
payloads are currently model-local: equal inline weights or equal external-data
ranges in different models are loaded separately, and static preparations are
keyed by model identity rather than deduplicated across stages. Budget for both
sets of weights and preparations. Within each stage, directly readable weights
remain borrowed views and the owning loader reuses preparations across calls.
The default binary file extensions are .pipe-onnx and .pipeline.
onnx_light.onnx.save(pipeline, path) saves the container, and
onnx_light.onnx.load(path) selects PipelineProto for either extension.
Other extensions and bytes inputs continue to select ModelProto.
See Builds, saves, and runs a small generation pipeline for a self-contained example covering construction, validation, binary serialization, and deterministic generation from the reloaded models, including the current Python execution limitations.