Include Deck chat profiles in runtime memory fit
This commit is contained in:
@@ -1,10 +1,31 @@
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
from runtime import Runtime
|
||||
|
||||
class RuntimeTests(unittest.TestCase):
|
||||
def test_deck_chat_profile_is_available_for_fit(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
r=Runtime(d);model_id='a'*64;model_root=Path(d)/'models';model_dir=model_root/model_id
|
||||
model_dir.mkdir(parents=True);(model_dir/'model.gguf').write_bytes(b'gguf')
|
||||
entry=dict(id=model_id,file='gemma-4-31B-it-Q4_0.gguf',kind='chat',profile_eligible=True)
|
||||
r.catalog=SimpleNamespace(root=model_root,entry=lambda ident:entry if ident==model_id else None)
|
||||
r.profiles=SimpleNamespace(lock=threading.RLock(),rows=[dict(id='gemma-profile',name='Gemma4',kind='chat',model_id=model_id,parameters=dict(context=32768,slots=1,batch=512,ubatch=128))])
|
||||
refs=r.references()['profiles'];gemma=next(p for p in refs if p['id']=='deck:gemma-profile')
|
||||
self.assertEqual((gemma['name'],gemma['context'],gemma['slots']),("Gemma4",32768,1))
|
||||
self.assertTrue(gemma['available'])
|
||||
r.state.update(active='build',builds=[dict(id='build',backend='CUDA',fit_tool=True)])
|
||||
result=type('Result',(),dict(returncode=0,stdout='-c 32768 -ngl 4',stderr=''))()
|
||||
gpus=[dict(uuid='GPU-free',name='5080',total_mib=16000,free_mib=8000)]
|
||||
with patch.object(r,'prerequisites',return_value={'gpus':gpus}),patch('runtime.subprocess.run',return_value=result) as run:
|
||||
r.fit('deck:gemma-profile',32768,1)
|
||||
args=run.call_args.args[0]
|
||||
self.assertEqual(args[args.index('--model')+1],str(model_dir/'model.gguf'))
|
||||
self.assertEqual(args[args.index('--batch-size')+1],'512')
|
||||
self.assertEqual(args[args.index('--ubatch-size')+1],'128')
|
||||
def test_untrusted_build_arguments(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
r=Runtime(d)
|
||||
|
||||
Reference in New Issue
Block a user