tracel-ai/burn · error
capture tensor {} has no initialized value
Error message
capture tensor {} has no initialized value What it means
During graph capture, `get_tensor_handle` reads a tensor's recorded value from the capture client state by tensor id. If the tensor was never registered/initialized on the capture client (no value recorded for that id), the lookup fails and this panic fires. It indicates the tensor handle being fetched was never produced inside the capture session.
Source
Thrown at crates/burn-capture/src/capture.rs:357
type Device = CaptureDevice;
type Bridge = CaptureBridge;
type Client = CaptureClient;
fn name(_device: &Self::Device) -> String {
"capture".into()
}
fn init_client(_device: &Self::Device) -> Self::Client {
// `get_client` reaches this only when no capture scope registered its client first.
panic!("capture tensor operations must run inside CaptureDevice::capture_scope")
}
fn get_tensor_handle(tensor: &TensorIr, client: &Self::Client) -> TensorData {
client
.state()
.lock()
.value(tensor.id)
.unwrap_or_else(|| panic!("capture tensor {} has no initialized value", tensor.id))
}
fn register_tensor(
client: &Self::Client,
handle: TensorData,
_shape: Shape,
_dtype: DType,
) -> RouterTensor<Self::Client> {
client.register_tensor_data(handle)
}
}
/// Bridge for materialized values between independent capture devices.
///
/// Only initialized tensors have handles in the capture backend, so values reaching this bridge
/// are concrete and can safely initialize a tensor in another capture scope. Computed tensors have
/// no materialized handle and are rejected by [`CaptureChannel::get_tensor_handle`] first.
pub struct CaptureBridge;View on GitHub (pinned to d16f7ba2ed)
Solutions
- Ensure every tensor whose handle is read is created inside the active capture scope so it gets registered with a value.
- Verify the tensor id passed to get_tensor_handle belongs to this capture client, not another backend's client.
- Register/initialize the tensor on the capture client (register_tensor) before requesting its handle.
Example fix
// before
let t = Tensor::<BurnDevice, 2>::ones([2, 2], &real_device); // different backend
let data = capture_client.get_tensor_by_id(t.primitive.id); // panic: unknown id
// after
device.capture_scope(|device| {
let t = Tensor::<CaptureDevice, 2>::ones([2, 2], device); // registered in scope
// ...
}); Defensive patterns
Strategy: validation
Validate before calling
// Only request handles for tensors created in the active capture session
let data = device.capture_scope(|device| {
let t = Tensor::<CaptureDevice, 2>::zeros([4, 4], device);
capture_client.get_tensor_handle(&t.primitive.to_ir(), &client) // id registered in this scope
}); Prevention
- Create every tensor you will read inside the same capture scope
- Don't mix tensor ids across backends/clients
- Register tensors explicitly when writing custom capture ops
When it happens
Trigger: Reading a tensor whose id is unknown to the capture client state — e.g. a tensor created outside the capture scope, a tensor whose registration was skipped, or reading the handle of a tensor before any operation initialized it.
Common situations: Importing/serializing tensors created on a different backend into capture; reusing a stale tensor id after the scope ended; a custom kernel/op that creates tensors without going through the capture client registration path.
Related errors
- capture graph {graph_id:?} was not registered
- capture tensor operations must run inside CaptureDevice::cap
- seeding is not supported during graph capture
- Message should have been TensorData
- Received a message that wasn't a tensor request! {msg:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/135571817daa8682.
Report an issue: GitHub.