pub struct EngineSpec {
pub schema_version: u32,
pub engine: EngineConfig,
pub context_ops: Vec<OpSpec>,
pub generation_ops: Vec<OpSpec>,
}Expand description
Serializable compiled engine.
schema_version guards forward/backward compatibility; engine carries
the identity used to load the matching perf database; context_ops and
generation_ops are the precompiled op lists the runner iterates.
EngineSpec derives serde so JSON / other self-describing formats work
directly. The bincode wire format, however, must go through
EngineSpec::to_bincode / EngineSpec::from_bincode, NOT
bincode::serialize(&spec) directly: EngineConfig uses
#[serde(flatten)] (load-bearing for the flat ctypes FFI contract), and
bincode 1.x cannot serialize a flattened struct (it emits a map of unknown
length → SequenceMustHaveLength). The helpers sidestep this by
JSON-encoding the engine field inside the bincode payload, keeping
EngineConfig the single source of truth (no mirror struct, no drift).
Fields§
§schema_version: u32§engine: EngineConfigEngine identity (model / system / backend / parallelism / quant).
Needed to locate and load the PerfDatabase.
context_ops: Vec<OpSpec>Context-phase ops, in execution order. Never contains OpSpec::Vision
(decomposed into child ops at compile time).
generation_ops: Vec<OpSpec>Generation-phase ops, in execution order.
Implementations§
Source§impl EngineSpec
impl EngineSpec
Sourcepub fn new(
engine: EngineConfig,
context_ops: Vec<OpSpec>,
generation_ops: Vec<OpSpec>,
) -> Self
pub fn new( engine: EngineConfig, context_ops: Vec<OpSpec>, generation_ops: Vec<OpSpec>, ) -> Self
Build a spec, stamping the current ENGINE_SPEC_SCHEMA_VERSION.
Sourcepub fn to_bincode(&self) -> Result<Vec<u8>, AicError>
pub fn to_bincode(&self) -> Result<Vec<u8>, AicError>
Serialize to the bincode wire format. The engine field is
JSON-encoded inside the payload (see the struct docs) so bincode never
sees EngineConfig’s flattened layout.
Sourcepub fn from_bincode(bytes: &[u8]) -> Result<Self, AicError>
pub fn from_bincode(bytes: &[u8]) -> Result<Self, AicError>
Deserialize from the bincode wire format produced by Self::to_bincode.
The schema_version prefix is read and validated before the
variable-layout op payloads are decoded. bincode is not self-describing,
so a producer/consumer op-layout skew (e.g. a newer producer that added
serialized fields to an OpSpec) would otherwise fail deep inside the
payload with a generic bincode decode: io error, masking the real
cause. Reading the leading version first lets a version mismatch surface
as a clear AicError::UnsupportedSchemaVersion instead.
Trait Implementations§
Source§impl Clone for EngineSpec
impl Clone for EngineSpec
Source§fn clone(&self) -> EngineSpec
fn clone(&self) -> EngineSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more