Skip to main content

Module device_registry

Module device_registry 

Source
Expand description

Device-per-circuit registry — obtain a wgpu::Device for a SPECIFIC adapter/circuit (e.g. the integrated GPU), not just the single process-wide primary (STELLAR H3 foundation). Native only; mirrors try_shared_gpu — never panics on a missing/failed device. Device-per-circuit registry — obtain a wgpu::Device for a SPECIFIC adapter/circuit (STELLAR §A H3 foundation for heterogeneous GPU routing).

[super::shared_gpu] / [super::try_shared_gpu] give you the single process-wide primary device (a PowerPreference::HighPerformance pick — the discrete GPU on a discrete+integrated box). This module lets code obtain a device for a specific enumerated circuit — e.g. the integrated GPU — so audio/vision work can run off the LLM’s silicon.

Role policy: keep the primary circuit free for the LLM; audio/vision use the auxiliary circuit. [try_auxiliary_gpu] gives callers the fallback chain auxiliary → primary → None (the caller then degrades to CPU) so they always get a device or None, never a panic.

Mirrors [super::try_shared_gpu]’s discipline: no unwrap() outside tests, and it NEVER panics on a missing or failed device — every failure path returns None. Native only.

Structs§

CircuitAdapter
One enumerated compute circuit: the live wgpu::Adapter, its capability snapshot, and a stable identity (vendor / device / backend) matching device_benchmark / host_topology.

Functions§

auxiliary_circuit_index
Index of the best auxiliary circuit — the best NON-primary circuit, so the primary stays free for the LLM. Prefers a (non-primary) DeviceType::IntegratedGpu; otherwise the next-best non-primary circuit (the list is already ranked discrete → integrated → …). Returns None when only one circuit exists.
enumerate_circuits
Enumerate every adapter once (cached), deduped to one entry per physical circuit (vendor, device) keeping the preferred backend, and sorted discrete → integrated → other → cpu for a deterministic, index-stable list. Returns an empty slice on a headless / GPU-less box.
primary_circuit_index
Index of the primary circuit — the discrete / HighPerformance adapter that super::shared_gpu uses. If the process-wide shared device is already initialized, matches its exact identity (that is definitionally the primary). Otherwise picks the first discrete GPU (what HighPerformance selects), else the top-ranked adapter. None only when no circuit exists. Never forces the shared device to initialize.
try_auxiliary_gpu
A device for the auxiliary circuit if one exists, else the primary shared device, else None. Fallback chain: auxiliary → primary → None (the caller then degrades to CPU). Never panics — every failure resolves to None.
try_device_for_adapter
Lazily build (and cache) a SharedGpuContext for the enumerated circuit at index.