{"record":{"id":"ce2fa9710ee1c36e","repo":"tracel-ai/burn","slug":"state-of-fusion-optimization-failed-to-decode","errorCode":null,"errorMessage":"state of fusion optimization `{}` failed to decode: {err}","messagePattern":"state of fusion optimization `(.+?)` failed to decode: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl-fusion/src/optim/base.rs","lineNumber":181,"sourceCode":"            name: name.to_string(),\n            state: {\n                let mut bytes = Vec::new();\n                ciborium::into_writer(state, &mut bytes)\n                    .expect(\"fusion optimization state must be serializable\");\n                bytes\n            },\n        }\n    }\n\n    /// Decode the optimization's state.\n    ///\n    /// # Panics\n    ///\n    /// When the bytes don't decode as `T` — the state was produced by a\n    /// different optimization sharing the name, or by an incompatible version.\n    pub fn decode<T: DeserializeOwned>(&self) -> T {\n        ciborium::from_reader(self.state.as_slice()).unwrap_or_else(|err| {\n            panic!(\n                \"state of fusion optimization `{}` failed to decode: {err}\",\n                self.name\n            )\n        })\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn state_round_trips_through_bytes() {\n        let state = CubeOptimizationState::new(\"custom\", &vec![3u32, 7]);\n\n        assert_eq!(state.name, \"custom\");\n        assert_eq!(state.decode::<Vec<u32>>(), vec![3, 7]);\n    }","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl-fusion/src/optim/base.rs#L163-L199","documentation":"Decode guard on stored fusion-optimization state: `OptimizationState::decode::<T>` expects the CBOR bytes to deserialize into the requested type T. The panic fires when the stored state was written by a different optimization that happens to share the same `name`, or by an incompatible version of the same optimization, so the bytes do not match T's schema.","triggerScenarios":"Thrown at crates/burn-cubecl-fusion/src/optim/base.rs:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Decode with the exact state type the optimization originally serialized (matching name AND type).","Bump or namespace the optimization name when its state layout changes, so old states are not mistaken for new ones.","Delete the stale checkpoint/cache containing the incompatible state and let the optimization re-initialize."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}