Buffer descriptor for creating GPU buffers
- size : USize
- usage : List BufferUsage
- mappedAtCreation : Bool
Instances For
Equations
Instances For
Early alias of getBufferId (declared before first use; same FFI symbol).
JS-trace registry: uid → (buffer, size). Populated only when DG_TRACE_JS is set (keeps the buffers alive for the post-save dump — acceptable in a trace run).
Create a GPU buffer. Resources are automatically cleaned up by Lean's GC via External finalizers.
Wrapper with debug output
Equations
- One or more equations did not get rendered due to their size.
Instances For
Write data to a buffer from the CPU. @param buffer The target buffer @param offset Offset in bytes @param data Pointer to source data (ByteArray)
writeBuffer with an optional JS-trace hook (DG_TRACE_JS): records small writes (params, canvases) with contents so a replayer can reproduce them.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Map a buffer for reading. Returns the mapped data as a ByteArray. @param buffer The buffer to map @param offset Offset in bytes @param size Size in bytes to map
Unmap a previously mapped buffer
Get a stable unique identifier for a GPU buffer (raw WGPUBuffer handle as UInt64). Used for bind group caching — same ID means same underlying GPU buffer.
metal_replacer STEP 2: the underlying MTLBuffer of this Dawn buffer (via reinterpret to metal::Buffer
- GetMTLBuffer). Reports its length/storageMode/contents — proves the buffer bridge for dispatching llama.cpp's Metal kernels on our data with no copies. See METAL_REPLACER_INTEGRATION.md.
metal_replacer STEP 3: dispatch a CUSTOM Metal kernel (out[i] = in[i]*2) on our Dawn-backed MTLBuffers.
Validates running a hand-written Metal kernel on our data end-to-end. Caller syncs the in write first
(a mapBufferRead) and reads out after. See METAL_REPLACER_INTEGRATION.md.
Hash an array of buffers into a single UInt64 key in one FFI call.
Avoids N separate getBufferId calls per dispatch.
Convert Float64 to Float32 IEEE 754 bits
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helper: Convert Float array to ByteArray for buffer upload (Float64 → Float32)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helper: Convert ByteArray to Float array after buffer readback
Equations
- One or more equations did not get rendered due to their size.
Instances For
DG_TRACE_JS_DUMP=1: after JSTrace.save, dump every referenced buffer
without provenance (derived weights: predequants, repacks — and activations,
harmless) as b<uid>.bin so the JS replayer can load them directly.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Hesper.WebGPU.jsTraceDumpMissing device = Hesper.WebGPU.jsTraceDumpWith device ".bin"
Instances For
dump EVERY registry buffer (no ref-set needed): call at step-0 START so the replayer gets the true PRE-step-0 state — pre-step-N dumps left stale step-(N-1) content in the unwritten tails of reused scratch buffers, which poisoned window-based comparisons (R19).
Equations
- One or more equations did not get rendered due to their size.
Instances For
post-state dump (after the recorded step): the replayer compares every buffer against these to LOCALIZE the first diverging kernel.
Equations
- Hesper.WebGPU.jsTraceDumpPost device = Hesper.WebGPU.jsTraceDumpWith device ".post.bin"