/** * utils/delta.ts — sparse, row-granular weight deltas for online checkpoints. * * Online adaptation (WSLA) restricts the trainable set to a few * selective-projection ROWS, yet each `adapt()` previously rewrote the WHOLE * model to disk. That is wasteful in both size and I/O: 99% of the bytes are * identical to the base checkpoint. A delta persists only the rows that actually * changed, as a diff against a base, so an online update writes kilobytes * instead of megabytes. * * Format (little-endian), CRC-trailed via {@link appendCrcTrailer}: * magic 'EVD0' u32 | version u32 | rowSize u32 | nRows u32 | * rowIndex[nRows] u32 | float32 row data[nRows * rowSize] * * The base + delta reconstruct the exact current weights; a row counts as * "changed" if any element differs beyond an optional epsilon. */ export interface RowDelta { /** Width of one row (elements). `base.length` must be a multiple of it. */ rowSize: number; /** Indices (row-major) of the rows that changed. */ rows: number[]; /** Concatenated new values for the changed rows (rows.length * rowSize). */ data: Float32Array; } /** * Compute the row-sparse delta of `current` vs `base` (same length + layout). * A row is included when any element differs by more than `eps` (default 0). */ export declare function computeRowDelta(base: Float32Array, current: Float32Array, rowSize: number, eps?: number): RowDelta; /** Apply a delta onto a copy of `base`, returning the reconstructed weights. */ export declare function applyRowDelta(base: Float32Array, delta: RowDelta): Float32Array; /** Serialize a delta to a CRC-trailed binary. */ export declare function serializeRowDelta(delta: RowDelta): ArrayBuffer; /** * Diff two whole checkpoint buffers of IDENTICAL structure (same model/config, * f32 data) into a sparse delta — the online-save win for `adapt()` (EVM-6b). * Both buffers are produced by the same `exportWeights()` so their headers are * byte-identical; only the weights the adapt actually changed appear in the * delta. Operates on the raw bytes (header rows diff to nothing), so it needs no * knowledge of the header layout and is GPU-free / unit-testable. * * Element-granular (each changed f32 stored as index+value) so a WSLA update * that touches a few rows persists kilobytes, not the whole model. */ export declare function diffCheckpoints(base: ArrayBuffer, current: ArrayBuffer): ArrayBuffer; /** * Reconstruct the `current` checkpoint from `base` + a diff produced by * {@link diffCheckpoints}. Returns a CRC-trailed buffer byte-identical to the * original current checkpoint, ready for `loadWeights`. */ export declare function applyCheckpointDiff(base: ArrayBuffer, diff: ArrayBuffer): ArrayBuffer; /** Parse a binary produced by {@link serializeRowDelta}; verifies CRC + magic. */ export declare function deserializeRowDelta(buffer: ArrayBuffer): RowDelta; //# sourceMappingURL=delta.d.ts.map