Skip to main content

add_delta

Function add_delta 

Source
pub fn add_delta(base: &Tensor, correction: Tensor) -> Tensor
Expand description

Add a TTT/LoRA delta correction to a base activation, coercing the correction to the base tensor’s dtype first.

The base model may run in BF16 while the delta matrix is forced to fp32 (see runtime/ttn_profile.rs). Adding fp32 directly to a bf16 tensor panics in addmm_impl_cpu_ (“expected m1 and m2 to have the same dtype”).

This helper is the single place that performs the dtype coercion so the fix cannot be missed when a new architecture adds a delta-injection site. See #139 (original llama fix) and #440 (qwen3_5 regression).