pub enum LayerCachePolicy {
NoState,
KeyValue {
attention: AttentionPolicy,
num_key_value_heads: NonZeroU32,
head_dim: NonZeroU32,
},
KeyOnly {
attention: AttentionPolicy,
num_key_heads: NonZeroU32,
head_dim: NonZeroU32,
},
CompressedLatentRotary {
attention: AttentionPolicy,
latent_dim: NonZeroU32,
rotary_dim: NonZeroU32,
},
FixedState {
tensors: Vec<StateTensorPolicy>,
},
KeyValueWithFixedState {
attention: AttentionPolicy,
num_key_value_heads: NonZeroU32,
head_dim: NonZeroU32,
tensors: Vec<StateTensorPolicy>,
},
KeyOnlyWithFixedState {
attention: AttentionPolicy,
num_key_heads: NonZeroU32,
head_dim: NonZeroU32,
tensors: Vec<StateTensorPolicy>,
},
}Expand description
Exact state kind, attention policy, and tensor geometry for one decoder layer.
Variants§
NoState
This layer contributes no independently persisted state.
KeyValue
Ordinary attention keys and values.
Fields
attention: AttentionPolicyExact full or sliding attention range.
num_key_value_heads: NonZeroU32Rank-local key/value head count.
head_dim: NonZeroU32Per-head key/value dimension.
KeyOnly
Attention history whose value payload is intentionally empty.
Fields
attention: AttentionPolicyExact full or sliding attention range.
num_key_heads: NonZeroU32Rank-local key head count.
head_dim: NonZeroU32Per-head key dimension.
CompressedLatentRotary
Compressed latent state plus rotary keys.
Fields
attention: AttentionPolicyExact full or sliding attention range.
latent_dim: NonZeroU32Compressed latent width.
rotary_dim: NonZeroU32Rotary-key width.
FixedState
Fixed-size recurrent or convolution state without attention.
Fields
tensors: Vec<StateTensorPolicy>Ordered tensors required to resume this layer.
KeyValueWithFixedState
Ordinary attention plus fixed-size state.
Fields
attention: AttentionPolicyExact full or sliding attention range.
num_key_value_heads: NonZeroU32Rank-local key/value head count.
head_dim: NonZeroU32Per-head key/value dimension.
tensors: Vec<StateTensorPolicy>Ordered additional tensors.
KeyOnlyWithFixedState
Key-only attention plus fixed-size state.
Fields
attention: AttentionPolicyExact full or sliding attention range.
num_key_heads: NonZeroU32Rank-local key head count.
head_dim: NonZeroU32Per-head key dimension.
tensors: Vec<StateTensorPolicy>Ordered additional tensors.
Implementations§
Source§impl LayerCachePolicy
impl LayerCachePolicy
Sourcepub const fn attention_residency_class(&self) -> Option<StateResidencyClass>
pub const fn attention_residency_class(&self) -> Option<StateResidencyClass>
Returns the residency behavior of this layer’s attention payload.
Sourcepub fn key_value(
attention: AttentionPolicy,
num_key_value_heads: i32,
head_dim: i32,
) -> Result<Self, CachePolicyError>
pub fn key_value( attention: AttentionPolicy, num_key_value_heads: i32, head_dim: i32, ) -> Result<Self, CachePolicyError>
Constructs validated ordinary key/value state geometry.
Sourcepub fn key_only(
attention: AttentionPolicy,
num_key_heads: i32,
head_dim: i32,
) -> Result<Self, CachePolicyError>
pub fn key_only( attention: AttentionPolicy, num_key_heads: i32, head_dim: i32, ) -> Result<Self, CachePolicyError>
Constructs validated key-only state geometry.
Sourcepub fn compressed_latent_rotary(
attention: AttentionPolicy,
latent_dim: i32,
rotary_dim: i32,
) -> Result<Self, CachePolicyError>
pub fn compressed_latent_rotary( attention: AttentionPolicy, latent_dim: i32, rotary_dim: i32, ) -> Result<Self, CachePolicyError>
Constructs validated compressed-latent state geometry.
Sourcepub fn fixed_only(
tensors: Vec<StateTensorPolicy>,
) -> Result<Self, CachePolicyError>
pub fn fixed_only( tensors: Vec<StateTensorPolicy>, ) -> Result<Self, CachePolicyError>
Constructs a validated fixed-state-only policy.
Sourcepub fn key_value_with_fixed_state(
attention: AttentionPolicy,
num_key_value_heads: i32,
head_dim: i32,
tensors: Vec<StateTensorPolicy>,
) -> Result<Self, CachePolicyError>
pub fn key_value_with_fixed_state( attention: AttentionPolicy, num_key_value_heads: i32, head_dim: i32, tensors: Vec<StateTensorPolicy>, ) -> Result<Self, CachePolicyError>
Constructs validated key/value plus fixed-state geometry.
Sourcepub fn key_only_with_fixed_state(
attention: AttentionPolicy,
num_key_heads: i32,
head_dim: i32,
tensors: Vec<StateTensorPolicy>,
) -> Result<Self, CachePolicyError>
pub fn key_only_with_fixed_state( attention: AttentionPolicy, num_key_heads: i32, head_dim: i32, tensors: Vec<StateTensorPolicy>, ) -> Result<Self, CachePolicyError>
Constructs validated key-only plus fixed-state geometry.
Sourcepub const fn attention(&self) -> Option<AttentionPolicy>
pub const fn attention(&self) -> Option<AttentionPolicy>
Returns the exact attention policy when present.
Sourcepub fn fixed_state(&self) -> &[StateTensorPolicy]
pub fn fixed_state(&self) -> &[StateTensorPolicy]
Returns ordered non-attention tensor policies.
Sourcepub fn components(&self) -> Vec<StateComponentPolicy>
pub fn components(&self) -> Vec<StateComponentPolicy>
Expands this layer policy into ordered, stably named semantic components shared by runtime residency and prompt persistence.
Sourcepub fn validate(&self) -> Result<(), CachePolicyError>
pub fn validate(&self) -> Result<(), CachePolicyError>
Validates dimensions and fixed-state invariants after deserialization.
Trait Implementations§
Source§impl Clone for LayerCachePolicy
impl Clone for LayerCachePolicy
Source§fn clone(&self) -> LayerCachePolicy
fn clone(&self) -> LayerCachePolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more