{"record":{"id":"c6519bcbc20446cd","repo":"jax-ml/jax","slug":"duplicate-serialization-registration-for-serialize","errorCode":null,"errorMessage":"Duplicate serialization registration for serialized_name `{serialized_name}`. Previous registration was for type `{deserialization_registry[serialized_name][0]}`.","messagePattern":"Duplicate serialization registration for serialized_name `(.+?)`\\. Previous registration was for type `(.+?)`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/export/_export.py","lineNumber":437,"sourceCode":"      :func:`jax.tree_util.register_pytree_node`. If not present, we look up\n      and use the ``unflatten_func``. This is needed for ``collections.namedtuple``,\n      which does not have a ``register_pytree_node``, but it can be useful to\n      override that function. Note that the result of ``from_children`` is\n      only used with :func:`jax.tree_util.tree_structure` to construct a proper\n      PyTree node, it is not used to construct the outputs of the serialized\n      function.\n\n  Returns:\n    the same type passed as ``nodetype``, so that this function can\n    be used as a class decorator.\n  \"\"\"\n  if nodetype in serialization_registry:\n    raise ValueError(\n        f\"Duplicate serialization registration for type `{nodetype}`. \"\n        \"Previous registration was with serialized_name \"\n        f\"`{serialization_registry[nodetype][0]}`.\")\n  if serialized_name in deserialization_registry:\n    raise ValueError(\n        \"Duplicate serialization registration for \"\n        f\"serialized_name `{serialized_name}`. \"\n        \"Previous registration was for type \"\n        f\"`{deserialization_registry[serialized_name][0]}`.\")\n  if from_children is None:\n    if nodetype not in tree_util._registry:\n      raise ValueError(\n          f\"If `from_children` is not present, you must call first\"\n          f\"`jax.tree_util.register_pytree_node` for `{nodetype}`\")\n    from_children = tree_util._registry[nodetype].from_iter\n\n  serialization_registry[nodetype] = (\n      serialized_name, serialize_auxdata)\n  deserialization_registry[serialized_name] = (\n      nodetype, deserialize_auxdata, from_children)\n  return nodetype\n\n","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/export/_export.py#L419-L455","documentation":"The companion check to 518: a different Python type was previously registered under the same serialized_name, so registering a new type with that name would make deserialization ambiguous. The error names the type that already owns the name.","triggerScenarios":"Registering class B with serialized_name 'my_type' when class A already used 'my_type'; name collisions between your registration and one made by a framework (e.g. a library also registering 'FrozenDict'); renaming classes but keeping the serialized name for compatibility.","commonSituations":"Two dependencies claiming the same serialized name; versioned class hierarchies where old and new classes share a wire name; copy-pasted registration code across modules.","solutions":["Choose a unique, namespaced serialized_name like 'mylib.MyType'","Reuse the existing registration (import the type that already owns the name) instead of re-registering","If you renamed a class intentionally, keep the old registration for backward compatibility and register the new class under a new name"],"exampleFix":"# before\nregister_pytree_node_serialization(NewType, 'FrozenDict')  # name taken\n\n# after\nregister_pytree_node_serialization(NewType, 'mylib.NewType')","handlingStrategy":"validation","validationCode":"from jax.experimental import export\nname_taken = 'my_type' in export.deserialization_registry\nif name_taken and export.deserialization_registry['my_type'][0] is not MyType:\n    raise RuntimeError('serialized name collision; pick a namespaced name')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Namespace serialized names: 'mylib.TypeName'","Register each wire name exactly once across the whole dependency tree","When renaming classes, assign a new serialized name rather than reusing the old one"],"tags":["jax","export","serialization","registry","name-collision"],"backgroundTag":"duplicate-registration","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}