EmergentTwilight/MMCoT / OURS /tests /test_shared_modeling.py
EmergentTwilight's picture
download
raw
2.13 kB
import unittest
from types import SimpleNamespace
from shared.modeling import validate_lora_adapter_config
class LoadedLoRAContractTest(unittest.TestCase):
@staticmethod
def expected():
return SimpleNamespace(
rank=32,
alpha=32,
dropout=0.0,
use_rslora=True,
targets=["q_proj", "v_proj"],
modules_to_save=["output_layer_vistok"],
)
@staticmethod
def actual():
return SimpleNamespace(
r=32,
lora_alpha=32,
lora_dropout=0.0,
use_rslora=True,
target_modules={"v_proj", "q_proj"},
modules_to_save=["output_layer_vistok"],
rank_pattern={},
alpha_pattern={},
peft_type="LORA",
task_type="CAUSAL_LM",
bias="none",
use_dora=False,
lora_bias=False,
)
def test_matching_loaded_adapter_is_accepted(self):
validate_lora_adapter_config(self.actual(), self.expected())
def test_loaded_adapter_mismatch_fails_closed(self):
fields = (
("r", 16, "rank"),
("lora_alpha", 64, "alpha"),
("lora_dropout", 0.1, "dropout"),
("use_rslora", False, "use_rslora"),
("target_modules", {"q_proj"}, "targets"),
("modules_to_save", [], "modules_to_save"),
("rank_pattern", {"q_proj": 8}, "rank_pattern"),
("alpha_pattern", {"q_proj": 8}, "alpha_pattern"),
("peft_type", "IA3", "peft_type"),
("task_type", "SEQ_CLS", "task_type"),
("bias", "all", "bias"),
("use_dora", True, "use_dora"),
("lora_bias", True, "lora_bias"),
)
for field, value, message in fields:
with self.subTest(field=field):
actual = self.actual()
setattr(actual, field, value)
with self.assertRaisesRegex(ValueError, message):
validate_lora_adapter_config(actual, self.expected())
if __name__ == "__main__":
unittest.main()

Xet Storage Details

Size:
2.13 kB
·
Xet hash:
82f6bfa8887268f0c63cdac146aa277ae05a2c59caa7f1c7f751e7b83a3993bf

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.