pub trait LayerWeightSetup {
// Provided methods
fn as_any_mut(&mut self) -> Option<&mut dyn Any> { ... }
fn transpose_moe_for_prefill(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()> { ... }
fn transpose_moe_gate_up_for_prefill(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()> { ... }
fn set_moe_down_transpose_scratch(
&mut self,
_scratch_packed: DevicePtr,
_scratch_scale: DevicePtr,
_packed_ptrs_t: DevicePtr,
_scale_ptrs_t: DevicePtr,
) { ... }
fn transpose_moe_for_prefill_unified(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()> { ... }
fn transpose_moe_for_prefill_hybrid(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()> { ... }
}Expand description
2026-09-26: A supertrait of TransformerLayer; see the module header.
Provided Methods§
Sourcefn as_any_mut(&mut self) -> Option<&mut dyn Any>
fn as_any_mut(&mut self) -> Option<&mut dyn Any>
2026-09-25: &mut dyn Any downcast hook for weight overlays applied after
construction, such as a LoRA install. Default None.
Sourcefn transpose_moe_for_prefill(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()>
fn transpose_moe_for_prefill( &mut self, _gpu: &dyn GpuBackend, _config: &ModelConfig, ) -> Result<()>
2026-09-25: Build persistent transposed gate/up/down MoE expert weights for the
prefill GEMMs. The factory’s MoE transpose pass (factory/m2_setup.rs) calls it,
outside the hybrid and unified layouts, when free memory covers the full transpose
plus a safety margin. Default: nothing.
Sourcefn transpose_moe_gate_up_for_prefill(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()>
fn transpose_moe_gate_up_for_prefill( &mut self, _gpu: &dyn GpuBackend, _config: &ModelConfig, ) -> Result<()>
2026-09-25: Like transpose_moe_for_prefill, for gate and up only. Outside the
hybrid and unified layouts, the transpose pass calls it when the full transpose does
not fit but gate and up do. Default: nothing.
Sourcefn set_moe_down_transpose_scratch(
&mut self,
_scratch_packed: DevicePtr,
_scratch_scale: DevicePtr,
_packed_ptrs_t: DevicePtr,
_scale_ptrs_t: DevicePtr,
)
fn set_moe_down_transpose_scratch( &mut self, _scratch_packed: DevicePtr, _scratch_scale: DevicePtr, _packed_ptrs_t: DevicePtr, _scale_ptrs_t: DevicePtr, )
2026-09-25: Give this layer’s MoE block the per-prefill down_proj transpose
scratch that every MoE layer shares, after transpose_moe_gate_up_for_prefill.
Default: nothing.
Sourcefn transpose_moe_for_prefill_unified(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()>
fn transpose_moe_for_prefill_unified( &mut self, _gpu: &dyn GpuBackend, _config: &ModelConfig, ) -> Result<()>
2026-09-25: Unified layout (METRALE_UNIFIED_MOE_LAYOUT=1): build transposed
gate/up/down and free the untransposed copies. Decode reads the transposed copies
when MoeLayer::use_t_layout_for_decode holds. Default: nothing.
Sourcefn transpose_moe_for_prefill_hybrid(
&mut self,
_gpu: &dyn GpuBackend,
_config: &ModelConfig,
) -> Result<()>
fn transpose_moe_for_prefill_hybrid( &mut self, _gpu: &dyn GpuBackend, _config: &ModelConfig, ) -> Result<()>
2026-09-25: Hybrid layout (METRALE_HYBRID_MOE_LAYOUT=1): build transposed
gate/up/down beside the originals and free nothing, so decode keeps the originals
and prefill uses the transposed copies. The transpose pass calls it only when twice
the full transpose fits. Default: nothing.