Debugging Overview
Volten debugging is opt-in per node.
You can enable debugging when you create the node, add debug functions in WGSL, run the node, then read its debug output.
const kernel = new Kernel(` fn main(gid: vec3u) { inout[gid.x] = inout[gid.x] * mult;
if (gid.x == 2u) { enableDebug(); }
// Only gid.x == 2u will emit debug logs debugF32("value", inout[gid.x]); }`);
const node = v.pass(kernel, { inout, mult }, { debug: true });
v.run(node);
const debug = await v.readDebug(node);debug.print();Console output:
[2,0,0] value: 30output is defined as: [global invocation id] message: value
The Debugging Loop
Section titled “The Debugging Loop”- Create a node with
{ debug: true }. - Call
enableDebug()inside the invocation you want to inspect. - Log later values with a typed helper like
debugF32()ordebugVec4f(). - Call
v.readDebug(node)afterv.run(node).
Keep Logs Narrow
Section titled “Keep Logs Narrow”GPU kernels may run thousands of invocations. A debug call inside every invocation can fill the debug buffer quickly.
Prefer a condition around enableDebug().
if (gid.x == 0u) { enableDebug();}
// Only gid.x == 0u emits this log.debugVec3f("first item", data[gid.x]);enableDebug() applies only to the current invocation. From that point on, debug calls in that invocation emit logs. Other invocations keep running normally, but their debug calls stay silent.