pub enum FfnComponent {
Moe(MoeLayer),
Dense(DenseFfnLayer),
None,
}Expand description
2026-09-25: A layer’s FFN: MoE, dense, or none.
Variants§
Moe(MoeLayer)
Dense(DenseFfnLayer)
None
2026-09-25: No FFN: forward returns its input and the other passes launch nothing.
Implementations§
Source§impl FfnComponent
impl FfnComponent
Sourcepub fn nvfp4_grouped_ok(&self, m: usize, ctx: &ForwardContext<'_>) -> bool
pub fn nvfp4_grouped_ok(&self, m: usize, ctx: &ForwardContext<'_>) -> bool
2026-09-27: Whether this is a MoE whose grouped NVFP4 decode serves m rows
(MoeLayer::nvfp4_grouped_decode_ok).
Sourcepub fn forward_nvfp4_grouped(
&self,
input: DevicePtr,
m: usize,
ctx: &ForwardContext<'_>,
stream: u64,
) -> Result<()>
pub fn forward_nvfp4_grouped( &self, input: DevicePtr, m: usize, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
2026-09-27: The grouped NVFP4 MoE decode over [m, H] rows into moe_output().
Errors for dense and none; callers gate on Self::nvfp4_grouped_ok first.
Source§impl FfnComponent
impl FfnComponent
pub fn is_none(&self) -> bool
pub fn is_dense(&self) -> bool
Sourcepub fn moe_grouped_decode_ok(&self) -> bool
pub fn moe_grouped_decode_ok(&self) -> bool
2026-09-25: Whether this is a MoE whose MoeLayer::grouped_decode_ok holds,
so multi-sequence decode may route it through forward_prefill
(qwen3_attention/trait_impl/multi_seq/ffn.rs). False for dense and none.
Sourcepub fn fp32_routing_active(&self, levers: &ModelLevers) -> bool
pub fn fp32_routing_active(&self, levers: &ModelLevers) -> bool
2026-09-25: MoeLayer::fp32_routing_active for a MoE; false otherwise.
pub fn forward( &self, input: DevicePtr, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<DevicePtr>
pub fn forward_k2( &self, input: DevicePtr, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
pub fn forward_k3( &self, input: DevicePtr, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
Sourcepub fn dense_fixed_ok(&self, m: usize, ctx: &ForwardContext<'_>) -> bool
pub fn dense_fixed_ok(&self, m: usize, ctx: &ForwardContext<'_>) -> bool
2026-09-30: Whether this is a dense FFN that runs m rows under a fixed
--activation-quantization (DenseFfnLayer::fixed_ok). False for MoE and none.
Sourcepub fn forward_dense_fixed(
&self,
input: DevicePtr,
m: usize,
ctx: &ForwardContext<'_>,
stream: u64,
) -> Result<()>
pub fn forward_dense_fixed( &self, input: DevicePtr, m: usize, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
2026-09-30: DenseFfnLayer::forward_fixed over m rows into moe_output; call only
when dense_fixed_ok(m) holds.
Sourcepub fn can_forward_km(&self, m: u32) -> bool
pub fn can_forward_km(&self, m: u32) -> bool
2026-09-25: Whether this is a dense FFN whose
DenseFfnLayer::can_forward_km(m) holds: a batched-GEMV tier serves m
rows and NVFP4 or FP8 weights are loaded. False for MoE and none.
Multi-sequence attention decode (qwen3_attention/trait_impl/multi_seq/ffn.rs)
asks before computing the pre-FFN norm.
Sourcepub fn narrow_rows(&self) -> u32
pub fn narrow_rows(&self) -> u32
2026-09-28: Row edge of a dense FFN’s narrow decode arms (DenseFfnLayer::narrow_rows:
its W4A4 edge under the weight-quantization tier, capped at 32, else the W4A16 edge).
MoE and none answer the W4A16 edge; can_forward_km is false for them anyway.
Sourcepub fn try_forward_km(
&self,
input: DevicePtr,
m: u32,
ctx: &ForwardContext<'_>,
stream: u64,
) -> Result<bool>
pub fn try_forward_km( &self, input: DevicePtr, m: u32, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<bool>
2026-09-25: DenseFfnLayer::forward_km over m rows. Returns Ok(false)
without launching when can_forward_km(m) is false.
pub fn forward_prefill( &self, input: DevicePtr, num_tokens: usize, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
pub fn forward_batched( &self, input: DevicePtr, num_tokens: usize, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
pub fn forward_token_major_decode( &self, input: DevicePtr, num_tokens: usize, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
pub fn forward_atomic_c4_decode( &self, input: DevicePtr, num_tokens: usize, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
Sourcepub fn fp8_grouped_decode_ok(&self, m: usize, ctx: &ForwardContext<'_>) -> bool
pub fn fp8_grouped_decode_ok(&self, m: usize, ctx: &ForwardContext<'_>) -> bool
2026-09-25: Whether the target model’s cross-row grouped FP8 MoE decode
serves m rows: ModelLevers::moe_fp8_grouped_decode_target
(METRALE_FP8_MOE_GROUPED_DECODE) is on and this is a MoE whose
MoeLayer::fp8_grouped_decode_ok(m) holds. The MTP drafter calls
MoeLayer::fp8_grouped_decode_ok directly, without the lever.
Sourcepub fn fp8_grouped_routing_ok(
&self,
m: usize,
routing: GroupedRouting,
ctx: &ForwardContext<'_>,
) -> bool
pub fn fp8_grouped_routing_ok( &self, m: usize, routing: GroupedRouting, ctx: &ForwardContext<'_>, ) -> bool
2026-09-26: Whether this is a MoE whose grouped FP8 decode serves m
rows with routing (MoeLayer::fp8_grouped_routing_ok). Unlike
Self::fp8_grouped_decode_ok it does not read the
moe_fp8_grouped_decode_target lever: the exact routings reproduce the
path they replace byte for byte, so they need no opt-in.
Sourcepub fn forward_fp8_grouped_decode_routed(
&self,
input: DevicePtr,
m: usize,
routing: GroupedRouting,
ctx: &ForwardContext<'_>,
stream: u64,
) -> Result<()>
pub fn forward_fp8_grouped_decode_routed( &self, input: DevicePtr, m: usize, routing: GroupedRouting, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
2026-09-26: Self::forward_fp8_grouped_decode with routing. Errors
for dense and none; callers gate on fp8_grouped_routing_ok first.
Sourcepub fn forward_fp8_grouped_decode(
&self,
input: DevicePtr,
m: usize,
ctx: &ForwardContext<'_>,
stream: u64,
) -> Result<()>
pub fn forward_fp8_grouped_decode( &self, input: DevicePtr, m: usize, ctx: &ForwardContext<'_>, stream: u64, ) -> Result<()>
2026-09-25: Cross-row grouped FP8 MoE decode over [m, H] rows into
moe_output(). Errors for dense and none; callers gate on
fp8_grouped_decode_ok first.