MCPcopy Create free account
hub / github.com/evilsocket/cake / forward

Method forward

cake-core/src/utils/fp8.rs:232–243  ·  view source on GitHub ↗

Forward pass: dequantizes weight if needed, computes matmul in weight dtype. The cached weight is already transposed and contiguous for optimal matmul.

(&self, x: &candle_core::Tensor)

Source from the content-addressed store, hash-verified

230 /// Forward pass: dequantizes weight if needed, computes matmul in weight dtype.
231 /// The cached weight is already transposed and contiguous for optimal matmul.
232 pub fn forward(&self, x: &candle_core::Tensor) -> candle_core::Result<candle_core::Tensor> {
233 let in_dtype = x.dtype();
234 let wt = self.get_weight()?; // pre-transposed
235 let compute = wt.dtype();
236 let x = if x.dtype() == compute { x.clone() } else { x.to_dtype(compute)? };
237 let y = x.broadcast_matmul(&wt)?;
238 let y = match &self.bias {
239 Some(b) => y.broadcast_add(&b.to_dtype(compute)?)?,
240 None => y,
241 };
242 if in_dtype == compute { Ok(y) } else { y.to_dtype(in_dtype) }
243 }
244}
245
246/// Create an Fp8Linear from a VarBuilder (no bias).

Callers 15

fp8_linear_forwardFunction · 0.45
flux2_pos_embedFunction · 0.45
fp8_linear_flux1_qkvFunction · 0.45
fp8_linear_flux1_mlpFunction · 0.45
attention_forwardFunction · 0.45
attention_with_qk_normFunction · 0.45
attention_sliding_windowFunction · 0.45
fp8_linear_forward_cpuFunction · 0.45
qwen3_moe_forwardFunction · 0.45
qwen3_5_moe_forwardFunction · 0.45

Calls 3

dtypeMethod · 0.80
get_weightMethod · 0.80
cloneMethod · 0.45