MCPcopy Create free account
hub / github.com/modelscope/modelscope / test_patch_peft

Method test_patch_peft

tests/utils/test_hf_util.py:168–182  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

166
167 @unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
168 def test_patch_peft(self):
169 with patch_context():
170 from transformers import AutoModelForCausalLM
171 from peft import PeftModel
172 model = AutoModelForCausalLM.from_pretrained(
173 'Qwen/Qwen1.5-0.5B-Chat',
174 trust_remote_code=True,
175 torch_dtype=torch.float32)
176 model = PeftModel.from_pretrained(
177 model,
178 'tastelikefeet/test_lora',
179 trust_remote_code=True,
180 torch_dtype=torch.float32)
181 self.assertTrue(model is not None)
182 self.assertFalse(hasattr(PeftModel, '_from_pretrained_origin'))
183
184 def test_patch_file_exists(self):
185 with patch_context():

Callers

nothing calls this directly

Calls 2

patch_contextFunction · 0.90
from_pretrainedMethod · 0.45

Tested by

no test coverage detected