Artifact IO

class torch_lattice.artifact.io.LatticeArtifactSaveResult(artifact_dir, graph_path, weights_path, weight_keys)[source]

Bases: object

Paths and weight keys written for one lattice artifact.

Parameters:
artifact_dir: Path
graph_path: Path
weights_path: Path
weight_keys: tuple[str, ...]
exception torch_lattice.artifact.io.LatticeModelArtifactError[source]

Bases: ValueError

Raised when a Torch model cannot form a valid lattice artifact.

class torch_lattice.artifact.io.LatticeModelArtifactOptions(input_dtype=None, batch_size=None, clean=True, validate=True, quantize_bits=None, quantize_group_size=32, quantize_scale_dtype='f16')[source]

Bases: object

Options for producing a portable lattice MLIR artifact.

Parameters:
  • input_dtype (str | None)

  • batch_size (int | None)

  • clean (bool)

  • validate (bool)

  • quantize_bits (int | None)

  • quantize_group_size (int)

  • quantize_scale_dtype (str)

input_dtype: str | None
batch_size: int | None
clean: bool
validate: bool
quantize_bits: int | None
quantize_group_size: int
quantize_scale_dtype: str
torch_lattice.artifact.io.save_lattice_model_artifact(model, artifact_dir, *, example_inputs, options=None, output_names=None)[source]

Export an eval-mode Torch model as MLIR plus safetensors.

example_inputs defines the public artifact ABI. Sparse inputs become coordinate, feature, and active-row argument groups; dense tensors retain their rank, dtype, and static non-leading dimensions.

Return type:

LatticeArtifactSaveResult

Parameters: