Last updated: 2026-11-17

Hardware Detection

Diagnostics Metal

All API Sections

Apple Silicon diagnostics and managed-model fit reporting for Metal.

The Metal diagnostics path inspects the default device, reports unified memory and feature support, and optionally projects how a selected GGUF or managed model fits once runtime allocations and KV reservation are included.

5 exports 0 methods src/diagnostics_metal.zig

5 exports shown

struct

Options

#
pub const Options = struct

Memory Layout

Size: 1 bytes (alignment: 1)

Offset Size Align Field Type
0 1 1 tier zinc_rt.engine.Tier

Configuration for a Metal diagnostics run.

src/diagnostics_metal.zig:24

struct

ManagedModelInfo

#
pub const ManagedModelInfo = struct

Memory Layout

Size: 80 bytes (alignment: 8)

Offset Size Align Field Type
0 16 8 id []const u8
16 16 8 display_name []const u8
32 16 8 file_name []const u8
48 8 8 size_bytes u64
56 8 8 required_vram_bytes u64
64 16 8 status_label []const u8

Catalog metadata for a managed (downloadable) model.

src/diagnostics_metal.zig:41

struct

UnifiedFitEstimate

#
pub const UnifiedFitEstimate = struct

Memory Layout

Size: 56 bytes (alignment: 8)

Offset Size Align Field Type
0 8 8 weights_bytes u64
8 8 8 runtime_unified_bytes u64
16 8 8 total_unified_bytes u64
24 8 8 recommended_working_set_bytes u64
32 8 8 total_memory_bytes u64
40 8 8 kv_cache_bytes u64
48 4 4 max_ctx u32
52 4 4 budget_max_ctx u32

Estimated unified-memory breakdown for running a model on Apple Silicon.

src/diagnostics_metal.zig:112

function

run

#
pub fn run(opts: Options, allocator: std.mem.Allocator) !void

Run a four-step Metal preflight check (host environment, device, shader assets, model) and print a colour-coded report to stdout.

The steps are: (1) host OS and CPU arch, (2) Metal device capabilities and unified-memory budget, (3) shader source presence and MSL smoke compile, (4) GGUF or managed-model memory-fit estimate. Returns `error.DiagnosticsFailed` if any check resolves to `.fail`.

Parameters

opts
Diagnostic configuration: optional model path, context ceiling, managed-model entry, and shader directory.
allocator
Used for Metal device initialisation and GGUF header inspection.

Returns

`error.DiagnosticsFailed` when one or more checks emit a FAIL status; otherwise succeeds or propagates I/O errors.

src/diagnostics_metal.zig:191

function

estimateUnifiedFit

#
pub fn estimateUnifiedFit( inspection: ModelInspection, recommended_working_set_bytes: u64, total_memory_bytes: u64, requested_context_length: ?u32, ) UnifiedFitEstimate

Compute a conservative unified-memory breakdown for running a model on Apple Silicon.

Combines tensor weight bytes with the runtime shared-buffer and KV-cache cost at the resolved context length, then determines how many tokens could fit within the Metal working-set budget.

Parameters

inspection
GGUF model inspection result supplying tensor size and model config.
recommended_working_set_bytes
Metal driver's recommended working-set ceiling; falls back to `total_memory_bytes` when zero.
total_memory_bytes
Physical unified memory on the device.
requested_context_length
Optional caller-supplied context cap; when null the model's own `context_length` is used (clamped by the backend runtime cap).

Returns

A `UnifiedFitEstimate` with per-category byte breakdowns and derived fit status fields.

src/diagnostics_metal.zig:492