Skip to main content

Crate memra_reference

Crate memra_reference 

Source
Expand description

Portable, deliberately unfused executor for canonical ModelPlan operations.

This crate is a correctness oracle, not a serving backend. It has no CUDA dependency and no external engine fallback. Unsupported canonical operations return a named error.

Modules§

hidden_trace
Env-gated hidden-state trace, shared by the reference executor and the CUDA trunk.

Structs§

ReferenceDraftOutput
ReferenceFixture
ReferenceMtpOutput
ReferenceMultimodalOutput
ReferenceOutput
ReferenceState
ReferenceTensor
ReferenceVisionInput
ReferenceVisionOutput
StreamedTrunkExecution
Layer-at-a-time trunk execution over the exact per-layer math of execute, for checkpoint-scale runs where all weights cannot be resident at once. The driver materializes only the current layer’s tensors, calls StreamedTrunkExecution::step, and frees them before the next layer.

Enums§

ReferenceError
ReferenceLayerState

Functions§

deterministic_fixture
execute
execute_mtp_standalone
Execute ONLY the MTP draft arm on CALLER-PROVIDED trunk wide states — the real-checkpoint draft-parity instrument (mtp-spec lane): the full-trunk host reference cannot hold the 360 GB artifact, but the MTP block’s rows fit host f32, so the engine’s captured trunk wide state feeds this host twin and the draft programs are compared row for row. trunk_hidden is [tokens, streams*hidden] (gated-residual plans) or [tokens, hidden]; row i seeds token_ids[i] — the same pairing execute uses internally.
execute_multimodal
execute_vision
kimi_delta_net_layer
Kimi Delta Attention (recurrent_kimi_delta_attention + Glm5NextTextLinearAttention), all f32, sequential over tokens. Only the lower-bound forget-gate branch exists: GLM-5.3-Flash always configures gate_lower_bound, so the softplus branch of Glm5NextTextForgetGate is dead for this model and deliberately not implemented. GPU-parity seam: run ONE KDA layer’s mixer over x ([tokens, hidden], already pre-attention-normed) and return its output plus the recurrent state it leaves behind.
kpool_allowed_tokens
K-pool compressed indexer selection (Glm5NextTextIndexer.forward), single-sequence causal case: every token is a valid key, so pooling starts at index 0 and only causality masks candidates. Returns the allowed source-token set per query, sorted ascending.

Type Aliases§

ReferenceWeights