{"record":{"id":"118b643b29c9498c","repo":"tracel-ai/burn","slug":"seeding-is-not-supported-during-graph-capture","errorCode":null,"errorMessage":"seeding is not supported during graph capture","messagePattern":"seeding is not supported during graph capture","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-capture/src/capture.rs","lineNumber":530,"sourceCode":"    }\n\n    fn register_tensor_data(&self, data: TensorData) -> RouterTensor<Self> {\n        let mut state = self.state().lock();\n        state.assert_open();\n        let id = TensorId::new(TENSOR_COUNTER.fetch_add(1, Ordering::Relaxed));\n        let shape = data.shape.clone();\n        let dtype = data.dtype;\n        state.values.insert(id, data);\n        drop(state);\n        RouterTensor::new(id, shape, dtype, self.clone())\n    }\n\n    fn device(&self) -> Self::Device {\n        self.device\n    }\n\n    fn seed(&self, _seed: u64) {\n        panic!(\"seeding is not supported during graph capture\")\n    }\n\n    fn dtype_usage(&self, dtype: DType) -> DTypeUsageSet {\n        match dtype {\n            // Capture records these operations without executing dtype-specific kernels. The\n            // router's quantized operations are not implemented yet, so quantized tensors remain\n            // the only dtype family that capture cannot represent through the backend API.\n            DType::QFloat(_) => DTypeUsageSet::empty(),\n            _ => DTypeUsage::general(),\n        }\n    }\n\n    fn register_and_execute_graph(\n        &self,\n        graph_id: GraphId,\n        relative_graph: Vec<OperationIr>,\n        bindings: GraphBindings,\n    ) {","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-capture/src/capture.rs#L512-L548","documentation":"The capture backend records operations instead of executing kernels, so it has no real RNG to reseed; calling `seed()` on a capture client panics. Randomness during capture must be handled outside the captured region or on the underlying backend.","triggerScenarios":"Calling `client.seed(seed)` or any API that reseeds the backend (e.g. seed-based random tensor config, `burn_import` seeding hooks) while the client is a capture client inside `capture_scope`.","commonSituations":"Reproducing training runs by seeding RNG when capturing a graph; framework code that unconditionally seeds before generating random weights; test harnesses that seed globally per iteration.","solutions":["Seed the underlying (real) backend device before entering `capture_scope`, not the capture client.","Remove or gate the seeding call so it is skipped when capture is active.","Generate random tensors before capture and feed them as constant inputs to the captured region."],"exampleFix":"// before\ndevice.capture_scope(|device| {\n    client.seed(42); // panic\n    let w = Tensor::<CaptureDevice, 2>::random(..., device);\n});\n// after\nreal_client.seed(42);\ndevice.capture_scope(|device| {\n    let w = Tensor::<CaptureDevice, 2>::random(..., device);\n});","handlingStrategy":"fallback","validationCode":"// Seed the real backend, not the capture client\nif !is_capture_client(&client) {\n    client.seed(42);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Seed the underlying device before entering capture_scope","Gate seeding code on capture being inactive","Pre-generate random tensors outside capture and pass them as inputs"],"tags":["rust","burn","graph-capture","rng"],"backgroundTag":"unsupported-operation-in-capture","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"}