{"record":{"id":"135571817daa8682","repo":"tracel-ai/burn","slug":"capture-tensor-has-no-initialized-value","errorCode":null,"errorMessage":"capture tensor {} has no initialized value","messagePattern":"capture tensor (.+?) has no initialized value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-capture/src/capture.rs","lineNumber":357,"sourceCode":"    type Device = CaptureDevice;\n    type Bridge = CaptureBridge;\n    type Client = CaptureClient;\n\n    fn name(_device: &Self::Device) -> String {\n        \"capture\".into()\n    }\n\n    fn init_client(_device: &Self::Device) -> Self::Client {\n        // `get_client` reaches this only when no capture scope registered its client first.\n        panic!(\"capture tensor operations must run inside CaptureDevice::capture_scope\")\n    }\n\n    fn get_tensor_handle(tensor: &TensorIr, client: &Self::Client) -> TensorData {\n        client\n            .state()\n            .lock()\n            .value(tensor.id)\n            .unwrap_or_else(|| panic!(\"capture tensor {} has no initialized value\", tensor.id))\n    }\n\n    fn register_tensor(\n        client: &Self::Client,\n        handle: TensorData,\n        _shape: Shape,\n        _dtype: DType,\n    ) -> RouterTensor<Self::Client> {\n        client.register_tensor_data(handle)\n    }\n}\n\n/// Bridge for materialized values between independent capture devices.\n///\n/// Only initialized tensors have handles in the capture backend, so values reaching this bridge\n/// are concrete and can safely initialize a tensor in another capture scope. Computed tensors have\n/// no materialized handle and are rejected by [`CaptureChannel::get_tensor_handle`] first.\npub struct CaptureBridge;","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-capture/src/capture.rs#L339-L375","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet t = Tensor::<BurnDevice, 2>::ones([2, 2], &real_device); // different backend\nlet data = capture_client.get_tensor_by_id(t.primitive.id); // panic: unknown id\n// after\ndevice.capture_scope(|device| {\n    let t = Tensor::<CaptureDevice, 2>::ones([2, 2], device); // registered in scope\n    // ...\n});","handlingStrategy":"validation","validationCode":"// Only request handles for tensors created in the active capture session\nlet data = device.capture_scope(|device| {\n    let t = Tensor::<CaptureDevice, 2>::zeros([4, 4], device);\n    capture_client.get_tensor_handle(&t.primitive.to_ir(), &client) // id registered in this scope\n});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","burn","graph-capture","state"],"backgroundTag":"tensor-not-initialized","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}