{"record":{"id":"3c25dfda7dccb735","repo":"jax-ml/jax","slug":"out-specs-already-specified","errorCode":null,"errorMessage":"out_specs already specified","messagePattern":"out_specs already specified","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/colocated_python/func.py","lineNumber":93,"sourceCode":"    \"\"\"Creates a new specialization with overrides.\"\"\"\n    if in_specs_treedef is None:\n      in_specs_treedef = self.in_specs_treedef\n    elif self.in_specs_treedef is not None:\n      raise ValueError(\"in_specs already specified\")\n    if in_specs_leaves is None:\n      in_specs_leaves = self.in_specs_leaves\n    elif self.in_specs_leaves is not None:\n      raise ValueError(\"in_specs already specified\")\n\n    if out_specs_fn is None:\n      out_specs_fn = self.out_specs_fn\n    elif self.out_specs_fn is not None:\n      raise ValueError(\"out_specs_fn already specified\")\n\n    if out_specs_treedef is None:\n      out_specs_treedef = self.out_specs_treedef\n    elif self.out_specs_treedef is not None:\n      raise ValueError(\"out_specs already specified\")\n    if out_specs_leaves is None:\n      out_specs_leaves = self.out_specs_leaves\n    elif self.out_specs_leaves is not None:\n      raise ValueError(\"out_specs already specified\")\n\n    if devices is None:\n      devices = self.devices\n    elif self.devices is not None:\n      raise ValueError(\"devices already specified\")\n    elif not isinstance(devices, xc.DeviceList):\n      devices = xc.DeviceList(tuple(devices))\n\n    return Specialization(\n        in_specs_treedef,\n        in_specs_leaves,\n        out_specs_fn,\n        out_specs_treedef,\n        out_specs_leaves,","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/colocated_python/func.py#L75-L111","documentation":"Raised when out_specs_treedef is supplied to update() but the specialization already carries an out_specs_treedef (i.e. out_specs was previously set). Internally out_specs is flattened into (treedef, leaves), and neither part may be reassigned after being set. It guards against conflicting output specifications in the builder chain.","triggerScenarios":"Calling update()/specialize() with out_specs=... (or its flattened treedef) after out_specs was already specified earlier in the chain, e.g. f.out_specs(s1).out_specs(s2).","commonSituations":"Reusing a partially configured colocated function object and adding output specs again; copy-paste of configuration blocks that both set out_specs.","solutions":["Delete the redundant out_specs argument from the later call","Create a new base specialization if you need different output specs","Check whether a decorator/wrapper already applied out_specs before your call"],"exampleFix":"# before\nspec = f.update(out_specs=s1).update(out_specs=s2)  # ValueError\n# after\nspec_a = f.update(out_specs=s1)\nspec_b = f.update(out_specs=s2)","handlingStrategy":"validation","validationCode":"def set_out_specs_once(f, out_specs):\n    if f.in_specs_leaves is not None and f.out_specs_treedef is not None:\n        return f  # already fully specified\n    return f.update(out_specs=out_specs)","typeGuard":"def out_specs_set(specialization) -> bool:\n    return getattr(specialization, 'out_specs_treedef', None) is not None","tryCatchPattern":"try:\n    f2 = f.update(out_specs=s)\nexcept ValueError as e:\n    if 'out_specs already specified' in str(e):\n        pass  # keep existing spec\n    else:\n        raise","preventionTips":["Centralize out_specs assignment in one place","Branch to a new base specialization for alternate output specs","Log which component sets each spec slot once"],"tags":["jax","colocated-python","api-misuse","configuration"],"backgroundTag":"duplicate-option-specification","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}