vllm_mlx.model_registry¶
Registry-backed multi-model serving with memory-budget eviction.
View the complete module source at #L1-L1201.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
vllm_mlx.model_registry
¶
Registry-backed multi-model serving with memory-budget eviction.
The registry maps OpenAI-compatible model names to concrete local paths or
declared HuggingFace IDs. Models are loaded lazily, optionally preloaded, and
evicted according to a memory-budget policy with configurable wait/fail/preempt
behaviour.
vllm_mlx.model_registry._ownership_registry
module-attribute
¶
_ownership_registry = _ModelOwnershipRegistry()
vllm_mlx.model_registry.ContentionStrategy
module-attribute
¶
vllm_mlx.model_registry.EngineFactory
module-attribute
¶
EngineFactory = Callable[['ResolvedModelConfig'], BaseEngine]
vllm_mlx.model_registry.ModelOwnershipError
¶
Bases: RuntimeError
Raised when an EngineCore attempts to use a model already in use.
vllm_mlx.model_registry._ModelOwnershipRegistry
¶
Process-local model ownership guard used by EngineCore.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry._ModelOwnershipRegistry._owners
instance-attribute
¶
vllm_mlx.model_registry._ModelOwnershipRegistry.acquire
¶
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry._ModelOwnershipRegistry.release
¶
vllm_mlx.model_registry._ModelOwnershipRegistry.is_owned
¶
vllm_mlx.model_registry.RegistryServeDefaults
dataclass
¶
RegistryServeDefaults(continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str | None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig | None, max_tokens: int, download_config: DownloadConfig)
Global serve defaults inherited by registry entries.
vllm_mlx.model_registry.RegistryServeDefaults.continuous_batching
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.prefill_step_size
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.specprefill_enabled
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.specprefill_threshold
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.specprefill_keep_pct
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.specprefill_backbone_pct
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.specprefill_draft_model
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.stream_interval
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.gpu_memory_utilization
instance-attribute
¶
vllm_mlx.model_registry.RegistryServeDefaults.scheduler_config
instance-attribute
¶
scheduler_config: SchedulerConfig | None
vllm_mlx.model_registry.RegistryServeDefaults.download_config
instance-attribute
¶
download_config: DownloadConfig
vllm_mlx.model_registry.ContentionPolicy
dataclass
¶
ContentionPolicy(strategy: ContentionStrategy = 'wait_then_fail', wait_timeout_s: float | None = 30.0, preempt_after_s: float | None = None)
Policy used when a new model cannot fit inside the memory budget.
vllm_mlx.model_registry.ContentionPolicy.strategy
class-attribute
instance-attribute
¶
strategy: ContentionStrategy = 'wait_then_fail'
vllm_mlx.model_registry.ContentionPolicy.wait_timeout_s
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.ContentionPolicy.preempt_after_s
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegistryManagerConfig
dataclass
¶
RegistryManagerConfig(memory_budget_bytes: int, policy: ContentionPolicy)
Global registry manager configuration.
vllm_mlx.model_registry.RegistryManagerConfig.memory_budget_bytes
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel
dataclass
¶
RegisteredModel(name: str, source: str, preload: bool = False, continuous_batching: bool | None = None, force_mllm: bool | None = None, enable_mtp: bool | None = None, prefill_step_size: int | None = None, specprefill_enabled: bool | None = None, specprefill_threshold: int | None = None, specprefill_keep_pct: float | None = None, specprefill_backbone_pct: float | None = None, specprefill_draft_model: str | None = None, stream_interval: int | None = None, gpu_memory_utilization: float | None = None, estimated_memory_bytes: int | None = None)
One configured model entry.
vllm_mlx.model_registry.RegisteredModel.preload
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.continuous_batching
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.force_mllm
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.enable_mtp
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.prefill_step_size
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.specprefill_enabled
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.specprefill_threshold
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.specprefill_keep_pct
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.specprefill_backbone_pct
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.specprefill_draft_model
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.stream_interval
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.gpu_memory_utilization
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.RegisteredModel.estimated_memory_bytes
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig
dataclass
¶
ResolvedModelConfig(entry: RegisteredModel, resolved_source: str, continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str | None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig | None, estimated_memory_bytes: int)
Effective configuration for a loaded model.
vllm_mlx.model_registry.ResolvedModelConfig.resolved_source
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.continuous_batching
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.prefill_step_size
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.specprefill_enabled
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.specprefill_threshold
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.specprefill_keep_pct
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.specprefill_backbone_pct
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.specprefill_draft_model
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.stream_interval
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.gpu_memory_utilization
instance-attribute
¶
vllm_mlx.model_registry.ResolvedModelConfig.scheduler_config
instance-attribute
¶
scheduler_config: SchedulerConfig | None
vllm_mlx.model_registry.ResolvedModelConfig.estimated_memory_bytes
instance-attribute
¶
vllm_mlx.model_registry.LoadedModel
dataclass
¶
LoadedModel(config: ResolvedModelConfig, engine: BaseEngine, loaded_at: float = time(), last_used_at: float = time(), active_requests: int = 0, active_tasks: set[Task[Any]] = set(), preempting: bool = False)
Runtime state for a loaded engine.
vllm_mlx.model_registry.LoadedModel.loaded_at
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.LoadedModel.last_used_at
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.LoadedModel.active_requests
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.LoadedModel.active_tasks
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.LoadedModel.preempting
class-attribute
instance-attribute
¶
vllm_mlx.model_registry.PendingLoad
dataclass
¶
PendingLoad(model_name: str, required_bytes: int, future: Future[LoadedModel])
A reserved model load in progress.
vllm_mlx.model_registry.ModelLease
dataclass
¶
ModelLease(manager: 'ModelManager | None', model_name: str, engine: BaseEngine, release_cb: Callable[[], Awaitable[None]])
vllm_mlx.model_registry.MemoryBudgetReport
dataclass
¶
MemoryBudgetReport(budget_bytes: int, device_working_set_bytes: int | None, gpu_memory_utilization: float | None, gpu_memory_utilization_source: str | None, per_engine_cache_limit_bytes: int | None, per_engine_cache_percent: float | None, continuous_batching_entries: int, total_entries: int)
Reconciliation of the manager weight budget with the Metal ceiling.
The manager budget counts model weights only, and the Metal allocation
ceiling (gpu_memory_utilization x device working set) is process-wide.
Those two are directly comparable, so a budget above the ceiling is a
deterministic conflict: the manager will keep models resident that MLX
cannot allocate, and the load fails instead of evicting.
The prefix-cache limit is deliberately not folded into that comparison.
cache_memory_mb is a per-engine maximum — it is cloned into each
resident continuous-batching engine and allocated lazily, and simple-mode
entries never receive it at all — so it is neither a single process-wide
reservation nor a bound that can be subtracted once. It is reported
alongside the ceiling instead, with its own conflict check.
vllm_mlx.model_registry.MemoryBudgetReport.device_working_set_bytes
instance-attribute
¶
vllm_mlx.model_registry.MemoryBudgetReport.gpu_memory_utilization
instance-attribute
¶
vllm_mlx.model_registry.MemoryBudgetReport.gpu_memory_utilization_source
instance-attribute
¶
vllm_mlx.model_registry.MemoryBudgetReport.per_engine_cache_limit_bytes
instance-attribute
¶
vllm_mlx.model_registry.MemoryBudgetReport.per_engine_cache_percent
instance-attribute
¶
vllm_mlx.model_registry.MemoryBudgetReport.continuous_batching_entries
instance-attribute
¶
vllm_mlx.model_registry.MemoryBudgetReport.allocation_ceiling_bytes
property
¶
Metal soft allocation limit that will be installed at engine start.
None when no ceiling can be attributed: either MLX cannot report a
device working set, or no entry will install one (only BatchedEngine
calls mx.set_memory_limit).
vllm_mlx.model_registry.MemoryBudgetReport.exceeds_ceiling
property
¶
True when the weights budget alone cannot fit under the ceiling.
Both sides are process-wide totals, so this is the deterministic check.
vllm_mlx.model_registry.MemoryBudgetReport.cache_limit_exceeds_ceiling
property
¶
True when one engine's prefix cache could alone fill the ceiling.
vllm_mlx.model_registry.ModelManager
¶
ModelManager(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory | None = None)
Registry-backed model manager with lazy load and memory-budget eviction.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._engine_factory
instance-attribute
¶
vllm_mlx.model_registry.ModelManager._loaded
instance-attribute
¶
_loaded: dict[str, LoadedModel] = {}
vllm_mlx.model_registry.ModelManager._loading
instance-attribute
¶
_loading: dict[str, PendingLoad] = {}
vllm_mlx.model_registry.ModelManager._unloading
instance-attribute
¶
_unloading: dict[str, LoadedModel] = {}
vllm_mlx.model_registry.ModelManager._condition
instance-attribute
¶
vllm_mlx.model_registry.ModelManager.memory_budget_bytes
property
¶
Return the registry's configured resident-model memory budget.
vllm_mlx.model_registry.ModelManager.registered_model_names
property
¶
Return sorted list of all registered model names.
vllm_mlx.model_registry.ModelManager.has_model
¶
vllm_mlx.model_registry.ModelManager.list_models
¶
Return registry state for /v1/models.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager.preload
async
¶
Preload any entries marked preload=true.
vllm_mlx.model_registry.ModelManager.shutdown
async
¶
Stop and unload every loaded engine.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager.acquire
async
¶
acquire(model_name: str) -> ModelLease
Acquire a lease for a configured model.
Source code in vllm_mlx/model_registry.py
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | |
vllm_mlx.model_registry.ModelManager.release
async
¶
Release a previously acquired model lease.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._claim_loaded_locked
¶
_claim_loaded_locked(model_name: str, *, loaded_override: LoadedModel | None = None) -> ModelLease | None
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._execute_load
async
¶
_execute_load(pending: PendingLoad) -> LoadedModel
Instantiate a reserved model load outside the manager lock.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._wait_for_change
async
¶
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._run_unloads
async
¶
_run_unloads(unloads: list[LoadedModel]) -> None
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._reserve_load_locked
¶
_reserve_load_locked(model_name: str, required_bytes: int) -> PendingLoad
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._begin_unload_locked
¶
_begin_unload_locked(model_name: str) -> LoadedModel
vllm_mlx.model_registry.ModelManager._collect_idle_unloads_locked
¶
_collect_idle_unloads_locked(requested_model: str, required_bytes: int) -> list[LoadedModel]
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._maybe_preempt_locked
¶
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._should_wait_locked
¶
vllm_mlx.model_registry.ModelManager._should_preempt_locked
¶
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._remaining_wait_timeout
¶
vllm_mlx.model_registry.ModelManager._can_reserve_locked
¶
vllm_mlx.model_registry.ModelManager._committed_bytes_locked
¶
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._instantiate_model
async
¶
_instantiate_model(entry: RegisteredModel, resolved_source: str) -> LoadedModel
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._resolve_source
async
¶
_resolve_source(entry: RegisteredModel) -> str
vllm_mlx.model_registry.ModelManager._resolve_source_sync
¶
_resolve_source_sync(entry: RegisteredModel) -> str
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._resolve_estimated_bytes
¶
_resolve_estimated_bytes(entry: RegisteredModel, resolved_source: str) -> int
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.ModelManager._resolve_model_config
¶
_resolve_model_config(entry: RegisteredModel, resolved_source: str) -> ResolvedModelConfig
Source code in vllm_mlx/model_registry.py
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 | |
vllm_mlx.model_registry.get_registry
¶
get_registry() -> _ModelOwnershipRegistry
vllm_mlx.model_registry._clone_scheduler_config
¶
_clone_scheduler_config(config: SchedulerConfig | None) -> SchedulerConfig | None
Clone a SchedulerConfig so per-model overrides do not mutate globals.
vllm_mlx.model_registry._parse_memory_budget_bytes
¶
Parse a memory budget from bytes, MB, or GB.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry._safe_available_memory_bytes
¶
vllm_mlx.model_registry._device_working_set_bytes
¶
Best-effort Metal recommended working-set size, or None when unavailable.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.build_memory_budget_report
¶
build_memory_budget_report(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, device_working_set_bytes: int | None = None) -> MemoryBudgetReport
Reconcile the manager weight budget against the Metal allocation ceiling.
The Metal limit is process-wide but is re-installed by every
BatchedEngine start, so the ceiling the manager has to live under is the
lowest utilization among the entries that actually install one. Only
continuous-batching entries qualify: SimpleEngine never calls
mx.set_memory_limit and is not even given a gpu_memory_utilization.
A registry with no continuous-batching entries therefore gets no attributed
ceiling rather than one derived from a value nothing installs.
Source code in vllm_mlx/model_registry.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
vllm_mlx.model_registry.log_memory_budget_report
¶
log_memory_budget_report(report: MemoryBudgetReport) -> None
Log the budget/ceiling reconciliation, warning when they conflict.
Source code in vllm_mlx/model_registry.py
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
vllm_mlx.model_registry._estimate_model_bytes_from_source
¶
Estimate model footprint from local artifact size when possible.
Source code in vllm_mlx/model_registry.py
vllm_mlx.model_registry.load_registry_config
¶
load_registry_config(config_path: str | PathLike[str], defaults: RegistryServeDefaults) -> tuple[RegistryManagerConfig, dict[str, RegisteredModel]]
Load and validate the models registry YAML file.
Source code in vllm_mlx/model_registry.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
vllm_mlx.model_registry.ModelOwnershipError · class
Raised when an EngineCore attempts to use a model already in use.
Parameters
This callable has no explicit inputs.
Returns
- Constructs:
vllm_mlx.model_registry.ModelOwnershipError
Exceptions and behavior
Class ModelOwnershipError derives from RuntimeError and declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry._ModelOwnershipRegistry · class
Process-local model ownership guard used by EngineCore.
Parameters
This callable has no explicit inputs.
Returns
- Constructs:
vllm_mlx.model_registry._ModelOwnershipRegistry
Exceptions and behavior
Class _ModelOwnershipRegistry declares 5 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry._ModelOwnershipRegistry.__init__ · method
Method _ModelOwnershipRegistry.__init__ updates self._owners.
Parameters
This callable has no explicit inputs.
Returns
- Type:
None
Exceptions and behavior
Method _ModelOwnershipRegistry.__init__ updates self._owners.
No direct raise statement appears in this definition.
vllm_mlx.model_registry._ModelOwnershipRegistry.acquire · method
vllm_mlx.model_registry._ModelOwnershipRegistry.acquire(*, model: Any, engine: Any, engine_id: str, force: bool = True) -> None
Method _ModelOwnershipRegistry.acquire calls id, self._owners.get, ModelOwnershipError; can raise ModelOwnershipError.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model |
Any |
yes |
none |
Required keyword-only input. |
engine |
Any |
yes |
none |
Required keyword-only input. |
engine_id |
str |
yes |
none |
Required keyword-only input. |
force |
bool |
no |
True |
Optional keyword-only input; defaults to True. |
Returns
- Type:
None
Exceptions and behavior
Method _ModelOwnershipRegistry.acquire calls id, self._owners.get, ModelOwnershipError; can raise ModelOwnershipError.
Directly raised exceptions: ModelOwnershipError.
vllm_mlx.model_registry._ModelOwnershipRegistry.release · method
Method _ModelOwnershipRegistry.release calls id, self._owners.get, self._owners.pop.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model |
Any |
yes |
none |
Required positional or keyword input. |
engine_id |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
None
Exceptions and behavior
Method _ModelOwnershipRegistry.release calls id, self._owners.get, self._owners.pop.
No direct raise statement appears in this definition.
vllm_mlx.model_registry._ModelOwnershipRegistry.is_owned · method
Method _ModelOwnershipRegistry.is_owned calls id, self._owners.get; has 2 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model |
Any |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
tuple[bool, str | None] - Direct return expressions:
(True, owner);(False, None)
Exceptions and behavior
Method _ModelOwnershipRegistry.is_owned calls id, self._owners.get; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry._ModelOwnershipRegistry.get_stats · method
Method _ModelOwnershipRegistry.get_stats calls len; returns {'total_entries': len(self._owners), 'active_owners': len(self._owners)}.
Parameters
This callable has no explicit inputs.
Returns
- Type:
dict[str, Any] - Direct return expressions:
{'total_entries': len(self._owners), 'active_owners': len(self._owners)}
Exceptions and behavior
Method _ModelOwnershipRegistry.get_stats calls len; returns {'total_entries': len(self._owners), 'active_owners': len(self._owners)}.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.get_registry · function
Return the global model ownership registry used by EngineCore.
Parameters
This callable has no explicit inputs.
Returns
- Type:
_ModelOwnershipRegistry - Direct return expressions:
_ownership_registry
Exceptions and behavior
Function get_registry returns _ownership_registry.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.RegistryServeDefaults · class
vllm_mlx.model_registry.RegistryServeDefaults(continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str | None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig | None, max_tokens: int, download_config: DownloadConfig)
Global serve defaults inherited by registry entries.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
continuous_batching |
bool |
yes |
none |
Required constructor field. |
force_mllm |
bool |
yes |
none |
Required constructor field. |
enable_mtp |
bool |
yes |
none |
Required constructor field. |
prefill_step_size |
int |
yes |
none |
Required constructor field. |
specprefill_enabled |
bool |
yes |
none |
Required constructor field. |
specprefill_threshold |
int |
yes |
none |
Required constructor field. |
specprefill_keep_pct |
float |
yes |
none |
Required constructor field. |
specprefill_backbone_pct |
float |
yes |
none |
Required constructor field. |
specprefill_draft_model |
str \| None |
yes |
none |
Required constructor field. |
stream_interval |
int |
yes |
none |
Required constructor field. |
gpu_memory_utilization |
float |
yes |
none |
Required constructor field. |
scheduler_config |
SchedulerConfig \| None |
yes |
none |
Required constructor field. |
max_tokens |
int |
yes |
none |
Required constructor field. |
download_config |
DownloadConfig |
yes |
none |
Required constructor field. |
Returns
- Constructs:
vllm_mlx.model_registry.RegistryServeDefaults
Exceptions and behavior
Class RegistryServeDefaults declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ContentionPolicy · class
vllm_mlx.model_registry.ContentionPolicy(strategy: ContentionStrategy = 'wait_then_fail', wait_timeout_s: float | None = 30.0, preempt_after_s: float | None = None)
Policy used when a new model cannot fit inside the memory budget.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
strategy |
ContentionStrategy |
no |
'wait_then_fail' |
Optional constructor field; defaults to 'wait_then_fail'. |
wait_timeout_s |
float \| None |
no |
30.0 |
Optional constructor field; defaults to 30.0. |
preempt_after_s |
float \| None |
no |
None |
Optional constructor field; defaults to None. |
Returns
- Constructs:
vllm_mlx.model_registry.ContentionPolicy
Exceptions and behavior
Class ContentionPolicy declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.RegistryManagerConfig · class
Global registry manager configuration.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
memory_budget_bytes |
int |
yes |
none |
Required constructor field. |
policy |
ContentionPolicy |
yes |
none |
Required constructor field. |
Returns
- Constructs:
vllm_mlx.model_registry.RegistryManagerConfig
Exceptions and behavior
Class RegistryManagerConfig declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.RegisteredModel · class
vllm_mlx.model_registry.RegisteredModel(name: str, source: str, preload: bool = False, continuous_batching: bool | None = None, force_mllm: bool | None = None, enable_mtp: bool | None = None, prefill_step_size: int | None = None, specprefill_enabled: bool | None = None, specprefill_threshold: int | None = None, specprefill_keep_pct: float | None = None, specprefill_backbone_pct: float | None = None, specprefill_draft_model: str | None = None, stream_interval: int | None = None, gpu_memory_utilization: float | None = None, estimated_memory_bytes: int | None = None)
One configured model entry.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name |
str |
yes |
none |
Required constructor field. |
source |
str |
yes |
none |
Required constructor field. |
preload |
bool |
no |
False |
Optional constructor field; defaults to False. |
continuous_batching |
bool \| None |
no |
None |
Optional constructor field; defaults to None. |
force_mllm |
bool \| None |
no |
None |
Optional constructor field; defaults to None. |
enable_mtp |
bool \| None |
no |
None |
Optional constructor field; defaults to None. |
prefill_step_size |
int \| None |
no |
None |
Optional constructor field; defaults to None. |
specprefill_enabled |
bool \| None |
no |
None |
Optional constructor field; defaults to None. |
specprefill_threshold |
int \| None |
no |
None |
Optional constructor field; defaults to None. |
specprefill_keep_pct |
float \| None |
no |
None |
Optional constructor field; defaults to None. |
specprefill_backbone_pct |
float \| None |
no |
None |
Optional constructor field; defaults to None. |
specprefill_draft_model |
str \| None |
no |
None |
Optional constructor field; defaults to None. |
stream_interval |
int \| None |
no |
None |
Optional constructor field; defaults to None. |
gpu_memory_utilization |
float \| None |
no |
None |
Optional constructor field; defaults to None. |
estimated_memory_bytes |
int \| None |
no |
None |
Optional constructor field; defaults to None. |
Returns
- Constructs:
vllm_mlx.model_registry.RegisteredModel
Exceptions and behavior
Class RegisteredModel declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ResolvedModelConfig · class
vllm_mlx.model_registry.ResolvedModelConfig(entry: RegisteredModel, resolved_source: str, continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str | None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig | None, estimated_memory_bytes: int)
Effective configuration for a loaded model.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
entry |
RegisteredModel |
yes |
none |
Required constructor field. |
resolved_source |
str |
yes |
none |
Required constructor field. |
continuous_batching |
bool |
yes |
none |
Required constructor field. |
force_mllm |
bool |
yes |
none |
Required constructor field. |
enable_mtp |
bool |
yes |
none |
Required constructor field. |
prefill_step_size |
int |
yes |
none |
Required constructor field. |
specprefill_enabled |
bool |
yes |
none |
Required constructor field. |
specprefill_threshold |
int |
yes |
none |
Required constructor field. |
specprefill_keep_pct |
float |
yes |
none |
Required constructor field. |
specprefill_backbone_pct |
float |
yes |
none |
Required constructor field. |
specprefill_draft_model |
str \| None |
yes |
none |
Required constructor field. |
stream_interval |
int |
yes |
none |
Required constructor field. |
gpu_memory_utilization |
float |
yes |
none |
Required constructor field. |
scheduler_config |
SchedulerConfig \| None |
yes |
none |
Required constructor field. |
estimated_memory_bytes |
int |
yes |
none |
Required constructor field. |
Returns
- Constructs:
vllm_mlx.model_registry.ResolvedModelConfig
Exceptions and behavior
Class ResolvedModelConfig declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.LoadedModel · class
vllm_mlx.model_registry.LoadedModel(config: ResolvedModelConfig, engine: BaseEngine, loaded_at: float = field(default_factory=time.time), last_used_at: float = field(default_factory=time.time), active_requests: int = 0, active_tasks: set[asyncio.Task[Any]] = field(default_factory=set), preempting: bool = False)
Runtime state for a loaded engine.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
config |
ResolvedModelConfig |
yes |
none |
Required constructor field. |
engine |
BaseEngine |
yes |
none |
Required constructor field. |
loaded_at |
float |
no |
field(default_factory=time.time) |
Optional constructor field; defaults to field(default_factory=time.time). |
last_used_at |
float |
no |
field(default_factory=time.time) |
Optional constructor field; defaults to field(default_factory=time.time). |
active_requests |
int |
no |
0 |
Optional constructor field; defaults to 0. |
active_tasks |
set[asyncio.Task[Any]] |
no |
field(default_factory=set) |
Optional constructor field; defaults to field(default_factory=set). |
preempting |
bool |
no |
False |
Optional constructor field; defaults to False. |
Returns
- Constructs:
vllm_mlx.model_registry.LoadedModel
Exceptions and behavior
Class LoadedModel declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.PendingLoad · class
vllm_mlx.model_registry.PendingLoad(model_name: str, required_bytes: int, future: asyncio.Future[LoadedModel])
A reserved model load in progress.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required constructor field. |
required_bytes |
int |
yes |
none |
Required constructor field. |
future |
asyncio.Future[LoadedModel] |
yes |
none |
Required constructor field. |
Returns
- Constructs:
vllm_mlx.model_registry.PendingLoad
Exceptions and behavior
Class PendingLoad declares 0 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelLease · class
vllm_mlx.model_registry.ModelLease(manager: 'ModelManager | None', model_name: str, engine: BaseEngine, release_cb: Callable[[], Awaitable[None]])
Active lease for a loaded model.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
manager |
'ModelManager \| None' |
yes |
none |
Required constructor field. |
model_name |
str |
yes |
none |
Required constructor field. |
engine |
BaseEngine |
yes |
none |
Required constructor field. |
release_cb |
Callable[[], Awaitable[None]] |
yes |
none |
Required constructor field. |
Returns
- Constructs:
vllm_mlx.model_registry.ModelLease
Exceptions and behavior
Class ModelLease declares 3 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelLease.release · method
Release this lease once and allow the model to become evictable.
Parameters
This callable has no explicit inputs.
Returns
- Type:
None - Direct return expressions:
None
Exceptions and behavior
Method ModelLease.release updates self.manager; calls self.release_cb; awaits asynchronous work; returns None.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelLease.__aenter__ · method
Method ModelLease.__aenter__ returns self.
Parameters
This callable has no explicit inputs.
Returns
- Type:
'ModelLease' - Direct return expressions:
self
Exceptions and behavior
Method ModelLease.__aenter__ returns self.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelLease.__aexit__ · method
Method ModelLease.__aexit__ calls self.release; awaits asynchronous work.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
exc_type |
not annotated |
yes |
none |
Required positional or keyword input. |
exc |
not annotated |
yes |
none |
Required positional or keyword input. |
tb |
not annotated |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
None
Exceptions and behavior
Method ModelLease.__aexit__ calls self.release; awaits asynchronous work.
No direct raise statement appears in this definition.
vllm_mlx.model_registry._clone_scheduler_config · function
vllm_mlx.model_registry._clone_scheduler_config(config: SchedulerConfig | None) -> SchedulerConfig | None
Clone a SchedulerConfig so per-model overrides do not mutate globals.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
config |
SchedulerConfig \| None |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
SchedulerConfig | None - Direct return expressions:
None;SchedulerConfig(**vars(config))
Exceptions and behavior
Function _clone_scheduler_config calls SchedulerConfig, vars; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry._parse_memory_budget_bytes · function
Parse a memory budget from bytes, MB, or GB.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value |
Any |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
int - Direct return expressions:
int(float(value) * 1024 ** 3);int(float(raw[:-2]) * 1024 ** 3);int(float(raw[:-2]) * 1024 ** 2);int(float(raw[:-1]));int(float(raw) * 1024 ** 3)
Exceptions and behavior
Function _parse_memory_budget_bytes calls ValueError, isinstance, int, float; can raise ValueError, TypeError; has 5 explicit return paths.
Directly raised exceptions: ValueError, TypeError.
vllm_mlx.model_registry._safe_available_memory_bytes · function
Best-effort available system memory.
Parameters
This callable has no explicit inputs.
Returns
- Type:
int - Direct return expressions:
0;int(psutil.virtual_memory().available)
Exceptions and behavior
Function _safe_available_memory_bytes calls int, psutil.virtual_memory; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry._device_working_set_bytes · function
Best-effort Metal recommended working-set size, or None when unavailable.
Parameters
This callable has no explicit inputs.
Returns
- Type:
int | None - Direct return expressions:
None;working_set or None
Exceptions and behavior
Function _device_working_set_bytes calls mx.metal.is_available, mx.device_info, info.get, int; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.MemoryBudgetReport · class
vllm_mlx.model_registry.MemoryBudgetReport(budget_bytes: int, device_working_set_bytes: int | None, gpu_memory_utilization: float | None, gpu_memory_utilization_source: str | None, per_engine_cache_limit_bytes: int | None, per_engine_cache_percent: float | None, continuous_batching_entries: int, total_entries: int)
Reconciliation of the manager weight budget with the Metal ceiling.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
budget_bytes |
int |
yes |
none |
Required constructor field. |
device_working_set_bytes |
int \| None |
yes |
none |
Required constructor field. |
gpu_memory_utilization |
float \| None |
yes |
none |
Required constructor field. |
gpu_memory_utilization_source |
str \| None |
yes |
none |
Required constructor field. |
per_engine_cache_limit_bytes |
int \| None |
yes |
none |
Required constructor field. |
per_engine_cache_percent |
float \| None |
yes |
none |
Required constructor field. |
continuous_batching_entries |
int |
yes |
none |
Required constructor field. |
total_entries |
int |
yes |
none |
Required constructor field. |
Returns
- Constructs:
vllm_mlx.model_registry.MemoryBudgetReport
Exceptions and behavior
Class MemoryBudgetReport declares 3 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.MemoryBudgetReport.allocation_ceiling_bytes · method
Metal soft allocation limit that will be installed at engine start.
Parameters
This callable has no explicit inputs.
Returns
- Type:
int | None - Direct return expressions:
None;int(self.device_working_set_bytes * self.gpu_memory_utilization)
Exceptions and behavior
Method MemoryBudgetReport.allocation_ceiling_bytes calls int; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.MemoryBudgetReport.exceeds_ceiling · method
True when the weights budget alone cannot fit under the ceiling.
Parameters
This callable has no explicit inputs.
Returns
- Type:
bool - Direct return expressions:
ceiling is not None and self.budget_bytes > ceiling
Exceptions and behavior
Method MemoryBudgetReport.exceeds_ceiling returns ceiling is not None and self.budget_bytes > ceiling.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.MemoryBudgetReport.cache_limit_exceeds_ceiling · method
True when one engine's prefix cache could alone fill the ceiling.
Parameters
This callable has no explicit inputs.
Returns
- Type:
bool - Direct return expressions:
False;self.per_engine_cache_limit_bytes >= ceiling
Exceptions and behavior
Method MemoryBudgetReport.cache_limit_exceeds_ceiling has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.build_memory_budget_report · function
vllm_mlx.model_registry.build_memory_budget_report(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, device_working_set_bytes: int | None = None) -> MemoryBudgetReport
Reconcile the manager weight budget against the Metal allocation ceiling.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
manager_config |
RegistryManagerConfig |
yes |
none |
Required positional or keyword input. |
registry |
dict[str, RegisteredModel] |
yes |
none |
Required positional or keyword input. |
defaults |
RegistryServeDefaults |
yes |
none |
Required positional or keyword input. |
device_working_set_bytes |
int \| None |
no |
None |
Optional keyword-only input; defaults to None. |
Returns
- Type:
MemoryBudgetReport - Direct return expressions:
MemoryBudgetReport(budget_bytes=manager_config.memory_budget_bytes, device_working_set_bytes=device_working_set_bytes, …
Exceptions and behavior
Function build_memory_budget_report calls _device_working_set_bytes, sorted, candidates.append, len; returns MemoryBudgetReport(budget_bytes=manager_config.memory_budget_bytes, device_working_set_bytes=device_working_set_bytes, ….
No direct raise statement appears in this definition.
vllm_mlx.model_registry.log_memory_budget_report · function
Log the budget/ceiling reconciliation, warning when they conflict.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
report |
MemoryBudgetReport |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
None - Direct return expressions:
None
Exceptions and behavior
Function log_memory_budget_report calls logger.info, logger.warning; returns None.
No direct raise statement appears in this definition.
vllm_mlx.model_registry._estimate_model_bytes_from_source · function
Estimate model footprint from local artifact size when possible.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
source |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
int - Direct return expressions:
0;path.stat().st_size if path.suffix in {'.safetensors', '.gguf'} else 0;total
Exceptions and behavior
Function _estimate_model_bytes_from_source calls Path, path.exists, path.is_file, path.stat; has 3 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.load_registry_config · function
vllm_mlx.model_registry.load_registry_config(config_path: str | os.PathLike[str], defaults: RegistryServeDefaults) -> tuple[RegistryManagerConfig, dict[str, RegisteredModel]]
Load and validate the models registry YAML file.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
config_path |
str \| os.PathLike[str] |
yes |
none |
Required positional or keyword input. |
defaults |
RegistryServeDefaults |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
tuple[RegistryManagerConfig, dict[str, RegisteredModel]] - Direct return expressions:
(manager, registry)
Exceptions and behavior
Function load_registry_config calls yaml.safe_load, Path(config_path).read_text, Path, raw.get; can raise ValueError; returns (manager, registry).
Directly raised exceptions: ValueError.
vllm_mlx.model_registry.ModelManager · class
vllm_mlx.model_registry.ModelManager(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory | None = None)
Registry-backed model manager with lazy load and memory-budget eviction.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
manager_config |
RegistryManagerConfig |
yes |
none |
Required positional or keyword input. |
registry |
dict[str, RegisteredModel] |
yes |
none |
Required positional or keyword input. |
defaults |
RegistryServeDefaults |
yes |
none |
Required positional or keyword input. |
engine_factory |
EngineFactory \| None |
no |
None |
Optional keyword-only input; defaults to None. |
Returns
- Constructs:
vllm_mlx.model_registry.ModelManager
Exceptions and behavior
Class ModelManager declares 27 direct member(s).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.__init__ · method
vllm_mlx.model_registry.ModelManager.__init__(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory | None = None) -> None
Method ModelManager.__init__ updates self._config, self._registry, self._defaults, self._engine_factory; calls asyncio.Condition.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
manager_config |
RegistryManagerConfig |
yes |
none |
Required positional or keyword input. |
registry |
dict[str, RegisteredModel] |
yes |
none |
Required positional or keyword input. |
defaults |
RegistryServeDefaults |
yes |
none |
Required positional or keyword input. |
engine_factory |
EngineFactory \| None |
no |
None |
Optional keyword-only input; defaults to None. |
Returns
- Type:
None
Exceptions and behavior
Method ModelManager.__init__ updates self._config, self._registry, self._defaults, self._engine_factory; calls asyncio.Condition.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.memory_budget_bytes · method
Return the registry's configured resident-model memory budget.
Parameters
This callable has no explicit inputs.
Returns
- Type:
int - Direct return expressions:
self._config.memory_budget_bytes
Exceptions and behavior
Method ModelManager.memory_budget_bytes returns self._config.memory_budget_bytes.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.registered_model_names · method
Return sorted list of all registered model names.
Parameters
This callable has no explicit inputs.
Returns
- Type:
list[str] - Direct return expressions:
sorted(self._registry.keys())
Exceptions and behavior
Method ModelManager.registered_model_names calls sorted, self._registry.keys; returns sorted(self._registry.keys()).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.has_model · method
Return whether a model name is present in the serving registry.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
bool - Direct return expressions:
model_name in self._registry
Exceptions and behavior
Method ModelManager.has_model returns model_name in self._registry.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.list_models · method
Return registry state for /v1/models.
Parameters
This callable has no explicit inputs.
Returns
- Type:
list[dict[str, Any]] - Direct return expressions:
data
Exceptions and behavior
Method ModelManager.list_models calls self._registry.items, self._loaded.get, self._unloading.get, self._loading.get; returns data.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.preload · method
Preload any entries marked preload=true.
Parameters
This callable has no explicit inputs.
Returns
- Type:
None
Exceptions and behavior
Method ModelManager.preload calls self._registry.values, self.acquire, lease.release; awaits asynchronous work.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.shutdown · method
Stop and unload every loaded engine.
Parameters
This callable has no explicit inputs.
Returns
- Type:
None
Exceptions and behavior
Method ModelManager.shutdown updates self._shutting_down; calls set, self._loading.values, self._loaded.values, cancel_tasks.update; awaits asynchronous work.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager.acquire · method
Acquire a lease for a configured model.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
ModelLease - Direct return expressions:
claimed
Exceptions and behavior
Method ModelManager.acquire calls KeyError, time.monotonic, set, RuntimeError; awaits asynchronous work; can raise KeyError, RuntimeError; returns claimed.
Directly raised exceptions: KeyError, RuntimeError.
vllm_mlx.model_registry.ModelManager.release · method
Release a previously acquired model lease.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
None - Direct return expressions:
None
Exceptions and behavior
Method ModelManager.release calls self._loaded.get, max, time.time, asyncio.current_task; awaits asynchronous work; returns None.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._claim_loaded_locked · method
vllm_mlx.model_registry.ModelManager._claim_loaded_locked(model_name: str, *, loaded_override: LoadedModel | None = None) -> ModelLease | None
Method ModelManager._claim_loaded_locked calls self._loaded.get, time.time, asyncio.current_task, loaded.active_tasks.add; has 2 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
loaded_override |
LoadedModel \| None |
no |
None |
Optional keyword-only input; defaults to None. |
Returns
- Type:
ModelLease | None - Direct return expressions:
None;ModelLease(manager=self, model_name=model_name, engine=loaded.engine, release_cb=_release)
Exceptions and behavior
Method ModelManager._claim_loaded_locked calls self._loaded.get, time.time, asyncio.current_task, loaded.active_tasks.add; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._claim_loaded_locked._release · nested function
Nested Function ModelManager._claim_loaded_locked._release calls self.release; awaits asynchronous work.
Parameters
This callable has no explicit inputs.
Returns
- Type:
None
Exceptions and behavior
Nested Function ModelManager._claim_loaded_locked._release calls self.release; awaits asynchronous work.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._execute_load · method
Instantiate a reserved model load outside the manager lock.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
pending |
PendingLoad |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
LoadedModel - Direct return expressions:
loaded
Exceptions and behavior
Method ModelManager._execute_load calls self._resolve_source, self._instantiate_model, self._loading.pop, current.future.done; awaits asynchronous work; can raise RuntimeError; returns loaded.
Directly raised exceptions: RuntimeError.
vllm_mlx.model_registry.ModelManager._wait_for_change · method
Method ModelManager._wait_for_change calls self._condition.wait, RuntimeError, asyncio.wait_for; awaits asynchronous work; can raise RuntimeError; returns None.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
timeout |
float \| None |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
None - Direct return expressions:
None
Exceptions and behavior
Method ModelManager._wait_for_change calls self._condition.wait, RuntimeError, asyncio.wait_for; awaits asynchronous work; can raise RuntimeError; returns None.
Directly raised exceptions: RuntimeError.
vllm_mlx.model_registry.ModelManager._run_unloads · method
Method ModelManager._run_unloads calls loaded.engine.stop, self._unloading.pop, self._condition.notify_all; awaits asynchronous work.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
unloads |
list[LoadedModel] |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
None
Exceptions and behavior
Method ModelManager._run_unloads calls loaded.engine.stop, self._unloading.pop, self._condition.notify_all; awaits asynchronous work.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._reserve_load_locked · method
vllm_mlx.model_registry.ModelManager._reserve_load_locked(model_name: str, required_bytes: int) -> PendingLoad
Method ModelManager._reserve_load_locked calls asyncio.get_running_loop().create_future, asyncio.get_running_loop, PendingLoad; returns pending.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
required_bytes |
int |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
PendingLoad - Direct return expressions:
pending
Exceptions and behavior
Method ModelManager._reserve_load_locked calls asyncio.get_running_loop().create_future, asyncio.get_running_loop, PendingLoad; returns pending.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._begin_unload_locked · method
Method ModelManager._begin_unload_locked calls self._loaded.pop; returns loaded.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
LoadedModel - Direct return expressions:
loaded
Exceptions and behavior
Method ModelManager._begin_unload_locked calls self._loaded.pop; returns loaded.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._collect_idle_unloads_locked · method
vllm_mlx.model_registry.ModelManager._collect_idle_unloads_locked(requested_model: str, required_bytes: int) -> list[LoadedModel]
Method ModelManager._collect_idle_unloads_locked calls self._committed_bytes_locked, sorted, self._loaded.items, selected.append; returns selected.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
requested_model |
str |
yes |
none |
Required positional or keyword input. |
required_bytes |
int |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
list[LoadedModel] - Direct return expressions:
selected
Exceptions and behavior
Method ModelManager._collect_idle_unloads_locked calls self._committed_bytes_locked, sorted, self._loaded.items, selected.append; returns selected.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._maybe_preempt_locked · method
vllm_mlx.model_registry.ModelManager._maybe_preempt_locked(*, model_name: str, required_bytes: int, start: float) -> set[asyncio.Task[Any]]
Method ModelManager._maybe_preempt_locked calls self._should_preempt_locked, set, self._committed_bytes_locked, sorted; has 2 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model_name |
str |
yes |
none |
Required keyword-only input. |
required_bytes |
int |
yes |
none |
Required keyword-only input. |
start |
float |
yes |
none |
Required keyword-only input. |
Returns
- Type:
set[asyncio.Task[Any]] - Direct return expressions:
set();cancel_tasks
Exceptions and behavior
Method ModelManager._maybe_preempt_locked calls self._should_preempt_locked, set, self._committed_bytes_locked, sorted; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._should_wait_locked · method
Method ModelManager._should_wait_locked calls self._remaining_wait_timeout; has 2 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
start |
float |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
bool - Direct return expressions:
False;timeout is None or timeout > 0
Exceptions and behavior
Method ModelManager._should_wait_locked calls self._remaining_wait_timeout; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._should_preempt_locked · method
Method ModelManager._should_preempt_locked calls time.monotonic; has 3 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
start |
float |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
bool - Direct return expressions:
True;False;elapsed >= trigger
Exceptions and behavior
Method ModelManager._should_preempt_locked calls time.monotonic; has 3 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._remaining_wait_timeout · method
Method ModelManager._remaining_wait_timeout calls max, time.monotonic; has 2 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
start |
float |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
float | None - Direct return expressions:
None;max(timeout - (time.monotonic() - start), 0.0)
Exceptions and behavior
Method ModelManager._remaining_wait_timeout calls max, time.monotonic; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._can_reserve_locked · method
Method ModelManager._can_reserve_locked calls self._committed_bytes_locked; returns self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
required_bytes |
int |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
bool - Direct return expressions:
self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes
Exceptions and behavior
Method ModelManager._can_reserve_locked calls self._committed_bytes_locked; returns self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._committed_bytes_locked · method
Method ModelManager._committed_bytes_locked calls sum, self._loaded.values, self._loading.values, self._unloading.values; returns loaded_bytes + loading_bytes + unloading_bytes.
Parameters
This callable has no explicit inputs.
Returns
- Type:
int - Direct return expressions:
loaded_bytes + loading_bytes + unloading_bytes
Exceptions and behavior
Method ModelManager._committed_bytes_locked calls sum, self._loaded.values, self._loading.values, self._unloading.values; returns loaded_bytes + loading_bytes + unloading_bytes.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._instantiate_model · method
async vllm_mlx.model_registry.ModelManager._instantiate_model(entry: RegisteredModel, resolved_source: str) -> LoadedModel
Method ModelManager._instantiate_model calls self._resolve_model_config, self._engine_factory, BatchedEngine, SimpleEngine; awaits asynchronous work; returns LoadedModel(config=config, engine=engine).
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
entry |
RegisteredModel |
yes |
none |
Required positional or keyword input. |
resolved_source |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
LoadedModel - Direct return expressions:
LoadedModel(config=config, engine=engine)
Exceptions and behavior
Method ModelManager._instantiate_model calls self._resolve_model_config, self._engine_factory, BatchedEngine, SimpleEngine; awaits asynchronous work; returns LoadedModel(config=config, engine=engine).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._resolve_source · method
Method ModelManager._resolve_source calls asyncio.to_thread; awaits asynchronous work; returns await asyncio.to_thread(self._resolve_source_sync, entry).
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
entry |
RegisteredModel |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
str - Direct return expressions:
await asyncio.to_thread(self._resolve_source_sync, entry)
Exceptions and behavior
Method ModelManager._resolve_source calls asyncio.to_thread; awaits asynchronous work; returns await asyncio.to_thread(self._resolve_source_sync, entry).
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._resolve_source_sync · method
Method ModelManager._resolve_source_sync calls Path(source).exists, Path, ensure_model_downloaded, is_mllm_model; has 2 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
entry |
RegisteredModel |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
str - Direct return expressions:
source;str(downloaded)
Exceptions and behavior
Method ModelManager._resolve_source_sync calls Path(source).exists, Path, ensure_model_downloaded, is_mllm_model; has 2 explicit return paths.
No direct raise statement appears in this definition.
vllm_mlx.model_registry.ModelManager._resolve_estimated_bytes · method
vllm_mlx.model_registry.ModelManager._resolve_estimated_bytes(entry: RegisteredModel, resolved_source: str) -> int
Method ModelManager._resolve_estimated_bytes calls _estimate_model_bytes_from_source, Path, source_path.exists, ValueError; can raise ValueError; has 3 explicit return paths.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
entry |
RegisteredModel |
yes |
none |
Required positional or keyword input. |
resolved_source |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
int - Direct return expressions:
entry.estimated_memory_bytes;estimated;max(available // 8, 1)
Exceptions and behavior
Method ModelManager._resolve_estimated_bytes calls _estimate_model_bytes_from_source, Path, source_path.exists, ValueError; can raise ValueError; has 3 explicit return paths.
Directly raised exceptions: ValueError.
vllm_mlx.model_registry.ModelManager._resolve_model_config · method
vllm_mlx.model_registry.ModelManager._resolve_model_config(entry: RegisteredModel, resolved_source: str) -> ResolvedModelConfig
Method ModelManager._resolve_model_config calls _clone_scheduler_config, self._resolve_estimated_bytes, ResolvedModelConfig; returns ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f….
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
entry |
RegisteredModel |
yes |
none |
Required positional or keyword input. |
resolved_source |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
ResolvedModelConfig - Direct return expressions:
ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f…
Exceptions and behavior
Method ModelManager._resolve_model_config calls _clone_scheduler_config, self._resolve_estimated_bytes, ResolvedModelConfig; returns ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f….
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
ModelOwnershipError |
class | ModelOwnershipError() |
Raised when an EngineCore attempts to use a model already in use. | #L38-L39 |
_ModelOwnershipRegistry |
class | _ModelOwnershipRegistry() |
Process-local model ownership guard used by EngineCore. | #L42-L82 |
_ModelOwnershipRegistry.__init__ |
method | _ModelOwnershipRegistry.__init__() -> None |
Method _ModelOwnershipRegistry.__init__ updates self._owners. |
#L45-L46 |
_ModelOwnershipRegistry.acquire |
method | _ModelOwnershipRegistry.acquire(*, model: Any, engine: Any, engine_id: str, force: bool = True) -> None |
Method _ModelOwnershipRegistry.acquire calls id, self._owners.get, ModelOwnershipError; can raise ModelOwnershipError. |
#L48-L63 |
_ModelOwnershipRegistry.release |
method | _ModelOwnershipRegistry.release(model: Any, engine_id: str) -> None |
Method _ModelOwnershipRegistry.release calls id, self._owners.get, self._owners.pop. |
#L65-L69 |
_ModelOwnershipRegistry.is_owned |
method | _ModelOwnershipRegistry.is_owned(model: Any) -> tuple[bool, str \| None] |
Method _ModelOwnershipRegistry.is_owned calls id, self._owners.get; has 2 explicit return paths. |
#L71-L76 |
_ModelOwnershipRegistry.get_stats |
method | _ModelOwnershipRegistry.get_stats() -> dict[str, Any] |
Method _ModelOwnershipRegistry.get_stats calls len; returns {'total_entries': len(self._owners), 'active_owners': len(self._owners)}. |
#L78-L82 |
get_registry |
function | get_registry() -> _ModelOwnershipRegistry |
Return the global model ownership registry used by EngineCore. | #L88-L90 |
RegistryServeDefaults |
class | RegistryServeDefaults(continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str \| None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig \| None, max_tokens: int, download_config: DownloadConfig) |
Global serve defaults inherited by registry entries. | #L109-L125 |
ContentionPolicy |
class | ContentionPolicy(strategy: ContentionStrategy = 'wait_then_fail', wait_timeout_s: float \| None = 30.0, preempt_after_s: float \| None = None) |
Policy used when a new model cannot fit inside the memory budget. | #L129-L134 |
RegistryManagerConfig |
class | RegistryManagerConfig(memory_budget_bytes: int, policy: ContentionPolicy) |
Global registry manager configuration. | #L138-L142 |
RegisteredModel |
class | RegisteredModel(name: str, source: str, preload: bool = False, continuous_batching: bool \| None = None, force_mllm: bool \| None = None, enable_mtp: bool \| None = None, prefill_step_size: int \| None = None, specprefill_enabled: bool \| None = None, specprefill_threshold: int \| None = None, specprefill_keep_pct: float \| None = None, specprefill_backbone_pct: float \| None = None, specprefill_draft_model: str \| None = None, stream_interval: int \| None = None, gpu_memory_utilization: float \| None = None, estimated_memory_bytes: int \| None = None) |
One configured model entry. | #L146-L163 |
ResolvedModelConfig |
class | ResolvedModelConfig(entry: RegisteredModel, resolved_source: str, continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str \| None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig \| None, estimated_memory_bytes: int) |
Effective configuration for a loaded model. | #L167-L184 |
LoadedModel |
class | LoadedModel(config: ResolvedModelConfig, engine: BaseEngine, loaded_at: float = field(default_factory=time.time), last_used_at: float = field(default_factory=time.time), active_requests: int = 0, active_tasks: set[asyncio.Task[Any]] = field(default_factory=set), preempting: bool = False) |
Runtime state for a loaded engine. | #L188-L197 |
PendingLoad |
class | PendingLoad(model_name: str, required_bytes: int, future: asyncio.Future[LoadedModel]) |
A reserved model load in progress. | #L201-L206 |
ModelLease |
class | ModelLease(manager: 'ModelManager \| None', model_name: str, engine: BaseEngine, release_cb: Callable[[], Awaitable[None]]) |
Active lease for a loaded model. | #L210-L231 |
ModelLease.release |
method | async ModelLease.release() -> None |
Release this lease once and allow the model to become evictable. | #L218-L225 |
ModelLease.__aenter__ |
method | async ModelLease.__aenter__() -> 'ModelLease' |
Method ModelLease.__aenter__ returns self. |
#L227-L228 |
ModelLease.__aexit__ |
method | async ModelLease.__aexit__(exc_type, exc, tb) -> None |
Method ModelLease.__aexit__ calls self.release; awaits asynchronous work. |
#L230-L231 |
_clone_scheduler_config |
function | _clone_scheduler_config(config: SchedulerConfig \| None) -> SchedulerConfig \| None |
Clone a SchedulerConfig so per-model overrides do not mutate globals. | #L234-L238 |
_parse_memory_budget_bytes |
function | _parse_memory_budget_bytes(value: Any) -> int |
Parse a memory budget from bytes, MB, or GB. | #L241-L256 |
_safe_available_memory_bytes |
function | _safe_available_memory_bytes() -> int |
Best-effort available system memory. | #L259-L263 |
_device_working_set_bytes |
function | _device_working_set_bytes() -> int \| None |
Best-effort Metal recommended working-set size, or None when unavailable. | #L266-L282 |
MemoryBudgetReport |
class | MemoryBudgetReport(budget_bytes: int, device_working_set_bytes: int \| None, gpu_memory_utilization: float \| None, gpu_memory_utilization_source: str \| None, per_engine_cache_limit_bytes: int \| None, per_engine_cache_percent: float \| None, continuous_batching_entries: int, total_entries: int) |
Reconciliation of the manager weight budget with the Metal ceiling. | #L286-L339 |
MemoryBudgetReport.allocation_ceiling_bytes |
method | MemoryBudgetReport.allocation_ceiling_bytes() -> int \| None |
Metal soft allocation limit that will be installed at engine start. | #L313-L322 |
MemoryBudgetReport.exceeds_ceiling |
method | MemoryBudgetReport.exceeds_ceiling() -> bool |
True when the weights budget alone cannot fit under the ceiling. | #L325-L331 |
MemoryBudgetReport.cache_limit_exceeds_ceiling |
method | MemoryBudgetReport.cache_limit_exceeds_ceiling() -> bool |
True when one engine's prefix cache could alone fill the ceiling. | #L334-L339 |
build_memory_budget_report |
function | build_memory_budget_report(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, device_working_set_bytes: int \| None = None) -> MemoryBudgetReport |
Reconcile the manager weight budget against the Metal allocation ceiling. | #L342-L421 |
log_memory_budget_report |
function | log_memory_budget_report(report: MemoryBudgetReport) -> None |
Log the budget/ceiling reconciliation, warning when they conflict. | #L424-L502 |
_estimate_model_bytes_from_source |
function | _estimate_model_bytes_from_source(source: str) -> int |
Estimate model footprint from local artifact size when possible. | #L505-L521 |
load_registry_config |
function | load_registry_config(config_path: str \| os.PathLike[str], defaults: RegistryServeDefaults) -> tuple[RegistryManagerConfig, dict[str, RegisteredModel]] |
Load and validate the models registry YAML file. | #L524-L621 |
ModelManager |
class | ModelManager(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory \| None = None) |
Registry-backed model manager with lazy load and memory-budget eviction. | #L624-L1201 |
ModelManager.__init__ |
method | ModelManager.__init__(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory \| None = None) -> None |
Method ModelManager.__init__ updates self._config, self._registry, self._defaults, self._engine_factory; calls asyncio.Condition. |
#L627-L643 |
ModelManager.memory_budget_bytes |
method | ModelManager.memory_budget_bytes() -> int |
Return the registry's configured resident-model memory budget. | #L646-L649 |
ModelManager.registered_model_names |
method | ModelManager.registered_model_names() -> list[str] |
Return sorted list of all registered model names. | #L652-L654 |
ModelManager.has_model |
method | ModelManager.has_model(model_name: str) -> bool |
Return whether a model name is present in the serving registry. | #L656-L659 |
ModelManager.list_models |
method | ModelManager.list_models() -> list[dict[str, Any]] |
Return registry state for /v1/models. | #L661-L699 |
ModelManager.preload |
method | async ModelManager.preload() -> None |
Preload any entries marked preload=true. | #L701-L706 |
ModelManager.shutdown |
method | async ModelManager.shutdown() -> None |
Stop and unload every loaded engine. | #L708-L739 |
ModelManager.acquire |
method | async ModelManager.acquire(model_name: str) -> ModelLease |
Acquire a lease for a configured model. | #L741-L819 |
ModelManager.release |
method | async ModelManager.release(model_name: str) -> None |
Release a previously acquired model lease. | #L821-L842 |
ModelManager._claim_loaded_locked |
method | ModelManager._claim_loaded_locked(model_name: str, *, loaded_override: LoadedModel \| None = None) -> ModelLease \| None |
Method ModelManager._claim_loaded_locked calls self._loaded.get, time.time, asyncio.current_task, loaded.active_tasks.add; has 2 explicit return paths. |
#L844-L874 |
ModelManager._claim_loaded_locked._release |
nested function | async ModelManager._claim_loaded_locked._release() -> None |
Nested Function ModelManager._claim_loaded_locked._release calls self.release; awaits asynchronous work. |
#L866-L867 |
ModelManager._execute_load |
method | async ModelManager._execute_load(pending: PendingLoad) -> LoadedModel |
Instantiate a reserved model load outside the manager lock. | #L876-L913 |
ModelManager._wait_for_change |
method | async ModelManager._wait_for_change(timeout: float \| None) -> None |
Method ModelManager._wait_for_change calls self._condition.wait, RuntimeError, asyncio.wait_for; awaits asynchronous work; can raise RuntimeError; returns None. |
#L915-L922 |
ModelManager._run_unloads |
method | async ModelManager._run_unloads(unloads: list[LoadedModel]) -> None |
Method ModelManager._run_unloads calls loaded.engine.stop, self._unloading.pop, self._condition.notify_all; awaits asynchronous work. |
#L924-L931 |
ModelManager._reserve_load_locked |
method | ModelManager._reserve_load_locked(model_name: str, required_bytes: int) -> PendingLoad |
Method ModelManager._reserve_load_locked calls asyncio.get_running_loop().create_future, asyncio.get_running_loop, PendingLoad; returns pending. |
#L933-L941 |
ModelManager._begin_unload_locked |
method | ModelManager._begin_unload_locked(model_name: str) -> LoadedModel |
Method ModelManager._begin_unload_locked calls self._loaded.pop; returns loaded. |
#L943-L946 |
ModelManager._collect_idle_unloads_locked |
method | ModelManager._collect_idle_unloads_locked(requested_model: str, required_bytes: int) -> list[LoadedModel] |
Method ModelManager._collect_idle_unloads_locked calls self._committed_bytes_locked, sorted, self._loaded.items, selected.append; returns selected. |
#L948-L968 |
ModelManager._maybe_preempt_locked |
method | ModelManager._maybe_preempt_locked(*, model_name: str, required_bytes: int, start: float) -> set[asyncio.Task[Any]] |
Method ModelManager._maybe_preempt_locked calls self._should_preempt_locked, set, self._committed_bytes_locked, sorted; has 2 explicit return paths. |
#L970-L1003 |
ModelManager._should_wait_locked |
method | ModelManager._should_wait_locked(start: float) -> bool |
Method ModelManager._should_wait_locked calls self._remaining_wait_timeout; has 2 explicit return paths. |
#L1005-L1010 |
ModelManager._should_preempt_locked |
method | ModelManager._should_preempt_locked(start: float) -> bool |
Method ModelManager._should_preempt_locked calls time.monotonic; has 3 explicit return paths. |
#L1012-L1020 |
ModelManager._remaining_wait_timeout |
method | ModelManager._remaining_wait_timeout(start: float) -> float \| None |
Method ModelManager._remaining_wait_timeout calls max, time.monotonic; has 2 explicit return paths. |
#L1022-L1026 |
ModelManager._can_reserve_locked |
method | ModelManager._can_reserve_locked(required_bytes: int) -> bool |
Method ModelManager._can_reserve_locked calls self._committed_bytes_locked; returns self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes. |
#L1028-L1032 |
ModelManager._committed_bytes_locked |
method | ModelManager._committed_bytes_locked() -> int |
Method ModelManager._committed_bytes_locked calls sum, self._loaded.values, self._loading.values, self._unloading.values; returns loaded_bytes + loading_bytes + unloading_bytes. |
#L1034-L1042 |
ModelManager._instantiate_model |
method | async ModelManager._instantiate_model(entry: RegisteredModel, resolved_source: str) -> LoadedModel |
Method ModelManager._instantiate_model calls self._resolve_model_config, self._engine_factory, BatchedEngine, SimpleEngine; awaits asynchronous work; returns LoadedModel(config=config, engine=engine). |
#L1044-L1073 |
ModelManager._resolve_source |
method | async ModelManager._resolve_source(entry: RegisteredModel) -> str |
Method ModelManager._resolve_source calls asyncio.to_thread; awaits asynchronous work; returns await asyncio.to_thread(self._resolve_source_sync, entry). |
#L1075-L1076 |
ModelManager._resolve_source_sync |
method | ModelManager._resolve_source_sync(entry: RegisteredModel) -> str |
Method ModelManager._resolve_source_sync calls Path(source).exists, Path, ensure_model_downloaded, is_mllm_model; has 2 explicit return paths. |
#L1078-L1087 |
ModelManager._resolve_estimated_bytes |
method | ModelManager._resolve_estimated_bytes(entry: RegisteredModel, resolved_source: str) -> int |
Method ModelManager._resolve_estimated_bytes calls _estimate_model_bytes_from_source, Path, source_path.exists, ValueError; can raise ValueError; has 3 explicit return paths. |
#L1089-L1121 |
ModelManager._resolve_model_config |
method | ModelManager._resolve_model_config(entry: RegisteredModel, resolved_source: str) -> ResolvedModelConfig |
Method ModelManager._resolve_model_config calls _clone_scheduler_config, self._resolve_estimated_bytes, ResolvedModelConfig; returns ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f…. |
#L1123-L1201 |