File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,9 @@ public VBLoRAAdapter(
311311 {
312312 _bankIndicesB = GenerateRandomIndices ( rank , bankSizeB ) ;
313313 }
314+
315+ // Now that banks + indices are initialized, sync the underlying LoRA layer to the selected vectors.
316+ UpdateLoRALayerFromBanks ( _loraLayer ) ;
314317 }
315318
316319 /// <summary>
@@ -406,16 +409,13 @@ private int[] GenerateRandomIndices(int count, int maxValue)
406409 /// </remarks>
407410 protected override LoRALayer < T > CreateLoRALayer ( int rank , double alpha )
408411 {
409- // Create a standard LoRA layer - we'll override its matrices with bank-selected vectors
410412 int inputSize = GetInputShape ( ) [ 0 ] ;
411413 int outputSize = GetOutputShape ( ) [ 0 ] ;
412414
413- LoRALayer < T > loraLayer = new LoRALayer < T > ( inputSize , outputSize , rank , alpha ) ;
414-
415- // Replace the LoRA layer's matrices with bank-selected vectors
416- UpdateLoRALayerFromBanks ( loraLayer ) ;
417-
418- return loraLayer ;
415+ // Important: this virtual is invoked from the base constructor, before VB-LoRA banks/indices are initialized.
416+ // We therefore only construct a standard LoRA layer here and let the derived constructor/Forward() synchronize
417+ // it with the vector banks once initialization is complete.
418+ return new LoRALayer < T > ( inputSize , outputSize , rank , alpha ) ;
419419 }
420420
421421 /// <summary>
You can’t perform that action at this time.
0 commit comments