Add GPU distribution and sampling controls to chat profiles

This commit is contained in:
Mikei386
2026-09-28 19:51:49 +02:00
parent e2b521fcaa
commit 8d03a9a979
4 changed files with 68 additions and 9 deletions
+15
View File
@@ -15,6 +15,21 @@ class ManagementTests(unittest.TestCase):
(target/'entry.json').write_text(json.dumps(self.entry));self.catalog=Catalog(self.root/'models');self.profiles=Profiles(self.root/'profiles.json',self.catalog)
def tearDown(self):self.tmp.cleanup()
def request(self):return dict(id=None,revision=0,name='image-test',kind='image',model_id=self.model_id,parameters=dict(width=1024,height=1024,steps=25,seed=-1,guidance=1))
def test_chat_medium_and_legacy_parameters(self):
self.entry['kind']='chat';(self.root/'models'/self.model_id/'entry.json').write_text(json.dumps(self.entry))
params=dict(context=160000,slots=2,threads=6,batch=2048,ubatch=256)
req=dict(self.request(),kind='chat',name='qwen-medium',parameters=params)
saved=self.profiles.save(req)
self.assertEqual(saved['parameters']['gpu_devices'],[])
devices=['GPU-8ad38c6c-5a01-9d8e-1dfa-ed662ad78fbe','GPU-4834d9d7-5b61-3004-1fb3-4ae49d482d4b']
params.update(gpu_devices=devices,split_mode='layer',tensor_split=[85,15],temperature=1.0,top_p=.95,top_k=20)
req.update(id=saved['id'],revision=1)
self.profiles.save(req)
restarted=Profiles(self.root/'profiles.json',self.catalog)
self.assertEqual(restarted.status()['profiles'][0]['parameters'],params)
for change in [dict(gpu_devices=devices*2),dict(tensor_split=[85]),dict(split_mode='none'),dict(top_p=1.1),dict(temperature=float('nan')),dict(top_k=True),dict(tensor_split=[0,100]),dict(gpu_devices=['CUDA0','CUDA1'])]:
with self.subTest(change=change),self.assertRaises(ValueError):self.profiles.save(dict(req,revision=2,parameters=dict(params,**change)))
def test_profiles_persist_and_update_conflicts(self):
saved=self.profiles.save(self.request());other=Profiles(self.root/'profiles.json',self.catalog)
row=other.status()['profiles'][0];self.assertEqual(row['parameters']['width'],1024);self.assertFalse(row['runnable']);self.assertIn('Textencoder',row['blockers'][0])