
LoRA forward with alpha/r scaling (Kamath Ch 4)
Source:R/kamath_llm2_native.R
morie_kamath_lora_weight_update.Rdh = W0 x + (alpha/r) B A x. km058's Eq 4.5 has no scaling; this named module carries the implementation's alpha/r, so the two stay separate.
Examples
morie_kamath_lora_weight_update(diag(2), matrix(c(1, 1), 1),
matrix(c(2, 0), 2), 4, 1, c(1, 3))
#> $h
#> [1] 33 3
#>
#> $base
#> [1] 1 3
#>
#> $delta
#> [1] 32 0
#>
#> $estimate
#> [1] 33
#>
#> $scaling
#> [1] 4
#>
#> $rank
#> [1] 1
#>
#> $alpha
#> [1] 4
#>
#> $n_trainable
#> [1] 4
#>
#> $n_frozen
#> [1] 4
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "LoRA forward h = W0 x + (alpha/r) B A x"
#>