veloxquant_mlx.artifacts.base module

Re-exports the ArtifactStore ABC for the artifacts subpackage.

Lets callers write from veloxquant_mlx.artifacts.base import ArtifactStore alongside the concrete backends in this package instead of reaching into core.abstractions directly.

class veloxquant_mlx.artifacts.base.ArtifactStore[source]

Bases: ABC

DAO interface for loading and saving precomputed quantization artifacts.

abstractmethod load_rotation_matrix(d, seed)[source]

Load a precomputed rotation matrix.

Parameters:
  • d (int) – Matrix dimension.

  • seed (int) – Random seed used to generate the matrix.

Return type:

Any

Returns:

MLX array of shape (d, d), fp16.

Raises:

ArtifactNotFoundError – If the artifact does not exist.

abstractmethod save_rotation_matrix(Pi, d, seed)[source]

Persist a rotation matrix.

Parameters:
  • Pi (Any) – Array of shape (d, d).

  • d (int) – Dimension.

  • seed (int) – Seed used to generate Pi.

Return type:

None

abstractmethod load_codebook(distribution, b, d)[source]

Load a precomputed codebook.

Parameters:
  • distribution (str) – Distribution name (e.g. ‘gaussian’, ‘beta’).

  • b (int) – Bit-width.

  • d (int) – Vector dimension.

Return type:

Any

Returns:

MLX array of shape (2^b,), fp16.

Raises:

ArtifactNotFoundError – If the artifact does not exist.

abstractmethod save_codebook(cb, distribution, b, d)[source]

Persist a codebook.

Parameters:
  • cb (Any) – Codebook centroids array.

  • distribution (str) – Distribution name.

  • b (int) – Bit-width.

  • d (int) – Dimension.

Return type:

None

abstractmethod load_jl_matrix(d, m, seed)[source]

Load a precomputed JL projection matrix.

Parameters:
  • d (int) – Input dimension.

  • m (int) – Output (sketch) dimension.

  • seed (int) – Random seed.

Return type:

Any

Returns:

MLX array of shape (m, d), fp16.

Raises:

ArtifactNotFoundError – If the artifact does not exist.

abstractmethod save_jl_matrix(S, d, m, seed)[source]

Persist a JL projection matrix.

Parameters:
  • S (Any) – Array of shape (m, d).

  • d (int) – Input dimension.

  • m (int) – Output dimension.

  • seed (int) – Seed.

Return type:

None

abstractmethod exists(artifact_type, **kwargs)[source]

Check whether a specific artifact exists in the store.

Parameters:
  • artifact_type (str) – One of ‘rotation’, ‘codebook’, ‘jl’.

  • **kwargs (Any) – Identifying parameters (d, seed, b, distribution, m).

Return type:

bool

Returns:

True if the artifact is present and loadable.