Zero-copy mmap-backed array for name if offload is active and the tensor
is in the manifest; else null. The converter aligns every tensor to 16 KB
and the mmap base is page-aligned, so the pointer is page-aligned —
required for the GPU to gather from it.
Lifetime: these arrays are created ONCE at model load
(QuantizedSwitchLinear.load, packages/inference/src/layers/quantized-switch-linear.ts)
and live as model weights;
every decode's gather_qmm references them, so GPU command buffers retain
the mlx buffer past any dispose and mlx may drop the LAST reference on
the Metal completion thread. That's why this must be fromPointer (native
free(NULL) dtor — safe from any thread), NOT the old fromView JSCallback
pin (the 2026-07-06 deadlock class). The memory contract is trivially
met: mm is module-level and never unmapped — the mapping owns the
bytes for the process (clean file-backed pages, ~0 phys_footprint).
Zero-copy mmap-backed array for
nameif offload is active and the tensor is in the manifest; else null. The converter aligns every tensor to 16 KB and the mmap base is page-aligned, so the pointer is page-aligned — required for the GPU to gather from it.Lifetime: these arrays are created ONCE at model load (QuantizedSwitchLinear.load, packages/inference/src/layers/quantized-switch-linear.ts) and live as model weights; every decode's gather_qmm references them, so GPU command buffers retain the mlx buffer past any dispose and mlx may drop the LAST reference on the Metal completion thread. That's why this must be fromPointer (native free(NULL) dtor — safe from any thread), NOT the old fromView JSCallback pin (the 2026-07-06 deadlock class). The memory contract is trivially met:
mmis module-level and never unmapped — the mapping owns the bytes for the process (clean file-backed pages, ~0 phys_footprint).