@@ -253,13 +253,16 @@ class TestEvo2LoRAWeightTyingValidation:
253253
254254 @pytest .mark .parametrize (
255255 "target_modules" ,
256- [["word_embeddings" ], ["output_layer" ]],
257- ids = ["word_embeddings_only" , "output_layer_only" ],
256+ [["word_embeddings" ], ["output_layer" ], [ "embedding.*" ], [ "output_*" ] ],
257+ ids = ["word_embeddings_only" , "output_layer_only" , "embedding_wildcard" , "output_wildcard" ],
258258 )
259259 def test_target_modules_one_side_raises_asymmetry_with_tying (self , wt_models , target_modules : list [str ]) -> None :
260260 """With weight tying, listing only one side of the tied pair raises our symmetry ValueError.
261261
262262 Evo2LoRA catches the asymmetry before handing off to Megatron Bridge.
263+ The wildcard cases verify the model-walk approach: ``embedding.*`` matches
264+ the real path ``embedding.word_embeddings`` and ``output_*`` matches
265+ ``output_layer``; neither would be detected by a synthetic-name check.
263266 """
264267 tied , _ = wt_models
265268 lora = Evo2LoRA (target_modules = target_modules , dim = 4 , alpha = 8 , dropout = 0.0 )
@@ -307,11 +310,16 @@ def test_target_modules_output_layer_accepted_without_tying(self, wt_models) ->
307310
308311 @pytest .mark .parametrize (
309312 "skip_freeze" ,
310- [["word_embeddings" ], ["output_layer" ]],
311- ids = ["word_embeddings_only" , "output_layer_only" ],
313+ [["word_embeddings" ], ["output_layer" ], [ "embedding.*" ], [ "output_*" ] ],
314+ ids = ["word_embeddings_only" , "output_layer_only" , "embedding_wildcard" , "output_wildcard" ],
312315 )
313316 def test_skip_freeze_one_side_raises_with_tying (self , wt_models , skip_freeze : list [str ]) -> None :
314- """Listing only one side of a tied pair in skip_freeze_modules must raise ValueError."""
317+ """Listing only one side of a tied pair in skip_freeze_modules must raise ValueError.
318+
319+ The wildcard cases verify the model-walk approach: ``embedding.*`` matches
320+ the real path ``embedding.word_embeddings`` and ``output_*`` matches
321+ ``output_layer``; neither would be detected by a synthetic-name check.
322+ """
315323 tied , _ = wt_models
316324 lora = Evo2LoRA (
317325 target_modules = _DEFAULT_LORA_TARGETS ,
@@ -517,19 +525,22 @@ def test_lora_checkpoint_excludes_frozen_embeddings(self, tmp_path: Path, base_c
517525 assert len (adapter_keys ) > 0 , "Checkpoint should still contain LoRA adapter keys."
518526
519527 @pytest .mark .parametrize (
520- "skip_module , expected_key_substr, lora_targets" ,
528+ "skip_freeze , expected_key_substr, lora_targets" ,
521529 [
522- ("word_embeddings" , "word_embeddings" , None ),
523- ("final_norm" , "final_norm" , None ),
524- ("dense" , "mixer.dense." , None ),
525- ("linear_fc2" , "mlp.linear_fc2." , ["dense_projection" , "linear_qkv" , "linear_proj" , "linear_fc1" ]),
530+ # word_embeddings and output_layer share a weight tensor when tying is enabled;
531+ # both must appear in skip_freeze to satisfy the symmetry contract.
532+ (["word_embeddings" , "output_layer" ], "word_embeddings" , None ),
533+ (["final_norm" ], "final_norm" , None ),
534+ (["dense" ], "mixer.dense." , None ),
535+ (["linear_fc2" ], "mlp.linear_fc2." , ["dense_projection" , "linear_qkv" , "linear_proj" , "linear_fc1" ]),
526536 ],
537+ ids = ["word_embeddings" , "final_norm" , "dense" , "linear_fc2" ],
527538 )
528539 def test_lora_skip_freeze_saves_and_trains_module (
529540 self ,
530541 tmp_path : Path ,
531542 base_ckpt : Path ,
532- skip_module : str ,
543+ skip_freeze : list [ str ] ,
533544 expected_key_substr : str ,
534545 lora_targets : list [str ] | None ,
535546 ):
@@ -538,12 +549,12 @@ def test_lora_skip_freeze_saves_and_trains_module(
538549
539550 from bionemo .evo2 .models .evo2_provider import hyena_forward_step
540551
541- lora_dir = tmp_path / f"lora_{ skip_module } "
552+ lora_dir = tmp_path / f"lora_{ skip_freeze [ 0 ] } "
542553 cfg = _build_pretrain_config (
543554 lora_dir ,
544555 train_iters = 1 ,
545556 lora = True ,
546- skip_freeze = [ skip_module ] ,
557+ skip_freeze = skip_freeze ,
547558 lora_target_modules = lora_targets ,
548559 pretrained_ckpt_dir = str (base_ckpt ),
549560 )
0 commit comments