{"record":{"id":"654be717531c0cea","repo":"xai-org/x-algorithm","slug":"unsupported-type-type-self-jitted","errorCode":null,"errorMessage":"Unsupported type: {type(self.jitted)}.","messagePattern":"Unsupported type: (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/utils/aot.py","lineNumber":677,"sourceCode":"    all_compiled = {n: _compile_or_load(n, t, metrics) for n, t in all_traced.items()}\n    return all_compiled, metrics\n\n\nclass JittedOrCompiled(Wrapped):\n    __slots__: tuple[str, ...] = (\"jitted\", \"fun_name\")\n\n    def __init__(self, jitted, name=None):\n        self.fun_name = name\n        self.jitted = jitted\n\n    def lower(self, *args, **kwargs):\n        if isinstance(self.jitted, Compiled):\n            raise ValueError(\"Cannot lower a compiled jit function.\")\n        return self.jitted.lower(*args, **kwargs)\n\n    def trace(self, *args, **kwargs) -> Traced:\n        if isinstance(self.jitted, (Traced, Compiled)):\n            raise TypeError(f\"Unsupported type: {type(self.jitted)}.\")\n        return self.jitted.trace(*args, **kwargs)\n\n    def name(self):\n        if self.fun_name is not None:\n            return self.fun_name\n        if isinstance(self.jitted, Wrapped):\n            return getattr(self.jitted._fun, \"__name__\", str(self.jitted._fun))\n        raise TypeError(f\"Unsupported type: {type(self.jitted)}.\")\n\n    def __call__(self, *args, **kwargs):\n        return self.jitted(*args, **kwargs)\n","sourceCodeStart":659,"sourceCodeEnd":689,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/utils/aot.py#L659-L689","documentation":"Wrapped.trace() only works on a raw (untraced, uncompiled) jit function; passing an already Traced or Compiled object raises TypeError since tracing an abstract stage twice is not supported.","triggerScenarios":"Calling trace() on a Wrapped whose jitted field is a Traced (from a previous trace call) or Compiled (from cache load) object.","commonSituations":"Re-running a trace/compile pipeline on cached results; loops that call trace multiple times over the same wrapper.","solutions":["Create a fresh Wrapped from the original jit function before tracing again","Skip trace() when isinstance(wrapped.jitted, (Traced, Compiled)) and use the artifact directly"],"exampleFix":"# before\ntraced = wrapped.trace(*args)  # already Traced/Compiled\n# after\nif isinstance(wrapped.jitted, (Traced, Compiled)):\n    traced = wrapped.jitted  # reuse\nelse:\n    traced = wrapped.trace(*args)","handlingStrategy":"type-guard","validationCode":"from phoenix.xrex.utils.aot import Traced, Compiled\nif isinstance(wrapped.jitted, (Traced, Compiled)):\n    traced = wrapped.jitted  # reuse\nelse:\n    traced = wrapped.trace(*args)","typeGuard":"def is_traceable(wrapped) -> bool:\n    from phoenix.xrex.utils.aot import Traced, Compiled\n    return not isinstance(wrapped.jitted, (Traced, Compiled))","tryCatchPattern":null,"preventionTips":["Trace once per function; cache the Traced artifact","Guard pipeline entry points with isinstance checks","Write pipeline code as explicit stages with type checks between them"],"tags":["jax","type-validation","aot"],"backgroundTag":"invalid-state-transition","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}