tracel-ai/burn · error

tuple variant is not implemented because it is not used in t

Error message

tuple variant is not implemented because it is not used in the burn module

What it means

The nested Deserializer's VariantAccess does not implement tuple variants. burn's module representation never uses serde tuple variants, so the method is stubbed with unimplemented! and panics if a type's Deserialize impl requests a tuple variant (deserialize_tuple_variant) during nested deserialization.

Source

Thrown at crates/burn-store/src/nested/de.rs:713

                        Err(Error::Other("Wrong variant".to_string()))
                    }
                }
                Some(other) => Err(custom_err(format!(
                    "expected DType variant as string, got {other:?}"
                ))),
                None => Err(custom_err("expected map containing 'DType' key for enum")),
            },
            other => Err(custom_err(format!(
                "expected map for enum variant, got {other:?}"
            ))),
        }
    }

    fn tuple_variant<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: Visitor<'de>,
    {
        unimplemented!("tuple variant is not implemented because it is not used in the burn module")
    }

    fn struct_variant<V>(
        self,
        _fields: &'static [&'static str],
        _visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: Visitor<'de>,
    {
        unimplemented!(
            "struct variant is not implemented because it is not used in the burn module"
        )
    }
}

/// A wrapper for the nested value data structure with a burn module adapter.
struct NestedValueWrapper<A: BurnModuleAdapter> {

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Replace tuple variants with struct variants in the deserialized type
  2. Use unit variants or plain structs instead of tuple-variant enums
  3. Implement tuple_variant in the adapter if you own a fork
  4. Bypass the nested deserializer and use a standard serde deserializer for that type

Example fix

// before
enum Padding { Explicit(usize, usize) }

// after
enum Padding { Explicit { top: usize, bottom: usize } }
Defensive patterns

Strategy: validation

Validate before calling

// audit types before use
fn assert_no_tuple_variants<T>() { /* rely on round-trip test */ }
#[cfg(test)]
#[test]
fn roundtrip_record() {
    let r = MyRecord::default();
    let nv = to_nested(&r).unwrap();
    let back: MyRecord = from_nested(nv).unwrap();
}

Try / catch

let result = std::panic::catch_unwind(|| MyType::deserialize(nested));
if result.is_err() { use_struct_variant_representation(); }

Prevention

When it happens

Trigger: Calling Deserialize on a type containing a tuple variant enum (e.g. `enum E { A(u32, u32) }`) through burn-store's nested value deserializer.

Common situations: Adding a custom layer or config type with tuple-variant enums to a model that is then saved/loaded via burn-store's nested record format.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/ab773ca61bed5bf7. Report an issue: GitHub.