Skip to main content

Crate apr_format

Crate apr_format 

Source
Expand description

§apr-format — sovereign .apr model container format

Minimal, dependency-light read/write for the .apr model container (v1 APRN + v2 APR\0), extracted from aprender-core so that downstream consumers (realizar inference, xpile, external tooling) can read and write .apr files without pulling the full ML/GPU/tokenizer/quantization stack. See issue #2231 — “depend on the format, not the framework.”

§Status: Stage 1 foundation + cut-feasibility spike

This crate currently ships:

  • The sovereign error seam (error::AprFormatError, wrapped by aprender-core via impl From).
  • The single deduplicated crc32::crc32 and [f16] conversions.
  • A representative v1 (APRN) slice — types (header/metadata/flags) and core_io (save/load) — proving the error-seam compiles at a crate boundary.
  • The byte-only structural validator split (validate), demonstrating the Structure-vs-Physics separation.

The bulk git-mv of the rest of format/ (v2 container, mmap, spec, …) lands in Stage 2.

§Locked design decisions (issue #2231)

  1. The GGUF/SafeTensors/ONNX converter stays in aprender-core (it needs f32 physics + the ML stack); only the container moves.
  2. std-only for v1 (no no_std yet — the std surface is kept thin).
  3. Wrapper error seam: the leaf owns AprFormatError; core From-wraps it.
  4. mmap is feature-gated (mmap feature, off by default).

Re-exports§

pub use core_io::inspect;
pub use core_io::inspect_bytes;
pub use core_io::load;
pub use core_io::load_auto;
pub use core_io::load_from_bytes;
pub use core_io::load_mmap;
pub use core_io::save;
pub use core_io::MMAP_THRESHOLD;
pub use crc32::crc32;
pub use error::AprFormatError;
pub use error::Result;
pub use f16::f16_to_f32;
pub use f16::f32_to_f16;
pub use model_card::ModelCard;
pub use model_card::TrainingDataInfo;
pub use types::Compression;
pub use types::DistillMethod;
pub use types::DistillationInfo;
pub use types::DistillationParams;
pub use types::Flags;
pub use types::Header;
pub use types::LayerMapping;
pub use types::LicenseInfo;
pub use types::LicenseTier;
pub use types::Metadata;
pub use types::ModelInfo;
pub use types::ModelType;
pub use types::SaveOptions;
pub use types::TeacherProvenance;
pub use types::TrainingInfo;
pub use types::FORMAT_VERSION;
pub use types::HEADER_SIZE;
pub use types::MAGIC;
pub use types::MAX_UNCOMPRESSED_SIZE;
pub use validate::validate_structure;
pub use validate::StructureCheck;

Modules§

core_io
v1 (APRN) core I/O — spike slice for issue #2231 Stage 1.
crc32
Single, deduplicated CRC32 implementation for the .apr container.
error
Error type for the sovereign apr-format leaf crate.
f16
IEEE-754 half-precision (f16) conversion, delegating to the half crate.
falsifiers
GREEN contract falsifiers for the apr-format extraction (issue #2231).
model_card
Model Card for .apr format (spec §11)
types
v1 (APRN) container type definitions — sovereign leaf (issue #2231).
v2
APR Format Module (v2 APR\0) — sovereign leaf (issue #2231)
validate
Structural validation — the Structure-category half of the validator split (issue #2231 Stage 1 spike, part b).