@simplexai/localmodels-win32-x64 0.1.0-dev.104 → 0.1.0-dev.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/bootstrap.identity +1 -1
  3. package/bootstrap.sha256 +80 -78
  4. package/modules/localmodels/__init__.py +1 -1
  5. package/modules/localmodels/__main__.py +204 -86
  6. package/modules/localmodels/apple_sensors.py +23 -0
  7. package/modules/localmodels/approval.py +25 -2
  8. package/modules/localmodels/catalog.json +454 -31
  9. package/modules/localmodels/catalog.py +11 -0
  10. package/modules/localmodels/catalog_recipes.py +61 -3
  11. package/modules/localmodels/cli_help.py +10 -0
  12. package/modules/localmodels/cli_parser.py +313 -230
  13. package/modules/localmodels/component.py +20 -2
  14. package/modules/localmodels/custom_probe.py +4 -2
  15. package/modules/localmodels/deploy.py +11 -1
  16. package/modules/localmodels/engine_adapters/suite_plan.py +21 -21
  17. package/modules/localmodels/host_sensors.py +25 -2
  18. package/modules/localmodels/hosts.py +26 -5
  19. package/modules/localmodels/library_cli.py +34 -16
  20. package/modules/localmodels/library_custom.py +9 -1
  21. package/modules/localmodels/library_direct.py +41 -1
  22. package/modules/localmodels/library_jobs.py +23 -4
  23. package/modules/localmodels/library_model.py +146 -1
  24. package/modules/localmodels/library_order.py +175 -69
  25. package/modules/localmodels/library_poly.py +42 -11
  26. package/modules/localmodels/library_presentation.py +485 -0
  27. package/modules/localmodels/library_pricing.py +3 -1
  28. package/modules/localmodels/library_serve.py +208 -3
  29. package/modules/localmodels/library_state.py +47 -10
  30. package/modules/localmodels/library_status.py +29 -16
  31. package/modules/localmodels/llm_rank.py +9 -3
  32. package/modules/localmodels/plan_envelope.py +11 -2
  33. package/modules/localmodels/probe.py +34 -7
  34. package/modules/localmodels/quant_formats.py +9 -2
  35. package/modules/localmodels/records.py +19 -2
  36. package/modules/localmodels/remote_ops_verify.py +91 -24
  37. package/modules/localmodels/runtime_index.py +303 -0
  38. package/modules/localmodels/setup_inspection.py +22 -3
  39. package/modules/localmodels/speech_cli.py +20 -14
  40. package/modules/localmodels/speech_serve.py +9 -2
  41. package/modules/localmodels/speech_server.py +3 -0
  42. package/modules/localmodels/stack_args.py +270 -139
  43. package/modules/localmodels/stack_auto.py +90 -5
  44. package/modules/localmodels/stack_cli.py +117 -116
  45. package/modules/localmodels/stack_compose.py +5 -1
  46. package/modules/localmodels/stack_debug.py +14 -4
  47. package/modules/localmodels/stack_down.py +2 -0
  48. package/modules/localmodels/stack_hardware.py +14 -12
  49. package/modules/localmodels/stack_mlx.py +8 -1
  50. package/modules/localmodels/stack_picks.py +19 -20
  51. package/modules/localmodels/stack_plan.py +3 -2
  52. package/modules/localmodels/stack_review.py +28 -7
  53. package/modules/localmodels/stack_suite.py +11 -9
  54. package/modules/localmodels/stack_up.py +2 -0
  55. package/modules/localmodels/stack_view.py +180 -35
  56. package/modules/localmodels/stack_view_demo.py +2 -0
  57. package/modules/localmodels/stack_view_gpu.py +36 -2
  58. package/modules/localmodels/stack_view_schema.py +26 -3
  59. package/modules/localmodels/stack_view_slots.py +3 -1
  60. package/modules/localmodels/stack_view_telemetry.py +90 -4
  61. package/modules/localmodels/stack_view_tick.py +246 -40
  62. package/modules/localmodels/stack_view_words.py +7 -0
  63. package/modules/localmodels/stack_whatif_html.py +9 -12
  64. package/modules/localmodels/suite.py +129 -2
  65. package/modules/localmodels/telemetry_math.py +458 -18
  66. package/modules/localmodels/transport.py +8 -1
  67. package/modules/localmodels/tts_cli.py +24 -20
  68. package/modules/localmodels/tts_serve.py +9 -2
  69. package/modules/localmodels/tts_sidecar.py +3 -0
  70. package/modules/localmodels/web/whatif/app.js +1 -1
  71. package/modules/localmodels/web/whatif/sim.js +8 -14
  72. package/modules/localmodels/win_probe.py +89 -16
  73. package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/METADATA +1 -1
  74. package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/RECORD +76 -74
  75. package/package.json +1 -1
  76. package/tool.json +1 -1
  77. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/WHEEL +0 -0
  78. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/entry_points.txt +0 -0
  79. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/LICENSE +0 -0
  80. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/NOTICE +0 -0
  81. /package/modules/{simplex_localmodels-0.1.0.dev104.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -8,37 +8,15 @@ grouped by purpose, so ``stack plan --help`` scans as model choice, placement, s
8
8
  from __future__ import annotations
9
9
 
10
10
  import argparse
11
+ from collections.abc import Callable
11
12
  from pathlib import Path
12
- from typing import TypeAlias
13
-
14
- from localmodels import (
15
- cli_help,
16
- deploy,
17
- stack_arena,
18
- stack_card,
19
- stack_debug,
20
- stack_down,
21
- stack_ledger,
22
- stack_mcp,
23
- stack_memory,
24
- stack_ports,
25
- stack_rollback,
26
- stack_suite,
27
- stack_try,
28
- stack_up,
29
- stack_update,
30
- stack_view_agent,
31
- stack_view_hub_cli,
32
- stack_view_serve,
33
- stack_warm,
34
- stack_whatif,
35
- vision,
36
- )
37
- from localmodels import stack_decision as decide
38
- from localmodels import stack_doctor as day2
39
- from localmodels import stack_hardware as hardware
40
- from localmodels.context_policy import AGENT, window_k
41
- from localmodels.stack_plan import PREFERENCES, REASONING_BUDGET, StackOptions
13
+ from types import ModuleType
14
+ from typing import TYPE_CHECKING, TypeAlias
15
+
16
+ from localmodels import cli_help
17
+
18
+ if TYPE_CHECKING:
19
+ from localmodels.stack_plan import StackOptions
42
20
 
43
21
  Parsers: TypeAlias = "argparse._SubParsersAction[argparse.ArgumentParser]"
44
22
 
@@ -103,6 +81,8 @@ EXIT = (
103
81
 
104
82
  def _tokens(value: str) -> int:
105
83
  """A token count such as 65536, 64K or 128k (K is 1024)."""
84
+ from localmodels.context_policy import AGENT, window_k
85
+
106
86
  text = value.strip().lower()
107
87
  try:
108
88
  tokens = int(text[:-1]) * 1024 if text.endswith("k") else int(text)
@@ -135,6 +115,9 @@ def _budget(value: str) -> int:
135
115
 
136
116
  def options_from_args(args: argparse.Namespace) -> StackOptions:
137
117
  """The plan options every planning front-end shares (`stack plan`, `install`, the TUI)."""
118
+ from localmodels import stack_debug, stack_suite, vision
119
+ from localmodels import stack_hardware as hardware
120
+
138
121
  options: StackOptions = {
139
122
  "llm": args.llm,
140
123
  "decision": args.decision,
@@ -174,6 +157,11 @@ def options_from_args(args: argparse.Namespace) -> StackOptions:
174
157
 
175
158
  def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
176
159
  """The planning options `stack plan` and `install` share; plan-only extras stay with `plan`."""
160
+ from localmodels import deploy, stack_ports, stack_suite, vision
161
+ from localmodels import stack_decision as decide
162
+ from localmodels import stack_hardware as hardware
163
+ from localmodels.stack_plan import PREFERENCES, REASONING_BUDGET
164
+
177
165
  choose = plan.add_argument_group("what to install")
178
166
  choose.add_argument(
179
167
  "--llm",
@@ -330,6 +318,8 @@ def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
330
318
 
331
319
 
332
320
  def _kv(text: str) -> str:
321
+ from localmodels import stack_debug
322
+
333
323
  try:
334
324
  return stack_debug.parse_kv(text)
335
325
  except ValueError as exc:
@@ -373,6 +363,8 @@ def document_install(parser: argparse.ArgumentParser, prog: str) -> None:
373
363
 
374
364
 
375
365
  def _plan(actions: Parsers) -> None:
366
+ from localmodels import stack_update
367
+
376
368
  plan = actions.add_parser("plan", help="price the whole stack for this computer, save a plan")
377
369
  add_plan_arguments(plan)
378
370
  out = plan.add_argument_group("input and output")
@@ -412,111 +404,224 @@ def _plan(actions: Parsers) -> None:
412
404
  )
413
405
 
414
406
 
415
- def _inspect(actions: Parsers) -> None:
416
- seen = actions.add_parser("hardware", help="each GPU, RAM, disk and what fits (read-only)")
417
- seen.add_argument(
418
- "--facts",
419
- type=Path,
420
- metavar="FILE",
421
- help="read host facts saved earlier instead of probing",
422
- )
423
- seen.add_argument("--json", action="store_true", help="print the readings as JSON")
424
- hardware.add_arguments(seen)
425
- stack_memory.add_parser(actions)
426
- stack_whatif.add_parser(actions)
427
- cli_help.document(
428
- seen,
429
- "Read-only: each GPU's model, VRAM (total, used, free, usable by the agent LLM), spec "
430
- "bandwidth, the processes holding it and the validated LLMs that fit it; then RAM, disk "
431
- "and the hardware tier. Priced the way `stack plan` prices them.",
432
- examples=[
433
- ("%(prog)s", "probe now"),
434
- ("%(prog)s --json", "the same readings as JSON"),
435
- ("%(prog)s --facts host.json", "another host's saved probe"),
436
- ],
437
- )
438
- listed = actions.add_parser("decisions", help="the decision models: VRAM, quality, pros, cons")
439
- cli_help.document(
440
- listed,
441
- "Read-only catalog view of the Jev-like decision models `--decision` accepts: VRAM per "
442
- "prompt limit, measured quality index, latency, license, pros and cons.",
443
- examples=[("%(prog)s", "")],
444
- )
407
+ def _inspect(actions: Parsers, only: str | None = None) -> None:
408
+ if only in (None, "hardware"):
409
+ from localmodels import stack_hardware as hardware
410
+
411
+ seen = actions.add_parser("hardware", help="each GPU, RAM, disk and what fits (read-only)")
412
+ seen.add_argument(
413
+ "--facts",
414
+ type=Path,
415
+ metavar="FILE",
416
+ help="read host facts saved earlier instead of probing",
417
+ )
418
+ seen.add_argument("--json", action="store_true", help="print the readings as JSON")
419
+ hardware.add_arguments(seen)
420
+ cli_help.document(
421
+ seen,
422
+ "Read-only: each GPU's model, VRAM (total, used, free, usable by the agent LLM), spec "
423
+ "bandwidth, the processes holding it and the validated LLMs that fit it; then RAM, disk "
424
+ "and the hardware tier. Priced the way `stack plan` prices them.",
425
+ examples=[
426
+ ("%(prog)s", "probe now"),
427
+ ("%(prog)s --json", "the same readings as JSON"),
428
+ ("%(prog)s --facts host.json", "another host's saved probe"),
429
+ ],
430
+ )
431
+ if only in (None, "memory"):
432
+ from localmodels import stack_memory
433
+
434
+ stack_memory.add_parser(actions)
435
+ if only in (None, "what-if"):
436
+ from localmodels import stack_whatif
437
+
438
+ stack_whatif.add_parser(actions)
439
+ if only in (None, "decisions"):
440
+ listed = actions.add_parser(
441
+ "decisions", help="the decision models: VRAM, quality, pros, cons"
442
+ )
443
+ cli_help.document(
444
+ listed,
445
+ "Read-only catalog view of the Jev-like decision models `--decision` accepts: VRAM per "
446
+ "prompt limit, measured quality index, latency, license, pros and cons.",
447
+ examples=[("%(prog)s", "")],
448
+ )
449
+
450
+
451
+ def _apply(actions: Parsers, only: str | None = None) -> None:
452
+ if only in (None, "apply"):
453
+ run = actions.add_parser("apply", help="install a saved plan you approved (live progress)")
454
+ run.add_argument("plan", type=Path, metavar="PLAN", help="the plan file `stack plan` saved")
455
+ run.add_argument(
456
+ "--approve", required=True, metavar="ID", help="the plan_id printed by stack plan"
457
+ )
458
+ output = run.add_mutually_exclusive_group()
459
+ output.add_argument(
460
+ "--json",
461
+ action="store_true",
462
+ help="one safe result on stdout; progress JSONL on stderr",
463
+ )
464
+ output.add_argument(
465
+ "--jsonl",
466
+ action="store_true",
467
+ help="sanitized progress counters and component results",
468
+ )
469
+ cli_help.document(
470
+ run,
471
+ "Install the plan you reviewed. Apply re-probes first and refuses when anything that "
472
+ "decided the plan changed (re-run `stack plan` then). On a terminal each component gets "
473
+ "a live row: download bar with speed and ETA, model loading, start and verification; "
474
+ "piped output is plain lines. Failed components stay visible; fix and rerun the same "
475
+ "command; files already downloaded are reused.",
476
+ examples=[
477
+ ("%(prog)s PLAN --approve ID", "the command `stack plan` printed"),
478
+ ("%(prog)s PLAN --approve ID --json", "installer protocol: one result object"),
479
+ ],
480
+ sections=[
481
+ ("output", "component verdicts on stdout; progress on stderr (JSONL with --json)"),
482
+ ("exit status", EXIT),
483
+ ],
484
+ )
485
+ if only in (None, "install"):
486
+ install = actions.add_parser("install", help="plan, confirm and apply in one command")
487
+ add_install_arguments(install)
488
+ document_install(install, "%(prog)s")
445
489
 
446
490
 
447
- def _apply(actions: Parsers) -> None:
448
- run = actions.add_parser("apply", help="install a saved plan you approved (live progress)")
449
- run.add_argument("plan", type=Path, metavar="PLAN", help="the plan file `stack plan` saved")
450
- run.add_argument(
451
- "--approve", required=True, metavar="ID", help="the plan_id printed by stack plan"
452
- )
453
- output = run.add_mutually_exclusive_group()
454
- output.add_argument(
455
- "--json", action="store_true", help="one safe result on stdout; progress JSONL on stderr"
456
- )
457
- output.add_argument(
458
- "--jsonl", action="store_true", help="sanitized progress counters and component results"
459
- )
460
- cli_help.document(
461
- run,
462
- "Install the plan you reviewed. Apply re-probes first and refuses when anything that "
463
- "decided the plan changed (re-run `stack plan` then). On a terminal each component gets "
464
- "a live row: download bar with speed and ETA, model loading, start and verification; "
465
- "piped output is plain lines. Failed components stay visible; fix and rerun the same "
466
- "command; files already downloaded are reused.",
467
- examples=[
468
- ("%(prog)s PLAN --approve ID", "the command `stack plan` printed"),
469
- ("%(prog)s PLAN --approve ID --json", "installer protocol: one result object"),
470
- ],
471
- sections=[
472
- ("output", "component verdicts on stdout; progress on stderr (JSONL with --json)"),
473
- ("exit status", EXIT),
474
- ],
475
- )
476
- install = actions.add_parser("install", help="plan, confirm and apply in one command")
477
- add_install_arguments(install)
478
- document_install(install, "%(prog)s")
491
+ def _helpers(actions: Parsers, only: str | None = None) -> None:
492
+ if only in (None, "capabilities"):
493
+ capabilities = actions.add_parser(
494
+ "capabilities", help="machine-readable protocol and feature support"
495
+ )
496
+ capabilities.add_argument(
497
+ "--json",
498
+ action="store_true",
499
+ required=True,
500
+ help="required: the output is JSON only",
501
+ )
502
+ cli_help.document(
503
+ capabilities,
504
+ "Installer feature detection: the package version and the stack features and schemas "
505
+ "this build implements (localmodels.stack-capabilities/v1). Reads no hardware.",
506
+ examples=[("%(prog)s --json", "")],
507
+ )
508
+ if only in (None, "commands"):
509
+ listing = actions.add_parser("commands", help="every stack subcommand and option (--json)")
510
+ listing.add_argument(
511
+ "--json", action="store_true", help="the tree as localmodels.cli-commands/v1"
512
+ )
513
+ cli_help.document(
514
+ listing,
515
+ "List every stack subcommand with its summary; --json adds usage, each option (flags, "
516
+ "value, default, choices, help) and the examples, for agents and completion scripts.",
517
+ examples=[("%(prog)s", "one line per command"), ("%(prog)s --json", "")],
518
+ )
519
+ if only in (None, "mcp"):
520
+ from localmodels import stack_mcp
479
521
 
522
+ stack_mcp.add_parser(actions)
480
523
 
481
- def _helpers(actions: Parsers) -> None:
482
- capabilities = actions.add_parser(
483
- "capabilities", help="machine-readable protocol and feature support"
484
- )
485
- capabilities.add_argument(
486
- "--json", action="store_true", required=True, help="required: the output is JSON only"
487
- )
488
- cli_help.document(
489
- capabilities,
490
- "Installer feature detection: the package version and the stack features and schemas "
491
- "this build implements (localmodels.stack-capabilities/v1). Reads no hardware.",
492
- examples=[("%(prog)s --json", "")],
493
- )
494
- listing = actions.add_parser("commands", help="every stack subcommand and option (--json)")
495
- listing.add_argument(
496
- "--json", action="store_true", help="the tree as localmodels.cli-commands/v1"
497
- )
498
- cli_help.document(
499
- listing,
500
- "List every stack subcommand with its summary; --json adds usage, each option (flags, "
501
- "value, default, choices, help) and the examples, for agents and completion scripts.",
502
- examples=[("%(prog)s", "one line per command"), ("%(prog)s --json", "")],
503
- )
504
- stack_mcp.add_parser(actions)
505
-
506
-
507
- def _day2(actions: Parsers) -> None:
508
- day2.add_parsers(actions)
509
- stack_up.add_parser(actions)
510
- stack_down.add_parser(actions)
511
- stack_warm.add_parser(actions)
512
- stack_try.add_parser(actions)
513
- stack_arena.add_parser(actions)
514
- stack_ledger.add_parser(actions)
515
- stack_card.add_parser(actions)
516
- stack_rollback.add_parser(actions)
517
- stack_view_serve.add_parser(actions)
518
- stack_view_hub_cli.add_parser(actions)
519
- stack_view_agent.add_parser(actions)
524
+
525
+ def _load_up() -> ModuleType:
526
+ from localmodels import stack_up
527
+
528
+ return stack_up
529
+
530
+
531
+ def _load_down() -> ModuleType:
532
+ from localmodels import stack_down
533
+
534
+ return stack_down
535
+
536
+
537
+ def _load_warm() -> ModuleType:
538
+ from localmodels import stack_warm
539
+
540
+ return stack_warm
541
+
542
+
543
+ def _load_try() -> ModuleType:
544
+ from localmodels import stack_try
545
+
546
+ return stack_try
547
+
548
+
549
+ def _load_arena() -> ModuleType:
550
+ from localmodels import stack_arena
551
+
552
+ return stack_arena
553
+
554
+
555
+ def _load_ledger() -> ModuleType:
556
+ from localmodels import stack_ledger
557
+
558
+ return stack_ledger
559
+
560
+
561
+ def _load_card() -> ModuleType:
562
+ from localmodels import stack_card
563
+
564
+ return stack_card
565
+
566
+
567
+ def _load_rollback() -> ModuleType:
568
+ from localmodels import stack_rollback
569
+
570
+ return stack_rollback
571
+
572
+
573
+ def _load_view() -> ModuleType:
574
+ from localmodels import stack_view_serve
575
+
576
+ return stack_view_serve
577
+
578
+
579
+ def _load_view_hub() -> ModuleType:
580
+ from localmodels import stack_view_hub_cli
581
+
582
+ return stack_view_hub_cli
583
+
584
+
585
+ def _load_view_agent() -> ModuleType:
586
+ from localmodels import stack_view_agent
587
+
588
+ return stack_view_agent
589
+
590
+
591
+ def _load_doctor() -> ModuleType:
592
+ from localmodels import stack_doctor
593
+
594
+ return stack_doctor
595
+
596
+
597
+ DAY2_LOADERS: dict[str, Callable[[], ModuleType]] = {
598
+ "up": _load_up,
599
+ "down": _load_down,
600
+ "warm": _load_warm,
601
+ "try": _load_try,
602
+ "arena": _load_arena,
603
+ "ledger": _load_ledger,
604
+ "card": _load_card,
605
+ "rollback": _load_rollback,
606
+ "view": _load_view,
607
+ "view-hub": _load_view_hub,
608
+ "view-agent": _load_view_agent,
609
+ }
610
+ DOCTOR_COMMANDS = frozenset({"status", "verify", "doctor", "remove", "prune"})
611
+
612
+
613
+ def day2_module(command_name: str) -> ModuleType:
614
+ """Lazily load the single day-2 handler module for ``command_name``."""
615
+ loader = DAY2_LOADERS.get(command_name, _load_doctor)
616
+ return loader()
617
+
618
+
619
+ def _day2(actions: Parsers, only: str | None = None) -> None:
620
+ if only is None or only in DOCTOR_COMMANDS:
621
+ _load_doctor().add_parsers(actions)
622
+ for name, loader in DAY2_LOADERS.items():
623
+ if only is None or only == name:
624
+ loader().add_parser(actions)
520
625
  docs = {
521
626
  "status": (
522
627
  "each deployment's state, health and disk, the last run (read-only)",
@@ -598,17 +703,43 @@ def _day2(actions: Parsers) -> None:
598
703
  ),
599
704
  }
600
705
  for name, (summary, description, examples) in docs.items():
601
- cli_help.summarize(actions, name, summary)
602
- cli_help.document(actions.choices[name], description, examples=examples)
706
+ if name in actions.choices:
707
+ cli_help.summarize(actions, name, summary)
708
+ cli_help.document(actions.choices[name], description, examples=examples)
709
+
710
+
711
+ _INSPECT_COMMANDS = frozenset({"hardware", "memory", "what-if", "decisions"})
712
+ _APPLY_COMMANDS = frozenset({"apply", "install"})
713
+ _HELPER_COMMANDS = frozenset({"capabilities", "commands", "mcp"})
714
+ _KNOWN_STACK_COMMANDS = (
715
+ frozenset({"plan"})
716
+ | _INSPECT_COMMANDS
717
+ | _APPLY_COMMANDS
718
+ | _HELPER_COMMANDS
719
+ | DOCTOR_COMMANDS
720
+ | frozenset(DAY2_LOADERS)
721
+ )
603
722
 
604
723
 
605
- def add_parser(sub: Parsers) -> None:
724
+ def add_parser(sub: Parsers, *, only: str | None = None) -> None:
606
725
  p = sub.add_parser("stack", help="the local agent stack: plan, install, operate, remove")
607
726
  actions = p.add_subparsers(dest="stack_command", required=True, metavar="COMMAND")
608
- _plan(actions)
609
- _inspect(actions)
610
- _apply(actions)
611
- _day2(actions)
612
- _helpers(actions)
727
+ target = only if only in _KNOWN_STACK_COMMANDS else None
728
+ if target is None:
729
+ _plan(actions)
730
+ _inspect(actions)
731
+ _apply(actions)
732
+ _day2(actions)
733
+ _helpers(actions)
734
+ elif target == "plan":
735
+ _plan(actions)
736
+ elif target in _INSPECT_COMMANDS:
737
+ _inspect(actions, only=target)
738
+ elif target in _APPLY_COMMANDS:
739
+ _apply(actions, only=target)
740
+ elif target in _HELPER_COMMANDS:
741
+ _helpers(actions, only=target)
742
+ else:
743
+ _day2(actions, only=target)
613
744
  cli_help.document(p, STACK, sections=[("for agents", AGENTS), ("exit status", EXIT)])
614
745
  cli_help.group_commands(p, GROUPS)
@@ -35,7 +35,7 @@ from localmodels.estimator import HardwareBudget
35
35
  from localmodels.plan_envelope import PlanError
36
36
  from localmodels.planning import llm_ram
37
37
  from localmodels.planning.budget import HARNESS_RAM, RAM_FLOOR, gpu_conflicts, host_ram
38
- from localmodels.probe import HostFacts
38
+ from localmodels.probe import GPU, HostFacts
39
39
  from localmodels.records import PinnedFile, Plan
40
40
  from localmodels.stack_plan import (
41
41
  DecisionChoice,
@@ -61,6 +61,49 @@ DEFAULT_READS: LlamaReads = (
61
61
  )
62
62
 
63
63
 
64
+ def _part_gpu(facts: HostFacts, parts: Parts) -> GPU | None:
65
+ raw_gpu = parts["budget"].get("gpu")
66
+ if not isinstance(raw_gpu, dict):
67
+ return None
68
+ idx = raw_gpu.get("index")
69
+ return next((g for g in facts.get("gpus") or [] if g["index"] == idx), None)
70
+
71
+
72
+ def _poly_concurrent_ok(recipe: suite.SuiteRecipe, gpu: GPU | None, parts: Parts) -> bool:
73
+ if recipe.get("runtime") != "strata-poly" or not suite.poly_gpu_resident(recipe, gpu):
74
+ return False
75
+ return int(str(parts["llm"]["launch"].get("slots") or 1)) >= 2
76
+
77
+
78
+ def _llama_decode_tok_s(
79
+ facts: HostFacts, options: StackOptions, llama_id: str, gpu_index: int
80
+ ) -> float | None:
81
+ if not llama_id:
82
+ return None
83
+ entry = cat.find_entry(llama_id)
84
+ if entry is None:
85
+ return None
86
+ variant = entry.variants[-1]
87
+ measured = stack_warm_store.lookup(facts, gpu_index, entry.id, variant.quant)
88
+ if measured is not None:
89
+ return round(measured, 1)
90
+ card_budget = stack_capacity.llm_budget(facts, gpu_index, options, entry=entry)[0]
91
+ return round(cat.decode_estimate(entry, variant, card_budget).tok_s, 1)
92
+
93
+
94
+ def _poly_decode_for_gpu(
95
+ facts: HostFacts, recipe: suite.SuiteRecipe, gpu: GPU | None, quant: str
96
+ ) -> tuple[float | None, str]:
97
+ if gpu is not None:
98
+ measured = stack_warm_store.lookup(facts, gpu["index"], recipe["id"], quant)
99
+ if measured is not None:
100
+ return round(measured, 1), "measured-decode"
101
+ est = suite.poly_decode_estimate(recipe, gpu)
102
+ if est is not None:
103
+ return round(est.tok_s, 1), est.basis
104
+ return None, "unavailable"
105
+
106
+
64
107
  def strata_parts(
65
108
  facts: HostFacts,
66
109
  options: StackOptions,
@@ -85,6 +128,7 @@ def strata_parts(
85
128
  refused). A recipe that no longer fits falls through to the ranking, and apply refuses the
86
129
  changed plan."""
87
130
  bar, llama_id = llama
131
+ prefer = str(options.get("prefer") or "smartest")
88
132
  skipped: list[str] = []
89
133
  ranked = stack_suite.auto_strata_candidates(
90
134
  facts, llm_rank.strata_bar(bar, options), llama_score=bar, options=options
@@ -92,12 +136,14 @@ def strata_parts(
92
136
  kept = approved_strata_recipe(facts, approved)
93
137
  if kept is not None:
94
138
  ranked = [kept, *(r for r in ranked if r["id"] != kept["id"])]
139
+ fastest_best: tuple[float, Parts, StackOptions] | None = None
95
140
  for recipe in ranked:
96
141
  score = recipe.get("quality", {}).get("score")
142
+ keeping = kept is not None and recipe["id"] == kept["id"]
97
143
  why = (
98
144
  (
99
145
  f"LLM: auto keeps the approved Strata {recipe['id']}"
100
- if kept is not None and recipe["id"] == kept["id"]
146
+ if keeping
101
147
  else f"LLM: auto picks Strata {recipe['id']}"
102
148
  )
103
149
  + f" (installed SimplexAI score {score}"
@@ -106,7 +152,7 @@ def strata_parts(
106
152
  if llama_id
107
153
  else ", no llama.cpp model fits"
108
154
  )
109
- + f", --prefer {options.get('prefer') or 'smartest'})"
155
+ + f", --prefer {prefer})"
110
156
  )
111
157
  try:
112
158
  candidate_options = options.copy()
@@ -120,6 +166,35 @@ def strata_parts(
120
166
  owned_ram=owned_ram,
121
167
  approved=approved,
122
168
  )
169
+ gpu = _part_gpu(facts, parts)
170
+ if (
171
+ not keeping
172
+ and prefer == "concurrent"
173
+ and not _poly_concurrent_ok(recipe, gpu, parts)
174
+ ):
175
+ raise StackError(
176
+ f"{recipe['id']} is offloaded or single-slot on this GPU; "
177
+ "skipped for --prefer concurrent"
178
+ )
179
+ poly_speed: float | None = None
180
+ if not keeping and prefer == "fastest" and llama_id and bar >= 0:
181
+ if not _poly_concurrent_ok(recipe, gpu, parts):
182
+ raise StackError(
183
+ f"{recipe['id']} is offloaded or single-slot on this GPU; "
184
+ "skipped for --prefer fastest"
185
+ )
186
+ poly_speed, _ = _poly_decode_for_gpu(
187
+ facts, recipe, gpu, str(parts["llm"]["model"]["quant"])
188
+ )
189
+ llama_speed = (
190
+ _llama_decode_tok_s(facts, options, llama_id, gpu["index"])
191
+ if gpu is not None
192
+ else None
193
+ )
194
+ if poly_speed is None or (llama_speed is not None and poly_speed <= llama_speed):
195
+ raise StackError(
196
+ f"{recipe['id']} estimated decode speed does not beat llama.cpp {llama_id}"
197
+ )
123
198
  missing = [
124
199
  f for f in parts["llm"]["files"] if f.get("generated") and not preparation.ready(f)
125
200
  ]
@@ -139,8 +214,15 @@ def strata_parts(
139
214
  f"(installed SimplexAI score {score}): {exc}"
140
215
  )
141
216
  continue
217
+ if not keeping and prefer == "fastest" and llama_id and bar >= 0 and poly_speed is not None:
218
+ if fastest_best is None or poly_speed > fastest_best[0]:
219
+ fastest_best = (poly_speed, parts, candidate_options)
220
+ continue
142
221
  options.update(candidate_options)
143
222
  return parts
223
+ if fastest_best is not None:
224
+ options.update(fastest_best[2])
225
+ return fastest_best[1]
144
226
  passed_over.extend(skipped)
145
227
  return None
146
228
 
@@ -197,6 +279,8 @@ def card_fits(
197
279
  previous=lambda *_: None,
198
280
  owned_ram=lambda: 0,
199
281
  )
282
+ if prefer == "concurrent" and not _poly_concurrent_ok(recipe, gpu, parts):
283
+ continue
200
284
  if (
201
285
  share
202
286
  and int(str(parts["budget"].get("vram_needed_bytes") or 0)) > gpu["free_bytes"]
@@ -222,13 +306,14 @@ def card_fits(
222
306
  )
223
307
  except (StackError, PlanError):
224
308
  continue
309
+ est = suite.poly_decode_estimate(recipe, gpu)
225
310
  fits.append(
226
311
  {
227
312
  "id": recipe["id"],
228
313
  "quant": str(parts["llm"]["model"]["quant"]),
229
314
  "quality": recipe["quality"]["score"],
230
- "decode_tok_s": None,
231
- "decode_basis": "unavailable",
315
+ "decode_tok_s": round(est.tok_s, 1) if est is not None else None,
316
+ "decode_basis": est.basis if est is not None else "unavailable",
232
317
  }
233
318
  )
234
319
  return fits