tensorgrad 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +154 -193
- package/dist/index.js +2208 -39
- package/dist/index.js.map +7 -1
- package/dist/worker.debug.js +553 -0
- package/package.json +60 -58
- package/src/adam.ts +69 -15
- package/src/compile.ts +334 -156
- package/src/index.ts +8 -4
- package/src/module.ts +72 -34
- package/src/worker-protocol.ts +183 -0
- package/src/worker-proxy.ts +76 -0
- package/src/worker.ts +281 -0
- package/dist/adam.js +0 -111
- package/dist/adam.js.map +0 -1
- package/dist/buffers.js +0 -120
- package/dist/buffers.js.map +0 -1
- package/dist/capture.js +0 -33
- package/dist/capture.js.map +0 -1
- package/dist/codegen.js +0 -724
- package/dist/codegen.js.map +0 -1
- package/dist/compile.js +0 -184
- package/dist/compile.js.map +0 -1
- package/dist/grad.js +0 -380
- package/dist/grad.js.map +0 -1
- package/dist/ir.js +0 -60
- package/dist/ir.js.map +0 -1
- package/dist/module.js +0 -155
- package/dist/module.js.map +0 -1
- package/dist/nn.js +0 -135
- package/dist/nn.js.map +0 -1
- package/dist/ops.js +0 -326
- package/dist/ops.js.map +0 -1
- package/dist/runtime.js +0 -402
- package/dist/runtime.js.map +0 -1
- package/dist/shape.js +0 -259
- package/dist/shape.js.map +0 -1
- package/dist/trace.js +0 -100
- package/dist/trace.js.map +0 -1
package/dist/runtime.js
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
// WebGPU runtime. Reads a BufferPlan + KernelSpec[] (produced by codegen),
|
|
2
|
-
// allocates real GPU buffers and pipelines, and provides a `step()` method
|
|
3
|
-
// that uploads inputs, dispatches all kernels, and reads back outputs.
|
|
4
|
-
//
|
|
5
|
-
// Browser-only: this module needs `navigator.gpu` at runtime.
|
|
6
|
-
/**
|
|
7
|
-
* Activation readbacks for one `step()`/`run()` call. Keyed by the names
|
|
8
|
-
* passed to `capture(name, t)` during the trace. `get(name)` throws if the
|
|
9
|
-
* name isn't registered or wasn't read back this call (i.e., the call was
|
|
10
|
-
* made without `{ withCaptures: true }`); use `has(name)` if you need to
|
|
11
|
-
* branch. `shapeOf(name)` returns the static-after-compile shape and works
|
|
12
|
-
* regardless of whether captures were read back.
|
|
13
|
-
*/
|
|
14
|
-
export class Captures {
|
|
15
|
-
shapes;
|
|
16
|
-
data;
|
|
17
|
-
constructor(shapes, data) {
|
|
18
|
-
this.shapes = shapes;
|
|
19
|
-
this.data = data;
|
|
20
|
-
}
|
|
21
|
-
get(name) {
|
|
22
|
-
const d = this.data.get(name);
|
|
23
|
-
if (!d) {
|
|
24
|
-
const known = [...this.data.keys()].sort().join(', ');
|
|
25
|
-
const detail = known ? `Known this call: ${known}` : `(call run/step with { withCaptures: true } to populate)`;
|
|
26
|
-
throw new Error(`Captures.get: '${name}' not present. ${detail}`);
|
|
27
|
-
}
|
|
28
|
-
return d;
|
|
29
|
-
}
|
|
30
|
-
shapeOf(name) {
|
|
31
|
-
const s = this.shapes[name];
|
|
32
|
-
if (!s) {
|
|
33
|
-
const known = Object.keys(this.shapes).sort().join(', ') || '(none registered)';
|
|
34
|
-
throw new Error(`Captures.shapeOf: '${name}' not registered. Known: ${known}`);
|
|
35
|
-
}
|
|
36
|
-
return s;
|
|
37
|
-
}
|
|
38
|
-
has(name) { return this.data.has(name); }
|
|
39
|
-
names() { return [...this.data.keys()].sort(); }
|
|
40
|
-
}
|
|
41
|
-
// Inlined numeric values (per WebGPU spec) so this module is importable in Node
|
|
42
|
-
// for codegen-only usage. The browser provides GPUBufferUsage as a global, but
|
|
43
|
-
// referencing it at module scope would crash before any browser code runs.
|
|
44
|
-
const STORAGE_RW = 0x80 /*STORAGE*/ | 0x8 /*COPY_DST*/ | 0x4; /*COPY_SRC*/
|
|
45
|
-
const READBACK = 0x1 /*MAP_READ*/ | 0x8; /*COPY_DST*/
|
|
46
|
-
export async function createRuntime(plan, kernels, lossBufferId, opts = {}) {
|
|
47
|
-
const device = opts.device ?? await acquireDevice();
|
|
48
|
-
const queue = device.queue;
|
|
49
|
-
// ---- Allocate one GPUBuffer per BufferSpec --------------------------------
|
|
50
|
-
// State buffers also get filled with their initValue at allocation time.
|
|
51
|
-
// Param buffers may be supplied externally via opts.sharedParams; in that
|
|
52
|
-
// case we reuse the provided GPUBuffer instead of allocating, and the
|
|
53
|
-
// sibling compile that owns it is responsible for upload + lifetime.
|
|
54
|
-
// ownedBufferIds tracks which buffers we allocated ourselves (and so must
|
|
55
|
-
// destroy on .destroy()) vs which were handed in by a sibling compile.
|
|
56
|
-
const buffers = new Map();
|
|
57
|
-
const ownedBufferIds = new Set();
|
|
58
|
-
const sharedParams = opts.sharedParams;
|
|
59
|
-
for (const spec of plan.buffers) {
|
|
60
|
-
const shared = spec.kind === 'param' ? sharedParams?.get(spec.name) : undefined;
|
|
61
|
-
if (shared) {
|
|
62
|
-
if (shared.size !== spec.byteSize) {
|
|
63
|
-
throw new Error(`sharedParams: size mismatch for '${spec.name}' — supplied ${shared.size} bytes, ` +
|
|
64
|
-
`compiled graph expects ${spec.byteSize}.`);
|
|
65
|
-
}
|
|
66
|
-
buffers.set(spec.id, shared);
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
const buf = device.createBuffer({
|
|
70
|
-
size: spec.byteSize,
|
|
71
|
-
usage: STORAGE_RW,
|
|
72
|
-
label: spec.name ?? `t${spec.id}-${spec.kind}`,
|
|
73
|
-
});
|
|
74
|
-
buffers.set(spec.id, buf);
|
|
75
|
-
ownedBufferIds.add(spec.id);
|
|
76
|
-
if (spec.kind === 'state')
|
|
77
|
-
fillStateBuffer(spec, buf);
|
|
78
|
-
}
|
|
79
|
-
// ---- Compile pipelines per kernel; cache by WGSL source -------------------
|
|
80
|
-
// Push an error scope around each shader+pipeline creation so we can surface
|
|
81
|
-
// the actual compile error rather than the cryptic "previous error" that
|
|
82
|
-
// comes from using an invalid pipeline at dispatch time.
|
|
83
|
-
const moduleCache = new Map();
|
|
84
|
-
const pipelines = [];
|
|
85
|
-
const probes = [];
|
|
86
|
-
for (const k of kernels) {
|
|
87
|
-
if (!k.wgsl) {
|
|
88
|
-
pipelines.push(null);
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
let module = moduleCache.get(k.wgsl);
|
|
92
|
-
if (!module) {
|
|
93
|
-
module = device.createShaderModule({ code: k.wgsl, label: k.opKind });
|
|
94
|
-
moduleCache.set(k.wgsl, module);
|
|
95
|
-
}
|
|
96
|
-
device.pushErrorScope('validation');
|
|
97
|
-
const pipeline = device.createComputePipeline({
|
|
98
|
-
layout: 'auto',
|
|
99
|
-
compute: { module, entryPoint: 'main' },
|
|
100
|
-
label: k.opKind,
|
|
101
|
-
});
|
|
102
|
-
pipelines.push(pipeline);
|
|
103
|
-
probes.push(device.popErrorScope().then(err => err ? { k, module: module, err } : null));
|
|
104
|
-
}
|
|
105
|
-
const probeResults = await Promise.all(probes);
|
|
106
|
-
const failures = probeResults.filter((p) => p != null);
|
|
107
|
-
if (failures.length > 0) {
|
|
108
|
-
const reports = [];
|
|
109
|
-
for (const { k, module, err } of failures) {
|
|
110
|
-
const info = await module.getCompilationInfo();
|
|
111
|
-
const messages = info.messages
|
|
112
|
-
.map(m => ` L${m.lineNum}:${m.linePos} [${m.type}] ${m.message}`)
|
|
113
|
-
.join('\n');
|
|
114
|
-
reports.push(`[shader compile error] ${k.opKind} (op #${k.opIndex}): ${err.message}\n` +
|
|
115
|
-
(messages || ' (no compilation messages)') +
|
|
116
|
-
`\n--- WGSL ---\n${k.wgsl}\n-----------`);
|
|
117
|
-
}
|
|
118
|
-
// eslint-disable-next-line no-console
|
|
119
|
-
console.error(reports.join('\n\n'));
|
|
120
|
-
throw new Error(`tensorgrad: ${failures.length} shader(s) failed to compile (see console).`);
|
|
121
|
-
}
|
|
122
|
-
// ---- Pre-build bind groups (static — buffer ids don't change per step) ---
|
|
123
|
-
const bindGroups = kernels.map((k, i) => {
|
|
124
|
-
const pipeline = pipelines[i];
|
|
125
|
-
if (!pipeline)
|
|
126
|
-
return null;
|
|
127
|
-
return device.createBindGroup({
|
|
128
|
-
layout: pipeline.getBindGroupLayout(0),
|
|
129
|
-
entries: k.bindings.map((bufId, idx) => ({
|
|
130
|
-
binding: idx,
|
|
131
|
-
resource: { buffer: buffers.get(bufId) },
|
|
132
|
-
})),
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
// ---- Output readback staging buffer ---------------------------------------
|
|
136
|
-
// `outputBufferId` is the graph's main output (loss for training, the user's
|
|
137
|
-
// returned tensor for forward-only). step() reads back its first element;
|
|
138
|
-
// run() reads back the full Float32Array.
|
|
139
|
-
const outputSpec = plan.buffers[lossBufferId];
|
|
140
|
-
const outputReadback = device.createBuffer({ size: outputSpec.byteSize, usage: READBACK });
|
|
141
|
-
let captureStaging = null;
|
|
142
|
-
function ensureCaptureStaging() {
|
|
143
|
-
if (captureStaging)
|
|
144
|
-
return captureStaging;
|
|
145
|
-
let totalBytes = 0;
|
|
146
|
-
const slices = [];
|
|
147
|
-
for (const [name, bufId] of plan.capturesByName) {
|
|
148
|
-
const spec = plan.buffers[bufId];
|
|
149
|
-
// copyBufferToBuffer offsets must be 4-aligned. Capture byteSizes are
|
|
150
|
-
// always shape-product × 4 (f32/i32/bool all 4 bytes), so cumulative
|
|
151
|
-
// offsets stay aligned.
|
|
152
|
-
slices.push({ name, bufId, offset: totalBytes, byteSize: spec.byteSize });
|
|
153
|
-
totalBytes += spec.byteSize;
|
|
154
|
-
}
|
|
155
|
-
const buffer = device.createBuffer({ size: totalBytes, usage: READBACK, label: 'captures-staging' });
|
|
156
|
-
captureStaging = { buffer, slices };
|
|
157
|
-
return captureStaging;
|
|
158
|
-
}
|
|
159
|
-
// ---- dispatch() — shared core for step() and run() -----------------------
|
|
160
|
-
// Uploads inputs, dispatches all kernels (in order), queues writebacks, copies
|
|
161
|
-
// the output buffer into its staging, optionally copies captures into theirs,
|
|
162
|
-
// submits, and reads back. Returns the full output Float32Array; step() takes
|
|
163
|
-
// [0] for scalar loss, run() returns it whole.
|
|
164
|
-
//
|
|
165
|
-
// **Concurrent calls auto-serialize.** Two `step()`/`run()` calls on the same
|
|
166
|
-
// runtime would otherwise both try to `mapAsync` the shared output staging
|
|
167
|
-
// buffer at the same time and trip "Buffer already has an outstanding map
|
|
168
|
-
// pending." We chain each new dispatch onto the prior one's promise so they
|
|
169
|
-
// run sequentially even when fired from independent async paths (e.g., a
|
|
170
|
-
// training loop's auxiliary `refreshPrediction()` + `writeDiagnostic()`).
|
|
171
|
-
let pending = Promise.resolve();
|
|
172
|
-
async function dispatch(inputs, opts) {
|
|
173
|
-
const turn = pending.catch(() => { }).then(() => dispatchUnsynchronized(inputs, opts));
|
|
174
|
-
pending = turn;
|
|
175
|
-
return turn;
|
|
176
|
-
}
|
|
177
|
-
async function dispatchUnsynchronized(inputs, opts) {
|
|
178
|
-
const wantCaptures = opts.wantCaptures;
|
|
179
|
-
if (wantCaptures && plan.capturesByName.size === 0) {
|
|
180
|
-
throw new Error(`withCaptures=true but no capture(...) calls were registered during ` +
|
|
181
|
-
`the trace. Add capture('name', tensor) inside your forward pass for ` +
|
|
182
|
-
`the intermediates you want read back.`);
|
|
183
|
-
}
|
|
184
|
-
for (const [name, bufId] of plan.inputsByName) {
|
|
185
|
-
const data = inputs[name];
|
|
186
|
-
if (!data)
|
|
187
|
-
throw new Error(`tensorgrad: missing input '${name}'`);
|
|
188
|
-
const expectedBytes = plan.buffers[bufId].byteSize;
|
|
189
|
-
if (data.byteLength !== expectedBytes) {
|
|
190
|
-
throw new Error(`tensorgrad: input '${name}' has ${data.byteLength} bytes, expected ${expectedBytes}`);
|
|
191
|
-
}
|
|
192
|
-
// Cast to BufferSource: typed arrays are accepted by writeBuffer at runtime
|
|
193
|
-
// but TS may infer ArrayBufferLike (vs ArrayBuffer) under strict configs.
|
|
194
|
-
queue.writeBuffer(buffers.get(bufId), 0, data);
|
|
195
|
-
}
|
|
196
|
-
const encoder = device.createCommandEncoder({ label: 'tensorgrad-step' });
|
|
197
|
-
for (let i = 0; i < kernels.length; i++) {
|
|
198
|
-
const k = kernels[i];
|
|
199
|
-
if (!k.wgsl || k.threads === 0)
|
|
200
|
-
continue;
|
|
201
|
-
const pipeline = pipelines[i];
|
|
202
|
-
const bindGroup = bindGroups[i];
|
|
203
|
-
const pass = encoder.beginComputePass({ label: k.opKind });
|
|
204
|
-
pass.setPipeline(pipeline);
|
|
205
|
-
pass.setBindGroup(0, bindGroup);
|
|
206
|
-
// WebGPU caps each dispatch dimension at 65535 workgroups. Split into 2D
|
|
207
|
-
// when a kernel needs more than that on the X axis. Kernels compute their
|
|
208
|
-
// global index as `gid.x + gid.y * (65535 * workgroup_size)`, matching the
|
|
209
|
-
// stride we set here. For dispatches that fit in one row, gid.y is 0.
|
|
210
|
-
const wgCount = Math.max(1, Math.ceil(k.threads / k.workgroupSize));
|
|
211
|
-
const MAX_X = 65535;
|
|
212
|
-
const wgX = Math.min(wgCount, MAX_X);
|
|
213
|
-
const wgY = Math.ceil(wgCount / MAX_X);
|
|
214
|
-
pass.dispatchWorkgroups(wgX, wgY, 1);
|
|
215
|
-
pass.end();
|
|
216
|
-
}
|
|
217
|
-
// After all dispatches: writebacks (Adam state, updated params). Empty for
|
|
218
|
-
// forward-only compiles.
|
|
219
|
-
for (const wb of plan.writebacks) {
|
|
220
|
-
encoder.copyBufferToBuffer(buffers.get(wb.source), 0, buffers.get(wb.dest), 0, wb.bytes);
|
|
221
|
-
}
|
|
222
|
-
encoder.copyBufferToBuffer(buffers.get(lossBufferId), 0, outputReadback, 0, outputSpec.byteSize);
|
|
223
|
-
// Capture readbacks (only when opted in). All captures concatenate into
|
|
224
|
-
// a single staging buffer so we mapAsync once instead of N times.
|
|
225
|
-
let layout = null;
|
|
226
|
-
if (wantCaptures) {
|
|
227
|
-
layout = ensureCaptureStaging();
|
|
228
|
-
for (const s of layout.slices) {
|
|
229
|
-
encoder.copyBufferToBuffer(buffers.get(s.bufId), 0, layout.buffer, s.offset, s.byteSize);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
queue.submit([encoder.finish()]);
|
|
233
|
-
// readback=false: training fire-and-forget. The encoder still copied
|
|
234
|
-
// loss → outputReadback (and captures → staging), but we don't await
|
|
235
|
-
// mapAsync. The caller can read the latest loss later via readLoss()
|
|
236
|
-
// when it actually wants to display it.
|
|
237
|
-
if (!opts.readback)
|
|
238
|
-
return null;
|
|
239
|
-
await outputReadback.mapAsync(GPUMapMode.READ);
|
|
240
|
-
const output = new Float32Array(outputReadback.getMappedRange().slice(0));
|
|
241
|
-
outputReadback.unmap();
|
|
242
|
-
const captures = new Map();
|
|
243
|
-
if (layout) {
|
|
244
|
-
await layout.buffer.mapAsync(GPUMapMode.READ);
|
|
245
|
-
const range = layout.buffer.getMappedRange();
|
|
246
|
-
for (const s of layout.slices) {
|
|
247
|
-
// Copy out (slice) before unmap — the underlying ArrayBuffer is
|
|
248
|
-
// detached when the buffer unmaps.
|
|
249
|
-
captures.set(s.name, new Float32Array(range, s.offset, s.byteSize / 4).slice());
|
|
250
|
-
}
|
|
251
|
-
layout.buffer.unmap();
|
|
252
|
-
}
|
|
253
|
-
return { output, captures };
|
|
254
|
-
}
|
|
255
|
-
async function step(inputs, opts) {
|
|
256
|
-
if (opts?.readLoss === false) {
|
|
257
|
-
await dispatch(inputs, { wantCaptures: false, readback: false });
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
const r = (await dispatch(inputs, { wantCaptures: opts?.withCaptures === true, readback: true }));
|
|
261
|
-
if (opts?.withCaptures)
|
|
262
|
-
return { loss: r.output[0], captures: new Captures(captureShapes, r.captures) };
|
|
263
|
-
return r.output[0];
|
|
264
|
-
}
|
|
265
|
-
// ---- readLoss() — explicit late readback for fire-and-forget training -----
|
|
266
|
-
// Maps the output buffer (which step() always copies the latest loss into,
|
|
267
|
-
// even when readLoss:false) and returns the value. Goes through the same
|
|
268
|
-
// serialization chain as step()/run() so two readLoss() calls don't both
|
|
269
|
-
// try to mapAsync the same buffer.
|
|
270
|
-
async function readLoss() {
|
|
271
|
-
const turn = pending.catch(() => { }).then(async () => {
|
|
272
|
-
await outputReadback.mapAsync(GPUMapMode.READ);
|
|
273
|
-
const v = new Float32Array(outputReadback.getMappedRange())[0];
|
|
274
|
-
outputReadback.unmap();
|
|
275
|
-
return v;
|
|
276
|
-
});
|
|
277
|
-
pending = turn;
|
|
278
|
-
return turn;
|
|
279
|
-
}
|
|
280
|
-
async function run(inputs, opts) {
|
|
281
|
-
const r = (await dispatch(inputs, { wantCaptures: opts?.withCaptures === true, readback: true }));
|
|
282
|
-
if (opts?.withCaptures)
|
|
283
|
-
return { output: r.output, captures: new Captures(captureShapes, r.captures) };
|
|
284
|
-
return r.output;
|
|
285
|
-
}
|
|
286
|
-
// ---- uploadParams ---------------------------------------------------------
|
|
287
|
-
function uploadParams(params, opts) {
|
|
288
|
-
const partial = opts?.partial ?? false;
|
|
289
|
-
for (const name of Object.keys(params)) {
|
|
290
|
-
if (!plan.paramsByName.has(name)) {
|
|
291
|
-
throw new Error(`uploadParams: unknown param '${name}'. ` +
|
|
292
|
-
`Known: ${[...plan.paramsByName.keys()].sort().join(', ')}`);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
if (!partial) {
|
|
296
|
-
for (const name of plan.paramsByName.keys()) {
|
|
297
|
-
if (!(name in params)) {
|
|
298
|
-
throw new Error(`uploadParams: missing param '${name}'. ` +
|
|
299
|
-
`Pass { partial: true } if you mean to update only some params.`);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
for (const [name, bufId] of plan.paramsByName) {
|
|
304
|
-
const data = params[name];
|
|
305
|
-
if (!data)
|
|
306
|
-
continue;
|
|
307
|
-
const expected = plan.buffers[bufId].byteSize / 4;
|
|
308
|
-
if (data.length !== expected) {
|
|
309
|
-
throw new Error(`uploadParams: '${name}' has ${data.length} elements, expected ${expected}`);
|
|
310
|
-
}
|
|
311
|
-
queue.writeBuffer(buffers.get(bufId), 0, data);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
// ---- download helpers -----------------------------------------------------
|
|
315
|
-
async function downloadFromMap(map) {
|
|
316
|
-
const stagings = [];
|
|
317
|
-
const encoder = device.createCommandEncoder({ label: 'tensorgrad-download' });
|
|
318
|
-
for (const [name, bufId] of map) {
|
|
319
|
-
const spec = plan.buffers[bufId];
|
|
320
|
-
const staging = device.createBuffer({ size: spec.byteSize, usage: READBACK });
|
|
321
|
-
encoder.copyBufferToBuffer(buffers.get(bufId), 0, staging, 0, spec.byteSize);
|
|
322
|
-
stagings.push({ name, buf: staging, bytes: spec.byteSize });
|
|
323
|
-
}
|
|
324
|
-
queue.submit([encoder.finish()]);
|
|
325
|
-
const out = {};
|
|
326
|
-
for (const s of stagings) {
|
|
327
|
-
await s.buf.mapAsync(GPUMapMode.READ);
|
|
328
|
-
out[s.name] = new Float32Array(s.buf.getMappedRange().slice(0));
|
|
329
|
-
s.buf.unmap();
|
|
330
|
-
s.buf.destroy();
|
|
331
|
-
}
|
|
332
|
-
return out;
|
|
333
|
-
}
|
|
334
|
-
// Fill a state buffer with its declared initValue (typically 0). Float and
|
|
335
|
-
// int both serialize to 4 bytes per element. Used at allocation time and on
|
|
336
|
-
// resetOptimizerState() — same logic, two callers.
|
|
337
|
-
function fillStateBuffer(spec, target) {
|
|
338
|
-
const elements = spec.byteSize / 4;
|
|
339
|
-
const init = spec.dtype === 'f32'
|
|
340
|
-
? new Float32Array(elements).fill(spec.initValue ?? 0)
|
|
341
|
-
: new Int32Array(elements).fill(Math.trunc(spec.initValue ?? 0));
|
|
342
|
-
queue.writeBuffer(target, 0, init);
|
|
343
|
-
}
|
|
344
|
-
function resetOptimizerState() {
|
|
345
|
-
for (const spec of plan.buffers) {
|
|
346
|
-
if (spec.kind === 'state')
|
|
347
|
-
fillStateBuffer(spec, buffers.get(spec.id));
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
// Build the params map AFTER buffer allocation so it points at the actual
|
|
351
|
-
// GPUBuffers (shared or freshly allocated).
|
|
352
|
-
const params = new Map();
|
|
353
|
-
for (const [name, bufId] of plan.paramsByName) {
|
|
354
|
-
params.set(name, buffers.get(bufId));
|
|
355
|
-
}
|
|
356
|
-
// Static-after-compile shape metadata so users don't have to recompute
|
|
357
|
-
// strides to interpret a flat capture readback.
|
|
358
|
-
const captureShapes = {};
|
|
359
|
-
for (const [name, bufId] of plan.capturesByName) {
|
|
360
|
-
captureShapes[name] = [...plan.buffers[bufId].shape];
|
|
361
|
-
}
|
|
362
|
-
const outputShape = [...plan.buffers[lossBufferId].shape];
|
|
363
|
-
const destroy = () => {
|
|
364
|
-
for (const [id, b] of buffers) {
|
|
365
|
-
if (ownedBufferIds.has(id))
|
|
366
|
-
b.destroy();
|
|
367
|
-
}
|
|
368
|
-
outputReadback.destroy();
|
|
369
|
-
if (captureStaging)
|
|
370
|
-
captureStaging.buffer.destroy();
|
|
371
|
-
};
|
|
372
|
-
return {
|
|
373
|
-
device,
|
|
374
|
-
params,
|
|
375
|
-
outputShape,
|
|
376
|
-
uploadParams,
|
|
377
|
-
downloadParams: () => downloadFromMap(plan.paramsByName),
|
|
378
|
-
downloadParamGrads: () => downloadFromMap(plan.paramGradsByName),
|
|
379
|
-
step,
|
|
380
|
-
run,
|
|
381
|
-
readLoss,
|
|
382
|
-
resetOptimizerState,
|
|
383
|
-
destroy,
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
/** Same machinery as `createRuntime`, narrower public type: a forward-only
|
|
387
|
-
* graph exposes `run()` instead of `step()` (no optimizer state, no scalar-
|
|
388
|
-
* loss readback). The full runtime object is built once and projected by
|
|
389
|
-
* `compileForward` to the public shape. */
|
|
390
|
-
export async function createForwardRuntime(plan, kernels, outputBufferId, opts = {}) {
|
|
391
|
-
return await createRuntime(plan, kernels, outputBufferId, opts);
|
|
392
|
-
}
|
|
393
|
-
async function acquireDevice() {
|
|
394
|
-
if (typeof navigator === 'undefined' || !navigator.gpu) {
|
|
395
|
-
throw new Error('tensorgrad: WebGPU not available in this environment');
|
|
396
|
-
}
|
|
397
|
-
const adapter = await navigator.gpu.requestAdapter();
|
|
398
|
-
if (!adapter)
|
|
399
|
-
throw new Error('tensorgrad: no WebGPU adapter');
|
|
400
|
-
return await adapter.requestDevice();
|
|
401
|
-
}
|
|
402
|
-
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,uEAAuE;AACvE,EAAE;AACF,8DAA8D;AAgB9D;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IAEA;IACA;IAFnB,YACmB,MAAyC,EACzC,IAA+B;QAD/B,WAAM,GAAN,MAAM,CAAmC;QACzC,SAAI,GAAJ,IAAI,CAA2B;IAC/C,CAAC;IACJ,GAAG,CAAC,IAAY;QACd,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC7B,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACrD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC,CAAC,yDAAyD,CAAA;YAC9G,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,kBAAkB,MAAM,EAAE,CAAC,CAAA;QACnE,CAAC;QACD,OAAO,CAAC,CAAA;IACV,CAAC;IACD,OAAO,CAAC,IAAY;QAClB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC3B,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,MAA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