class_docstr: ### LoRA weights
  Wq = Wq + Aq @ Bq
  Wk = Wk + Ak @ Bk
  Wv = Wv + Av @ Bv
  Q = X @ Wq = X @ Wq + X @ Aq @ Bq
  K = X @ Wk = X @ Wk + X @ Ak @ Bk
  V = X @ Wv = X @ Wv + X @ Av @ Bv
  
  ### Backpropagation chain rule
  dC/dWq = X.T @ D(Wq)
  dC/dWk = X.T @ D(Wk)
  dC/dWv = X.T @ D(Wv)
  
  ### Q projection LoRA weights
  dC/dAq =       X.T @ D(Wq) @ B.T
  dC/dBq = A.T @ X.T @ D(Wq)
  
  ### K projection LoRA weights
  dC/dAk =       X.T @ D(Wk) @ B.T
  dC/dBk = A.T @ X.T @ D(Wk)
  
  ### V projection LoRA weights
  dC/dAv =       X.T @ D(Wv) @ B.T
  dC/dBv = A.T @ X.T @ D(Wv)
class_docstr_tok: ["#","#","#","LoRA","weights","Wq","=","Wq","+","Aq","@","Bq","Wk","=","Wk","+","Ak","@","Bk","Wv","=","Wv","+","Av","@","Bv","Q","=","X","@","Wq","=","X","@","Wq","+","X","@","Aq","@","Bq","K","=","X","@","Wk","=","X","@","Wk","+","X","@","Ak","@","Bk","V","=","X","@","Wv","=","X","@","Wv","+","X","@","Av","@","Bv","#","#","#","Backpropagation","chain","rule","dC\/dWq","=","X.T","@","D","(","Wq",")","dC\/dWk","=","X.T","@","D","(","Wk",")","dC\/dWv","=","X.T","@","D","(","Wv",")","#","#","#","Q","projection","LoRA","weights","dC\/dAq","=","X.T","@","D","(","Wq",")","@","B.T","dC\/dBq","=","A.T","@","X.T","@","D","(","Wq",")","#","#","#","K","projection","LoRA","weights","dC\/dAk","=","X.T","@","D","(","Wk",")","@","B.T","dC\/dBk","=","A.T","@","X.T","@","D","(","Wk",")","#","#","#","V","projection","LoRA","weights","dC\/dAv","=","X.T","@","D","(","Wv",")","@","B.T","dC\/dBv","=","A.T","@","X.T","@","D","(","Wv",")"]
code: def forward(ctx, X: torch.Tensor, W, W_quant, A, B, S):
      dtype = X.dtype
      XW = matmul_lora(X, W, W_quant, A, B, S)
      ctx.custom_saved_tensors = (
          W,
          W_quant,
          S,
      )
      ctx.save_for_backward(A, B, X)
      return XW
  
file_path: unsloth/unsloth/kernels/fast_lora.py
imports: import torch
  from .utils import fast_dequantize, QUANT_STATE
  from .swiglu import swiglu_fg_kernel, swiglu_DWf_DW_dfg_kernel
label_desc: Use image node_id 1 for calling the LoRA_W obj's underlying member method code with example usage: obj.forward(ctx, X, W, W_quant, A, B, S) and returns: XW