okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b0fc432ed
main
1"""The all-cards split engine and the parallel setting: no collision, and the number means the split's lanes. 2 3The split's run config (strata_control/split_engine.split_config) always carries `--batch N`. The launcher used to write a launch-profile override 4`parallel=<card fit>` beside it even when nobody asked, and `strata serve --profile` (strata_cli/cli.py _effective) refuses a parallel override next to 5--batch: every 2-card NVIDIA start with the split on Auto stopped with "parallel override conflicts with --batch/--slots in run config args". 6Now: the launcher writes no parallel override when the run config holds the slots; `--parallel N` is the split's lanes; the app's Concurrent requests 7(a profile override on the saved run config) is accepted for a split config and sets --batch in the engine's arguments. Nothing is started. 8""" 9 10from __future__import annotations 11 12import contextlib 13import copy 14import io 15import json 16import tempfile 17import unittest 18from pathlib import Path 19from unittest import mock 20 21from strata_cli import cli 22from strata_cli .launch import settings as S 23from strata_cli .launch .runner import Runner 24from strata_control import profiles ,split_engine as SE 25from tests .terminal .launch_support import HW_12 ,Home ,catalog 26import serve .server # noqa: F401 imported before any test patches sys.platform: serve/lifeline.py runs Linux-only libc code when it is imported as Linux 27 28A6000 = {"name" :"NVIDIA RTX A6000" ,"vram_gb" :48.0 ,"usable" :True ,"vendor" :"nvidia" } 29HW_2XA6000 = {** HW_12 ,"ram_gb" :125.0 ,"disk_free_gb" :900.0 ,"engine_vendor" :"nvidia" ,"gpus" : [{** A6000 ,"index" :i }for i in range (2 )]} 30R9700 = {"name" :"AMD Radeon AI PRO R9700" ,"vram_gb" :32.0 ,"usable" :True ,"vendor" :"amd" ,"arch" :"gfx1201" } 31HW_4XR9700 = {** HW_12 ,"ram_gb" :251.0 ,"disk_free_gb" :900.0 ,"engine_vendor" :"amd" ,"gpus" : [{** R9700 ,"index" :i }for i in range (4 )]} 32 33SPLIT_ARGS = ["--native" ,"/m/x-00001.gguf" ,"--mtp" ,"/m/mtp/rt" ,"--draft-vocab" ,"/e/draft_vocab_en.bin" ,"--max-context" ,"131072" , 34"--spec" ,"6" ,"--lookup" ,"15" ,"--conversation-cache-mib" ,"4096" ,"--batch" ,"6" ] 35LAYER_ARGS = ["--pack" ,"/m/packs/x" ,"--native" ,"/m/x-00001.gguf" ,"--spec" ,"4" ,"--mtp" ,"/m/mtp/rt" ] 36 37 38def split_cfg (lanes :int = 6 ,** more )-> dict : 39args = list (SPLIT_ARGS ) 40args [args .index ("--batch" )+ 1 ]= str (lanes ) 41return {"exe" :"/e/strata-split-2-sm120" ,"args" :args ,"tokenizer" :"/m/tokenizer" ,"model_name" :"m" ,"port" :8080 , 42"split_engine_note" :"Using the all-cards split engine on 2 cards." ,"drafting" :"mtp" ,** more } 43 44 45def layer_cfg (** more )-> dict : 46return {"exe" :"/e/strata" ,"args" :list (LAYER_ARGS ),"tokenizer" :"/m/tokenizer" ,"model_name" :"m" ,"port" :8080 ,** more } 47 48 49class Base (unittest .TestCase ): 50hw = HW_2XA6000 51 52def setUp (self ): 53self .home = Home ().__enter__ () 54self .addCleanup (self .home .__exit__ ,None ,None ,None ) 55# the all-cards split rule asks the host OS and is Linux only (strata_control/split_engine.expected): these fake cards are a Linux PC 56plat = mock .patch ("sys.platform" ,"linux" ) 57plat .start () 58self .addCleanup (plat .stop ) 59# and NVIDIA: an Intel Arc in the box that runs the test would make the launch an Intel one (Runner.intel_chosen reads the real machine) 60intel = mock .patch .object (Runner ,"intel_chosen" ,lambda self :False ) 61intel .start () 62self .addCleanup (intel .stop ) 63 64def profile_for (self ,cfg :dict ,* ,parallel = None ,hw = None ,four_card = None )-> dict : 65"""What Runner.ensure_profile saves as the launch profile's overrides for this written run config.""" 66cfgfile = Path (self .home .base )/ "cfg.json" 67cfgfile .write_text (json .dumps (cfg ),encoding = "utf-8" ) 68s = S .LaunchSettings (family = "qwen" ,model = "UD-Q4_K_XL" ,context = 131072 ,tune = "skip" ,parallel = parallel ) 69r = Runner (s ,catalog = catalog (hw or self .hw )) 70if four_card is not None : 71r .four_card_parallel = four_card 72r .ensure_profile (cfgfile ) 73prof ,_rev = profiles .load (r .profile ) 74return dict (prof .get ("overrides" )or {}) 75 76 77class TerminalPath (Base ): 78def test_the_split_run_config_gets_no_parallel_override_by_default (self ): 79"""The 2-card Auto start: before, the card-fit default (4) was written beside the split's --batch and the server refused to start.""" 80ov = self .profile_for (split_cfg ()) 81self .assertNotIn ("parallel" ,ov ) 82values ,_o = cli ._effective (split_cfg (), {"overrides" :ov },None )# the check that refused the start 83self .assertEqual (values ["parallel" ],None ) 84 85def test_a_layer_split_run_config_keeps_the_fitted_default (self ): 86ov = self .profile_for (layer_cfg ()) 87self .assertEqual (ov .get ("parallel" ),4 ,"48 GB card: the fitted default is unchanged on the layer split" ) 88cli ._effective (layer_cfg (), {"overrides" :ov },None ) 89 90def test_parallel_n_on_the_split_is_not_a_profile_override_either (self ): 91ov = self .profile_for (split_cfg (lanes = 3 ),parallel = 3 ) 92self .assertNotIn ("parallel" ,ov ) 93cli ._effective (split_cfg (lanes = 3 ), {"overrides" :ov },None ) 94 95def test_the_amd_four_card_default_does_not_collide_with_the_split (self ): 96"""AMD gfx1201 x4 starts the split by itself too; amd_four_card.apply put parallel=8 in the run config and the launcher mirrored it into the profile.""" 97cfg = split_cfg (lanes = 8 ,parallel = 8 ,exe = "/e/strata-split-4-amd" ) 98ov = self .profile_for (cfg ,hw = HW_4XR9700 ,four_card = 8 ) 99self .assertNotIn ("parallel" ,ov ) 100values ,origins = cli ._effective (cfg , {"overrides" :ov },None ) 101self .assertEqual ((values ["parallel" ],origins ["parallel" ]), (8 ,"run_config" )) 102 103def test_the_conflict_check_still_stops_a_plain_batch_config (self ): 104"""Only the split's run config is exempt: another config with its own --batch and a parallel override is still refused.""" 105cfg = layer_cfg (args = LAYER_ARGS + ["--batch" ,"6" ]) 106with self .assertRaises (profiles .ProfileError ): 107cli ._effective (cfg , {"overrides" : {"parallel" :4 }},None ) 108 109 110class LanesFromTheFlag (Base ): 111def run_apply (self ,parallel ,use_split ): 112"""Runner.apply_split_engine with the rule stubbed: what the rule sees in the config, and what is left of it afterwards.""" 113seen = {} 114 115def fake (cfg ,** _kw ): 116seen ["parallel" ]= cfg .get ("parallel" ) 117if use_split : 118new = split_cfg (lanes = int (cfg .get ("parallel" )or 6 ),parallel = cfg .get ("parallel" )) 119cfg .clear () 120cfg .update (new ) 121return SE .Decision (use_split , ["Using the all-cards split engine on 2 cards." ]if use_split else ["no" ],2 ,quiet =not use_split ) 122 123s = S .LaunchSettings (family = "qwen" ,model = "UD-Q4_K_XL" ,context = 131072 ,tune = "skip" ,parallel = parallel ) 124r = Runner (s ,catalog = catalog (self .hw )) 125mtp = Path (self .home .base )/ "mtp" / "rt" # the draft layer is on disk 126mtp .mkdir (parents = True ,exist_ok = True ) 127 (mtp / "dense.bin" ).write_bytes (b"x" ) 128cfg = layer_cfg (args = LAYER_ARGS [:- 1 ]+ [str (mtp )]) 129with mock .patch .object (SE ,"apply_to_config" ,fake ),contextlib .redirect_stdout (io .StringIO ()): 130r .apply_split_engine (cfg ) 131self .layer_args = LAYER_ARGS [:- 1 ]+ [str (mtp )] 132return seen ["parallel" ],cfg 133 134def test_parallel_n_reaches_the_rule_and_becomes_the_lane_count (self ): 135seen ,cfg = self .run_apply (3 ,True ) 136self .assertEqual (seen ,3 ) 137self .assertEqual (cfg ["args" ][cfg ["args" ].index ("--batch" )+ 1 ],"3" ) 138 139def test_without_the_flag_the_rule_sees_nothing_and_the_default_lanes_stay (self ): 140seen ,cfg = self .run_apply (None ,True ) 141self .assertIsNone (seen ) 142self .assertEqual (cfg ["args" ][cfg ["args" ].index ("--batch" )+ 1 ],"6" ) 143 144def test_a_refusal_leaves_the_layer_split_config_without_the_extra_key (self ): 145seen ,cfg = self .run_apply (3 ,False ) 146self .assertEqual (seen ,3 ) 147self .assertNotIn ("parallel" ,cfg ) 148self .assertEqual (cfg ["args" ],self .layer_args ) 149 150 151class DraftLayerMissing (Base ): 152"""The plan for Auto downloads DFlash2's drafter and not the draft layer; the split needs the draft layer (--mtp) and exits at start without it 153("sfnx: --native and --mtp are required"), so the server fell back to the layer split after a failed start and a misleading line. Now the launcher 154does not pick the split when the draft layer's folder is not on disk.""" 155 156def run_apply (self ,mode ,mtp_exists ): 157called = [] 158mtp = Path (self .home .base )/ "mtp" / "rt" 159if mtp_exists : 160mtp .mkdir (parents = True ) 161 (mtp / "dense.bin" ).write_bytes (b"x" ) 162cfg = layer_cfg (args = LAYER_ARGS [:- 1 ]+ [str (mtp )],** ({"split_engine" :mode }if mode else {})) 163 164def fake (c ,** _kw ): 165called .append (True ) 166return SE .Decision (False , ["no" ],2 ,quiet = True ) 167 168r = Runner (S .LaunchSettings (family = "qwen" ,model = "UD-Q4_K_XL" ,context = 131072 ,tune = "skip" ),catalog = catalog (self .hw )) 169with mock .patch .object (SE ,"apply_to_config" ,fake ),contextlib .redirect_stdout (io .StringIO ()): 170r .apply_split_engine (cfg ) 171return bool (called ),r .notices 172 173def test_without_the_folder_auto_stays_on_the_layer_split_without_a_word (self ): 174called ,notices = self .run_apply (None ,False ) 175self .assertEqual ((called ,notices ), (False , [])) 176 177def test_without_the_folder_on_says_how_to_get_it (self ): 178called ,notices = self .run_apply ("on" ,False ) 179self .assertFalse (called ) 180self .assertEqual (len (notices ),1 ) 181self .assertIn ("--drafting mtp" ,notices [0 ]) 182 183def test_with_the_folder_the_rule_is_asked_as_before (self ): 184self .assertEqual (self .run_apply (None ,True ), (True , [])) 185 186def test_off_never_asks (self ): 187self .assertEqual (self .run_apply ("off" ,True ), (False , [])) 188 189 190def cards (n ,cc = 120 ,vendor = "nvidia" ,arch = "" ): 191return [SE .Card (i ,"RTX PRO 6000" if vendor == "nvidia" else "R9700" ,98304 if vendor == "nvidia" else 32768 ,cc if vendor == "nvidia" else 0 ,vendor ,arch ) 192for i in range (n )] 193 194 195class AutoFetchesTheDraftLayer (Base ): 196"""The owner's default: the split engine on 2 cards (sm_86 / sm_120) and on 4 x gfx1201. It runs the MTP draft layer and nothing else, so where Auto will pick it the plan and 197the fetch are for the MTP (5.2 GB), not DFlash2's drafter; a person's own DFlash2 / off keeps the layer split; one card, other cards and --split-engine off keep DFlash2.""" 198 199def settings (self ,** kw ): 200return S .LaunchSettings (** {"family" :"qwen" ,"model" :"UD-Q4_K_XL" ,"context" :131072 ,"tune" :"skip" ,"vision" :"off" ,** kw }) 201 202def runner (self ,probe ,** kw ): 203r = Runner (self .settings (** kw ),catalog = catalog (self .hw )) 204self .patches = [mock .patch .object (SE ,"probe_cards" ,lambda idx = None :probe ),mock .patch .object (SE ,"ram_gib" ,lambda : (500.0 ,400.0 )), 205mock .patch ("strata_control.drafting.detect_hardware" ,lambda : ("cuda" , ["sm_120" ]))] 206for p in self .patches : 207p .start () 208self .addCleanup (p .stop ) 209return r 210 211def test_two_cards_on_auto_resolve_to_the_mtp_and_the_plan_says_why (self ): 212r = self .runner (cards (2 ),gpus = [0 ,1 ]) 213self .assertEqual (r .resolved_drafting ("qwen" ),"mtp" ) 214self .assertEqual (r .drafting_plan_line (),"Drafting: MTP (the all-cards split engine uses the MTP draft layer, 5.2 GB)" ) 215kinds = [p ["kind" ]for p in r .download_plan ()["parts" ]] 216self .assertIn ("mtp" ,kinds ) 217self .assertNotIn ("dflash2" ,kinds ) 218 219def test_the_size_in_the_plan_is_the_size_setup_fetches (self ): 220"""tools/mtp_fetch.py reads the same 31 pinned tensors of the checkpoint for every set (5.214 GB) and packs them into the 0.9 GB layer the engine loads; the plan, the 221plan line, `strata drafting plan` and setup's own disk check all use that one number.""" 222from strata_control .discovery import MTP_FETCH_GB 223r = self .runner (cards (2 ),gpus = [0 ,1 ]) 224part = next (p for p in r .download_plan ()["parts" ]if p ["kind" ]== "mtp" ) 225self .assertEqual (part ["gb" ],MTP_FETCH_GB ) 226self .assertIn (f" { MTP_FETCH_GB :g } GB" ,r .drafting_plan_line ()) 227setup_text = (Path (__file__ ).resolve ().parents [2 ]/ "setup.py" ).read_text (encoding = "utf-8" ) 228self .assertIn (f"mtp_fetch = { MTP_FETCH_GB } if" ,setup_text ,"setup.py counts the layer with the same number" ) 229self .assertEqual (MTP_FETCH_GB ,5.2 ) 230 231def test_the_inputs_of_the_fetch_are_the_mtp_so_the_dflash2_drafter_is_not_fetched (self ): 232from strata_control import drafting 233r = self .runner (cards (2 ),gpus = [0 ,1 ]) 234want = r .drafting_inputs ({"model_name" :"qwen3.8-flash-next-unsloth-ud-q4_k_xl" ,"args" : []}) 235self .assertEqual (want ["mode" ],"mtp" ) 236self .assertFalse (drafting .needs_pack (** want )) 237self .assertFalse (drafting .wants_one_request (** want ),"the split has its lanes: no 'one request at a time'" ) 238 239def test_a_persons_own_choice_off_or_one_card_or_an_other_card_keeps_dflash2 (self ): 240for name ,probe ,kw in (("their own DFlash2" ,cards (2 ), {"gpus" : [0 ,1 ],"drafting" :"dflash2" }), 241 ("split-engine off" ,cards (2 ), {"gpus" : [0 ,1 ],"split_engine" :"off" }), 242 ("one card" ,cards (1 ), {"gpus" : [0 ]}), 243 ("sm_89 cards" ,cards (2 ,cc = 89 ), {"gpus" : [0 ,1 ]}), 244 ("three cards" ,cards (3 ), {"gpus" : [0 ,1 ,2 ]})): 245with self .subTest (name ): 246r = self .runner (probe ,** kw ) 247self .assertEqual (r .resolved_drafting ("qwen" ),"dflash2" ) 248self .assertNotIn ("mtp" , [p ["kind" ]for p in r .download_plan ()["parts" ]]) 249 250def test_dflash2_by_name_with_the_split_engine_on_fetches_the_dflash2_drafter_not_the_layer (self ): 251"""Owner 2026-11-03: both choices are the person's own (--drafting dflash2 --split-engine on): the split engine runs, with DFlash2's drafter.""" 252r = self .runner (cards (2 ),gpus = [0 ,1 ],drafting = "dflash2" ,split_engine = "on" ) 253self .assertTrue (r .split_expected ()) 254self .assertEqual (r .resolved_drafting ("qwen" ),"dflash2" ) 255kinds = [p ["kind" ]for p in r .download_plan ()["parts" ]] 256self .assertIn ("dflash2" ,kinds ) 257self .assertNotIn ("mtp" ,kinds ) 258want = r .drafting_inputs ({"model_name" :"qwen3.8-flash-next-unsloth-ud-q4_k_xl" ,"args" : []}) 259self .assertEqual (want ["mode" ],"dflash2" ) 260self .assertNotIn ("MTP" ,r .drafting_plan_line ()) 261# the same name with the split engine on Auto stays the layer split (and a number of requests changes nothing about which drafter) 262r = self .runner (cards (2 ),gpus = [0 ,1 ],drafting = "dflash2" ) 263self .assertFalse (r .split_expected ()) 264r = self .runner (cards (2 ),gpus = [0 ,1 ],drafting = "dflash2" ,split_engine = "on" ,parallel = 4 ) 265want = r .drafting_inputs ({"model_name" :"qwen3.8-flash-next-unsloth-ud-q4_k_xl" ,"args" : []}) 266self .assertEqual ((want ["mode" ],want ["blocked" ]), ("dflash2" ,False ),"the person's own number of requests no longer blocks a DFlash2 they named" ) 267 268def test_amd_four_gfx1201_is_the_mtp_two_are_not (self ): 269self .hw = HW_4XR9700 270r = self .runner (cards (4 ,vendor = "amd" ,arch = "gfx1201" ),gpus = [0 ,1 ,2 ,3 ]) 271self .assertEqual (r .resolved_drafting ("qwen" ),"mtp" ) 272r2 = self .runner (cards (2 ,vendor = "amd" ,arch = "gfx1201" ),gpus = [0 ,1 ]) 273self .assertEqual (r2 .resolved_drafting ("qwen" ),"dflash2" ) 274 275def test_the_rule_answers_without_files_and_says_no_to_what_it_would_refuse (self ): 276self .assertTrue (SE .expected ({},indexes = [0 ,1 ],probe = lambda i :cards (2 ),ram = lambda : (500.0 ,400.0 ),system = "linux" )) 277self .assertFalse (SE .expected ({"split_engine" :"off" },probe = lambda i :cards (2 ),ram = lambda : (500.0 ,400.0 ),system = "linux" )) 278self .assertFalse (SE .expected ({"drafting" :"dflash2" },probe = lambda i :cards (2 ),ram = lambda : (500.0 ,400.0 ),system = "linux" )) 279self .assertTrue (SE .expected ({"drafting" :"dflash2" ,"split_engine" :"on" },probe = lambda i :cards (2 ),ram = lambda : (500.0 ,400.0 ),system = "linux" ),"named and asked for: both are the person's own" ) 280self .assertFalse (SE .expected ({},probe = lambda i :cards (2 ),ram = lambda : (500.0 ,400.0 ),system = "darwin" )) 281self .assertFalse (SE .expected ({},probe = lambda i :cards (2 ),ram = lambda : (500.0 ,4.0 ),system = "linux" ),"not enough RAM for the locked tables" ) 282 283def test_the_apps_drafting_plan_follows_the_same_rule (self ): 284from strata_cli import drafting_cmd 285cfg = {"gpu" : [0 ,1 ],"args" : ["--native" ,"/nowhere/x-00001.gguf" ,"--max-context" ,"131072" ]} 286self .runner (cards (2 )) 287self .assertTrue (drafting_cmd ._split_expected (cfg ,cfg ["args" ])) 288self .assertFalse (drafting_cmd ._split_expected ({** cfg ,"split_engine" :"off" },cfg ["args" ])) 289self .assertFalse (drafting_cmd ._split_expected ({** cfg ,"drafting" :"dflash2" },cfg ["args" ])) 290 291 292class SummaryTellsWhatRuns (Base ): 293"""The server falls back to the normal layer split when the split engine exits at start (serve/server.py start_engine_or_fallback; metrics engine.split_fallback). 294The launcher's summary used to keep the line written before the start, "Using the all-cards split engine on 2 cards".""" 295 296def runner (self ,log_name = "e.log" ): 297cfgfile = Path (self .home .base )/ "cfg.json" 298log = Path (self .home .base )/ log_name 299cfgfile .write_text (json .dumps ({"log" :str (log ),"args" : []}),encoding = "utf-8" ) 300r = Runner (S .LaunchSettings (family = "qwen" ,model = "UD-Q4_K_XL" ,context = 131072 ,tune = "skip" ,port = 18999 ),catalog = catalog (self .hw )) 301r .config_path = cfgfile 302r .notices .append ("Using the all-cards split engine on 2 cards. Turn it off with: strata launch --split-engine off." ) 303return r ,log 304 305def metrics (self ,engine ): 306resp = mock .MagicMock () 307resp .read .return_value = json .dumps ({"engine" :engine }).encode () 308resp .__enter__ .return_value = resp 309return mock .patch ("urllib.request.urlopen" ,lambda * a ,** k :resp ) 310 311def test_a_fallback_replaces_the_line_and_gives_the_engines_reason (self ): 312r ,log = self .runner () 313Path (str (log )+ ".split-engine" ).write_text ("[strata] engine started: x\nsfnx: --native and --mtp are required\n" ,encoding = "utf-8" ) 314with self .metrics ({"split_fallback" :True }),contextlib .redirect_stdout (io .StringIO ()): 315r .report_drafting () 316self .assertEqual (r .notices , ["The all-cards split engine could not start (sfnx: --native and --mtp are required); running the normal layer split." ]) 317 318def test_a_fallback_without_a_reason_in_the_log_still_says_it (self ): 319r ,_log = self .runner () 320with self .metrics ({"split_fallback" :True }),contextlib .redirect_stdout (io .StringIO ()): 321r .report_drafting () 322self .assertEqual (r .notices , ["The all-cards split engine could not start; running the normal layer split." ]) 323 324def test_when_the_split_runs_the_line_stays (self ): 325r ,_log = self .runner () 326with self .metrics ({}),contextlib .redirect_stdout (io .StringIO ()): 327r .report_drafting () 328self .assertEqual (len (r .notices ),1 ) 329self .assertTrue (r .notices [0 ].startswith ("Using the all-cards split engine" )) 330 331 332class PlanTellsTheApp (Base ): 333"""`strata drafting plan` is what the app reads (native-control.mjs): with the split taking the start it says choice mtp and split true.""" 334 335def plan (self ,probe ,* extra ): 336from tests .terminal .launch_support import run_cli 337data = Path (self .home .base )/ "d" 338data .mkdir (exist_ok = True ) 339with mock .patch .object (SE ,"probe_cards" ,lambda idx = None :probe ),mock .patch .object (SE ,"ram_gib" ,lambda : (500.0 ,400.0 )),mock .patch ("strata_control.drafting.detect_hardware" ,lambda : ("cuda" , ["sm_120" ])): 340code ,out ,err = run_cli (["drafting" ,"plan" ,"--family" ,"qwen" ,"--data-dir" ,str (data ),"--output" ,"json" ,* extra ]) 341self .assertEqual (code ,0 ,err ) 342return json .loads (out ) 343 344def test_two_cards_on_auto_say_split_and_the_mtp (self ): 345p = self .plan (cards (2 ),"--mode" ,"auto" ) 346self .assertEqual ((p ["split" ],p ["choice" ],p ["needed" ]), (True ,"mtp" ,False )) 347 348def test_one_card_or_a_chosen_dflash2_do_not (self ): 349for probe ,mode in ((cards (1 ),"auto" ), (cards (2 ),"dflash2" )): 350p = self .plan (probe ,"--mode" ,mode ) 351self .assertFalse (p ["split" ], (len (probe ),mode )) 352self .assertEqual (p ["choice" ],"dflash2" ) 353 354 355@ contextlib . contextmanager 356def tempdir (): 357with tempfile .TemporaryDirectory ()as tmp : 358yield tmp 359 360 361def app_cfg (tmp :str ,** more )-> dict : 362"""The run config the app hands to Control at a Load (native-control.mjs buildConfig): the installed model's layer-split config with the app's own keys 363(host, port, api_key, the card list, parallel 4 where nobody chose a number) and the draft layer on disk.""" 364root = Path (tmp ) 365 (root / "data" ).mkdir (exist_ok = True ) 366 (root / "data" / "draft_vocab_en.bin" ).write_bytes (b"x" ) 367mtp = root / "mtp" / "rt" 368mtp .mkdir (parents = True ,exist_ok = True ) 369 (mtp / "dense.bin" ).write_bytes (b"x" ) 370cfg = {"exe" :"/e/strata" ,"args" : ["--pack" ,"/m/packs/x" ,"--native" ,"/m/x-00001.gguf" ,"--spec" ,"4" ,"--mtp" ,str (mtp ),"--max-context" ,"131072" , 371"--kv" ,"int8" ,"--vram-reserve-mib" ,"1536" ], 372"cwd" :tmp ,"tokenizer" :"/m/tokenizer" ,"model_name" :"qwen3.8-flash-next-unsloth-ud-q4_k_xl" ,"host" :"127.0.0.1" ,"port" :18500 ,"api_key" :"k" ,"gpu" : [0 ,1 ],"layer_split" :"auto" , 373"open_browser" :False ,"parallel" :4 ,"fit_max_tokens" :True ,"env" : {}} 374cfg .update (more ) 375return cfg 376 377 378def set_arg (cfg :dict ,flag :str ,value :str )-> None : 379cfg ["args" ][cfg ["args" ].index (flag )+ 1 ]= value 380 381 382def flag_of (cfg :dict ,flag :str )-> str : 383return cfg ["args" ][cfg ["args" ].index (flag )+ 1 ] 384 385 386class AppPlanEqualsTerminalPlan (Base ): 387"""0.2.10.1: the app asks `strata drafting plan` / `fetch` WITHOUT --no-split, so its plan is the Terminal's: where the split rule says yes, Auto is the split with the MTP draft 388layer (fetched through the app's existing MTP step), and a person's DFlash2 or Off keeps the layer split.""" 389 390def plan (self ,probe ,* extra ,config = None ): 391from tests .terminal .launch_support import run_cli 392data = Path (self .home .base )/ "d" 393data .mkdir (exist_ok = True ) 394argv = ["drafting" ,"plan" ,"--data-dir" ,str (data ),"--output" ,"json" ,* extra ] 395if config is not None : 396path = Path (self .home .base )/ "cfg-plan.json" 397path .write_text (json .dumps (config ),encoding = "utf-8" ) 398argv += ["--config" ,str (path )] 399else : 400argv += ["--family" ,"qwen" ] 401with mock .patch .object (SE ,"probe_cards" ,lambda idx = None :probe ),mock .patch .object (SE ,"ram_gib" ,lambda : (500.0 ,400.0 )), \ 402mock .patch ("strata_control.drafting.detect_hardware" ,lambda : ("cuda" , ["sm_120" ])): 403code ,out ,err = run_cli (argv ) 404self .assertEqual (code ,0 ,err ) 405return json .loads (out ) 406 407def terminal (self ,probe ,** kw ): 408"""What the Terminal's launch decides for the same machine and choice: the drafter, the split word and the parts of its download plan.""" 409s = S .LaunchSettings (** {"family" :"qwen" ,"model" :"UD-Q4_K_XL" ,"context" :131072 ,"tune" :"skip" ,"vision" :"off" ,** kw }) 410r = Runner (s ,catalog = catalog (self .hw )) 411with mock .patch .object (SE ,"probe_cards" ,lambda idx = None :probe ),mock .patch .object (SE ,"ram_gib" ,lambda : (500.0 ,400.0 )), \ 412mock .patch ("strata_control.drafting.detect_hardware" ,lambda : ("cuda" , ["sm_120" ])): 413return r .resolved_drafting ("qwen" ),r .split_expected (), [p ["kind" ]for p in r .download_plan ()["parts" ]] 414 415def test_the_apps_plan_on_two_cards_is_the_terminals_split_and_the_mtp (self ): 416p = self .plan (cards (2 ),"--mode" ,"auto" ) 417drafter ,split ,kinds = self .terminal (cards (2 ),gpus = [0 ,1 ]) 418self .assertEqual ((p ["split" ],p ["choice" ],p ["needed" ]), (True ,"mtp" ,False )) 419self .assertEqual ((drafter ,split ), ("mtp" ,True )) 420self .assertIn ("mtp" ,kinds ) 421self .assertNotIn ("dflash2" ,kinds ) 422 423def test_without_the_mtp_layer_the_plan_asks_for_it (self ): 424"""The draft layer is not on disk (a DFlash2 install leaves it out): mtp_needed with its size, and nothing for DFlash2.""" 425from strata_control .discovery import MTP_FETCH_GB 426with tempdir ()as tmp : 427cfg = app_cfg (tmp ) 428set_arg (cfg ,"--mtp" ,str (Path (tmp )/ "nowhere" / "rt" )) 429p = self .plan (cards (2 ),"--mode" ,"auto" ,config = cfg ) 430self .assertEqual ((p ["split" ],p ["choice" ],p ["needed" ],p ["mtp_needed" ],p ["mtp_gb" ]), (True ,"mtp" ,False ,True ,MTP_FETCH_GB )) 431self .assertIn ("all-cards split engine" ,p ["line" ]) 432self .assertIn (f" { MTP_FETCH_GB :g } GB" ,p ["line" ]) 433 434def test_the_plan_line_is_the_terminals_line (self ): 435from strata_control .discovery import MTP_FETCH_GB 436self .assertEqual (SE .split_plan_line (MTP_FETCH_GB ),f"Drafting: MTP (the all-cards split engine uses the MTP draft layer, { MTP_FETCH_GB :g } GB)" ) 437self .assertEqual (SE .split_plan_line (),"Drafting: MTP (the all-cards split engine uses the MTP draft layer)" ) 438 439def test_a_persons_dflash2_or_off_or_one_card_is_the_same_in_the_app_and_the_terminal (self ): 440for name ,probe ,mode ,config ,kw in (("their DFlash2" ,cards (2 ),"dflash2" ,None , {"gpus" : [0 ,1 ],"drafting" :"dflash2" }), 441 ("split-engine off" ,cards (2 ),"auto" , {"split_engine" :"off" ,"model_name" :"qwen3.8-flash-next-unsloth-ud-q4_k_xl" ,"args" : []}, {"gpus" : [0 ,1 ],"split_engine" :"off" }), 442 ("one card" ,cards (1 ),"auto" ,None , {"gpus" : [0 ]})): 443with self .subTest (name ): 444p = self .plan (probe ,"--mode" ,mode ,config = config ) 445drafter ,split ,kinds = self .terminal (probe ,** kw ) 446self .assertFalse (p ["split" ]) 447self .assertEqual (p ["choice" ],"dflash2" ) 448self .assertEqual ((drafter ,split ), ("dflash2" ,False )) 449self .assertNotIn ("mtp" ,kinds ) 450 451def test_a_saved_dflash2_is_overridden_by_the_auto_the_screen_carries (self ): 452"""The Models screen's Load with Auto on a model whose settings file still says dflash2: the choice in hand is Auto, so the rule is asked with Auto.""" 453with tempdir ()as tmp : 454cfg = app_cfg (tmp ,drafting = "dflash2" ) 455p_auto = self .plan (cards (2 ),"--mode" ,"auto" ,config = cfg ) 456p_saved = self .plan (cards (2 ),config = cfg ) 457self .assertTrue (p_auto ["split" ]) 458self .assertFalse (p_saved ["split" ]) 459self .assertEqual (p_saved ["choice" ],"dflash2" ) 460 461def test_an_explicit_mtp_is_the_split_too_as_in_the_terminal (self ): 462p = self .plan (cards (2 ),"--mode" ,"mtp" ) 463_ ,split ,_ = self .terminal (cards (2 ),gpus = [0 ,1 ],drafting = "mtp" ) 464self .assertEqual ((p ["split" ],p ["choice" ]), (True ,"mtp" )) 465self .assertTrue (split ) 466 467def test_four_r9700_in_the_app_are_the_split_and_the_mtp_too (self ): 468p = self .plan (cards (4 ,vendor = "amd" ,arch = "gfx1201" ),"--mode" ,"auto" ) 469self .assertEqual ((p ["split" ],p ["choice" ]), (True ,"mtp" )) 470p2 = self .plan (cards (2 ,vendor = "amd" ,arch = "gfx1201" ),"--mode" ,"auto" ) 471self .assertEqual ((p2 ["split" ],p2 ["choice" ]), (False ,"dflash2" )) 472 473def test_a_conversation_memory_other_than_int8_is_not_the_split_in_the_plan_either (self ): 474with tempdir ()as tmp : 475cfg = app_cfg (tmp ) 476set_arg (cfg ,"--kv" ,"q4_0" ) 477p = self .plan (cards (2 ),"--mode" ,"auto" ,config = cfg ) 478self .assertFalse (p ["split" ]) 479self .assertEqual (p ["choice" ],"dflash2" ) 480 481def test_no_split_stays_for_a_person_and_for_the_failed_layer_fetch (self ): 482from tests .terminal .launch_support import run_cli 483p = self .plan (cards (2 ),"--mode" ,"auto" ,"--no-split" ) 484self .assertEqual ((p ["split" ],p ["choice" ],p ["mtp_needed" ]), (False ,"dflash2" ,False )) 485self .assertTrue (p ["needed" ],"DFlash2's drafter is what the plan fetches then" ) 486for sub in ("plan" ,"fetch" ): 487code ,out ,_ = run_cli (["drafting" ,sub ,"--help" ]) 488self .assertIn ("--no-split" ,out ) 489 490def test_the_hosts_calls_only_carry_no_split_when_it_is_told_to (self ): 491"""The app (apps/host/server/control-runtime.mjs) adds --no-split only after the split's draft layer could not be downloaded.""" 492text = (Path (__file__ ).resolve ().parents [2 ]/ "apps/host/server/control-runtime.mjs" ).read_text (encoding = "utf-8" ) 493self .assertNotIn ("'--no-split', '--output', 'json'" ,text ) 494self .assertNotIn ("'--no-split', '--if-needed'" ,text ) 495self .assertEqual (text .count ("...(noSplit ? ['--no-split'] : [])" ),2 ) 496 497 498class AppStartsTheSplit (Base ): 499"""The app's engine start (apps/host: buildConfig, then `profile` + `runtime start`) never went through the Terminal's apply_split_engine; Control now answers it 500(`strata split-engine apply`, strata_control/split_engine.apply_run_config) from the same rule, engine package and draft layer.""" 501 502@staticmethod 503def model (): 504return SE .ModelFacts (routed_types = {"Q4_K" :97 ,"Q5_K" :2 ,"Q5_1" :43 ,"Q8_0" :5 },routed_bytes = int (71.7 * (1 << 30 )),embd_type = "Q8_0" ,shexp_types = {"Q8_0" :144 }, 505embd_ram_bytes = int (27.5 * (1 << 30 )),layers = 48 ,experts = 512 ) 506 507def apply (self ,cfg ,* ,probe = None ,avail = 400.0 ,exe = "/e/strata-split-2-sm120" ,system = "linux" ): 508probe = probe or cards (2 ) 509return SE .apply_run_config (cfg ,exe_for_cards = lambda n ,cc = None ,arch = None :exe ,system = system ,probe = lambda idx :probe ,ram = lambda : (500.0 ,avail ), 510scan = lambda path :self .model ()) 511 512def test_the_apps_default_of_four_slots_is_the_splits_four_lanes (self ): 513with tempdir ()as tmp : 514cfg = app_cfg (tmp ) 515d ,line ,warn = self .apply (cfg ) 516self .assertTrue (d .use_split ,d .reasons ) 517self .assertEqual (flag_of (cfg ,"--batch" ),"4" ) 518self .assertEqual (cfg ["exe" ],"/e/strata-split-2-sm120" ) 519self .assertEqual (cfg ["drafting" ],"mtp" ) 520self .assertIn ("all-cards split engine on 2 cards" ,line ) 521self .assertFalse (warn ) 522# the app's own keys ride along, and the normal layer split is kept whole for the server's fallback 523for key in ("host" ,"port" ,"api_key" ,"tokenizer" ,"model_name" ,"fit_max_tokens" ,"parallel" ): 524self .assertIn (key ,cfg ,key ) 525self .assertEqual (cfg ["split_fallback" ]["exe" ],"/e/strata" ) 526self .assertIn ("--vram-reserve-mib" ,cfg ["split_fallback" ]["args" ]) 527self .assertNotIn ("--vram-reserve-mib" ,cfg ["args" ],"the layer split's own flags are not given to the split engine" ) 528 529def test_a_number_the_person_chose_is_the_lanes_and_never_more_than_eight (self ): 530for chosen ,want in ((1 ,"1" ), (3 ,"3" ), (8 ,"8" ), (12 ,"8" )): 531with self .subTest (chosen ),tempdir ()as tmp : 532cfg = app_cfg (tmp ,parallel = chosen ) 533d ,_ ,_ = self .apply (cfg ) 534self .assertTrue (d .use_split ) 535self .assertEqual (flag_of (cfg ,"--batch" ),want ) 536 537def test_no_number_at_all_gives_the_splits_own_default_lanes (self ): 538with tempdir ()as tmp : 539cfg = app_cfg (tmp ) 540del cfg ["parallel" ] 541self .apply (cfg ) 542self .assertEqual (flag_of (cfg ,"--batch" ),"6" ) 543 544def test_vision_is_passed_when_the_app_reads_pictures (self ): 545with tempdir ()as tmp : 546cfg = app_cfg (tmp ,vision = {"exe" :"/e/strata-vision" ,"mmproj" :"/m/mm.gguf" }) 547self .apply (cfg ) 548self .assertIn ("--vision" ,cfg ["args" ]) 549with tempdir ()as tmp : 550cfg = app_cfg (tmp ) 551self .apply (cfg ) 552self .assertNotIn ("--vision" ,cfg ["args" ]) 553 554def test_every_no_leaves_the_apps_run_config_alone_and_auto_says_nothing (self ): 555cases = {"a person's DFlash2" : ({"drafting" :"dflash2" }, {}),"drafting off" : ({"drafting" :"off" }, {}),"the switch off" : ({"split_engine" :"off" }, {}), 556"engine arguments of their own" : ({"user_args" : ["--x" ,"1" ]}, {}),"one card" : ({"gpu" :0 }, {"probe" :cards (1 )}), 557"two other cards" : ({}, {"probe" :cards (2 ,cc = 89 )}),"too little RAM" : ({}, {"avail" :10.0 }),"no split engine in the package" : ({}, {"exe" :None }), 558"Windows" : ({}, {"system" :"windows" })} 559for name , (more ,kw )in cases .items (): 560with self .subTest (name ),tempdir ()as tmp : 561cfg = app_cfg (tmp ,** more ) 562before = copy .deepcopy (cfg ) 563d ,line ,_ = self .apply (cfg ,** kw ) 564self .assertFalse (d .use_split ,name ) 565self .assertEqual (cfg ,before ,name ) 566self .assertEqual (line ,"" ,f" { name } : Auto says nothing" ) 567with tempdir ()as tmp :# a conversation memory other than int8 is refused by the rule itself 568cfg = app_cfg (tmp ) 569set_arg (cfg ,"--kv" ,"q4_0" ) 570before = copy .deepcopy (cfg ) 571d ,line ,_ = self .apply (cfg ) 572self .assertFalse (d .use_split ) 573self .assertEqual ((cfg ,line ), (before ,"" )) 574 575def test_a_missing_draft_layer_is_a_quiet_layer_split_and_on_says_how_to_get_it (self ): 576with tempdir ()as tmp : 577cfg = app_cfg (tmp ) 578set_arg (cfg ,"--mtp" ,str (Path (tmp )/ "nowhere" / "rt" )) 579d ,line ,_ = self .apply (cfg ) 580self .assertFalse (d .use_split ) 581self .assertEqual (line ,"" ) 582self .assertNotIn ("split_fallback" ,cfg ) 583cfg2 = app_cfg (tmp ,split_engine = "on" ) 584set_arg (cfg2 ,"--mtp" ,str (Path (tmp )/ "nowhere" / "rt" )) 585d2 ,line2 ,warn2 = self .apply (cfg2 ) 586self .assertFalse (d2 .use_split ) 587self .assertIn ("draft layer" ,line2 ) 588self .assertTrue (warn2 ) 589 590def test_the_command_writes_the_split_config_only_on_a_yes_and_never_touches_the_input (self ): 591from tests .terminal .launch_support import run_cli 592with tempdir ()as tmp : 593src = Path (tmp )/ "layer.json" 594out = Path (tmp )/ "split.json" 595cfg = app_cfg (tmp ) 596src .write_text (json .dumps (cfg ),encoding = "utf-8" ) 597before = src .read_text (encoding = "utf-8" ) 598with mock .patch .object (SE ,"probe_cards" ,lambda idx = None :cards (2 )),mock .patch .object (SE ,"ram_gib" ,lambda : (500.0 ,400.0 )), \ 599mock .patch .object (SE ,"scan_model" ,lambda path :self .model ()), \ 600mock .patch .object (SE ,"exe_finder" ,lambda c : (lambda n ,cc = None ,arch = None :"/e/strata-split-2-sm120" )), \ 601mock .patch ("sys.platform" ,"linux" ): 602code ,text ,err = run_cli (["split-engine" ,"apply" ,"--config" ,str (src ),"--out" ,str (out ),"--output" ,"json" ]) 603self .assertEqual (code ,0 ,err ) 604got = json .loads (text ) 605self .assertTrue (got ["ok" ]and got ["split" ],got ) 606self .assertEqual (got ["cards" ],2 ) 607written = json .loads (out .read_text (encoding = "utf-8" )) 608self .assertEqual (flag_of (written ,"--batch" ),"4" ) 609self .assertEqual (src .read_text (encoding = "utf-8" ),before ) 610out .unlink () 611src .write_text (json .dumps ({** cfg ,"drafting" :"dflash2" }),encoding = "utf-8" ) 612code ,text ,err = run_cli (["split-engine" ,"apply" ,"--config" ,str (src ),"--out" ,str (out ),"--output" ,"json" ]) 613got = json .loads (text ) 614self .assertEqual ((code ,got ["split" ],got ["written" ]), (0 ,False ,None )) 615self .assertFalse (out .exists ()) 616src .write_text ("not json" ,encoding = "utf-8" ) 617code ,text ,_ = run_cli (["split-engine" ,"apply" ,"--config" ,str (src ),"--out" ,str (out ),"--output" ,"json" ]) 618self .assertNotEqual (code ,0 ) 619self .assertFalse (json .loads (text )["ok" ]) 620 621def test_the_fallback_layer_split_keeps_the_apps_slots_and_its_own_drafting_choice (self ): 622"""If the split engine will not come up, the server starts the layer split from split_fallback (serve/server.py start_engine_or_fallback) with the app's parallel.""" 623from serve .server import SPLIT_KEYS 624with tempdir ()as tmp : 625cfg = app_cfg (tmp ) 626self .apply (cfg ) 627cfg2 = {k :v for k ,v in cfg .items ()if k not in SPLIT_KEYS + ("exe" ,"args" ,"env" ,"layer_split" ,"replicas" ,"user_args" ,"drafting" )} 628cfg2 .update (cfg ["split_fallback" ]) 629self .assertEqual (cfg2 ["parallel" ],4 ) 630self .assertEqual (cfg2 ["exe" ],"/e/strata" ) 631self .assertNotIn ("drafting" ,cfg2 ) 632 633 634class LaneClamp (Base ): 635"""The engine runs 1..8 lanes ("sfnx: --batch must be 1..8"): the AMD four-card default PARALLEL 32, a layer config's own --batch and an app profile's parallel 636are cut to 8 in the split's run config and in the server's --batch.""" 637 638def split_args (self ,lanes ): 639d = SE .Decision (True , [],2 ) 640cfg = SE .split_config ({"tokenizer" :"/t" ,"port" :1 },d ,exe = "/e/strata-split-2-sm86" ,native = "/m/x-00001.gguf" ,mtp_dir = "/m/mtp/rt" ,draft_vocab = "/e/v.bin" , 641context = 131072 ,lanes = lanes ) 642return cfg ["args" ] 643 644def test_split_config_cuts_the_lanes_to_1_through_8 (self ): 645for lanes ,want in ((32 ,"8" ), (9 ,"8" ), (8 ,"8" ), (5 ,"5" ), (1 ,"1" ), (0 ,"1" )): 646a = self .split_args (lanes ) 647self .assertEqual (a [a .index ("--batch" )+ 1 ],want ,lanes ) 648 649def stubbed (self ,cfg ,probe ,mode_ = "on" ,exe = "/e/strata-split-2-sm86" ): 650data = Path (self .home .base )/ "vocab" 651data .mkdir (exist_ok = True ) 652 (data / "draft_vocab_en.bin" ).write_bytes (b"v" ) 653return SE .apply_to_config (cfg ,exe_for_cards = lambda n ,cc = None ,arch = None :exe ,system = "linux" ,probe = lambda i :probe ,ram = lambda : (500.0 ,400.0 ), 654scan = lambda p :SE .ASSUMED_MODEL ,data_dir = str (data ),mode_ = mode_ ) 655 656def test_iq3_s_on_two_cards_with_a_layer_config_batch_32_starts_with_8 (self ): 657native = Path (self .home .base )/ "x-00001.gguf" 658native .write_bytes (b"g" ) 659cfg = {"gpu" : [0 ,1 ],"split_engine" :"on" ,"args" : ["--pack" ,"/p" ,"--native" ,str (native ),"--mtp" ,"/m/mtp/rt" ,"--max-context" ,"131072" ,"--batch" ,"32" ]} 660d = self .stubbed (cfg ,cards (2 ,cc = 86 )) 661self .assertTrue (d .use_split ,d .reasons ) 662self .assertEqual (cfg ["args" ][cfg ["args" ].index ("--batch" )+ 1 ],"8" ) 663 664def test_the_amd_four_card_default_parallel_32_starts_with_8 (self ): 665native = Path (self .home .base )/ "x-00001.gguf" 666native .write_bytes (b"g" ) 667cfg = {"gpu" : [0 ,1 ,2 ,3 ],"parallel" :32 ,"args" : ["--pack" ,"/p" ,"--native" ,str (native ),"--mtp" ,"/m/mtp/rt" ,"--max-context" ,"131072" ]} 668d = self .stubbed (cfg ,cards (4 ,vendor = "amd" ,arch = "gfx1201" ),mode_ = "auto" ,exe = "/e/strata-split-4-amd" ) 669self .assertTrue (d .use_split ,d .reasons ) 670self .assertEqual (cfg ["args" ][cfg ["args" ].index ("--batch" )+ 1 ],"8" ) 671 672def test_a_profile_parallel_of_16_gives_the_servers_batch_8 (self ): 673from serve .server import parallel_args 674for n ,want in ((16 ,"8" ), (32 ,"8" ), (3 ,"3" ), (8 ,"8" )): 675args = list (SPLIT_ARGS ) 676parallel_args (split_cfg (parallel = n ),args ) 677self .assertEqual (args [args .index ("--batch" )+ 1 ],want ,n ) 678 679 680class AppPath (Base ): 681"""The app's Settings 'Concurrent requests = N' is a profile override on the saved run config (strata_control/profiles); `strata serve --profile` reads it.""" 682 683def engine_argv (self ,cfg :dict ,overrides :dict )-> list [str ]: 684from serve .server import engine_args 685values ,_o = cli ._effective (cfg , {"overrides" :overrides },None ) 686eff = {** cfg ,"args" :list (cfg ["args" ])} 687if values ["parallel" ]is not None : 688eff ["parallel" ]= values ["parallel" ] 689with contextlib .redirect_stdout (io .StringIO ()): 690return engine_args (eff ) 691 692def test_concurrent_requests_on_a_split_config_sets_its_lanes (self ): 693argv = self .engine_argv (split_cfg (lanes = 6 ), {"host" :"127.0.0.1" ,"port" :8080 ,"parallel" :3 }) 694self .assertEqual (argv .count ("--batch" ),1 ) 695self .assertEqual (argv [argv .index ("--batch" )+ 1 ],"3" ) 696 697def test_no_override_keeps_the_lanes_the_launcher_wrote (self ): 698argv = self .engine_argv (split_cfg (lanes = 5 ), {"host" :"127.0.0.1" ,"port" :8080 }) 699self .assertEqual (argv [argv .index ("--batch" )+ 1 ],"5" ) 700 701def test_the_servers_parallel_flag_is_accepted_for_the_split_and_still_refused_beside_another_batch (self ): 702"""`strata serve --profile` hands the profile's parallel to the server as --parallel N; the server refused it next to any --batch in the saved args.""" 703from serve .server import parallel_flag_conflicts 704self .assertFalse (parallel_flag_conflicts (split_cfg ())) 705self .assertFalse (parallel_flag_conflicts (layer_cfg ())) 706self .assertTrue (parallel_flag_conflicts (layer_cfg (args = LAYER_ARGS + ["--batch" ,"6" ]))) 707self .assertTrue (parallel_flag_conflicts (layer_cfg (args = LAYER_ARGS + ["--slots" ,"6" ]))) 708 709def test_the_layer_split_still_takes_its_batch_from_parallel (self ): 710argv = self .engine_argv (layer_cfg (), {"host" :"127.0.0.1" ,"port" :8080 ,"parallel" :3 }) 711self .assertEqual (argv [argv .index ("--batch" )+ 1 ],"3" ) 712 713 714if __name__ == "__main__" : 715unittest .main ()