{"record":{"id":"0ecf71846d59c7cc","repo":"xai-org/x-algorithm","slug":"compilation-does-not-support-serialization","errorCode":null,"errorMessage":"Compilation does not support serialization","messagePattern":"Compilation does not support serialization","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/utils/aot.py","lineNumber":191,"sourceCode":"                unloaded_executable.output_shardings,\n                partially_serialized.out_shardings_mem_kinds,\n            )\n        ]\n        unloaded_executable.output_shardings = restored_out_shardings\n\n    return jax.stages.Compiled(\n        unloaded_executable.load(),\n        [],\n        lowered.args_info,\n        lowered.out_tree,\n        no_kwargs=partially_serialized.no_kwargs,\n    )\n\n\ndef partially_serialize(compiled: Compiled, execution_devices: Sequence[xc.Device]):\n    unloaded_exec = getattr(compiled._executable, \"_unloaded_executable\", None)\n    if unloaded_exec is None:\n        raise ValueError(\"Compilation does not support serialization\")\n\n    in_shardings_mem_kinds = [s.memory_kind for s in unloaded_exec.input_shardings]\n    out_shardings_mem_kinds = [s.memory_kind for s in unloaded_exec.output_shardings]\n\n    compile_options = getattr(unloaded_exec, \"compile_options\", None)\n    serialized_compile_options = None\n    if compile_options is not None:\n        serialized_compile_options = compile_options.SerializeAsString()\n\n    with io.BytesIO() as file:\n        _JaxPjrtPickler(file, execution_devices).dump(unloaded_exec)\n        return PartiallySerialized(\n            file.getvalue(),\n            in_shardings_mem_kinds,\n            out_shardings_mem_kinds,\n            compiled._no_kwargs,\n            serialized_compile_options,\n        )","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/utils/aot.py#L173-L209","documentation":"partially_serialize relies on a private _unloaded_executable attribute on the Compiled object, which only exists for executables produced by the XLA AOT path that supports serialization. If the Compiled object came from an ordinary jax jit compile (or a jaxlib version without that attribute), serialization is unsupported.","triggerScenarios":"Calling partially_serialize on a Compiled object obtained from standard jax.jit(...).lower(...).compile() rather than the repo's AOT compile path, or after the executable was already fully loaded in a way that dropped the unloaded handle.","commonSituations":"Mixing normal jit compilation with the AOT caching utilities; upgrading jaxlib so the private _unloaded_executable attribute disappears; serializing a compiled function obtained from a checkpoint restored via a different code path.","solutions":["Route compilation through the repo's AOT compile helper (_compile_or_load) so the executable retains serialization support","Pin/verify the jaxlib version this code was developed against","Skip caching (pass no aot_cache_dir) when the executable is not AOT-produced"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"from jax._src import xla_extension as xc\nexe = compiled._executable\nif getattr(exe, '_unloaded_executable', None) is None:\n    skip_caching = True  # not serializable","typeGuard":"def is_serializable(compiled) -> bool:\n    return getattr(getattr(compiled, '_executable', None), '_unloaded_executable', None) is not None","tryCatchPattern":"try:\n    blob = partially_serialize(compiled, devices)\nexcept ValueError:\n    logger.warning('skipping AOT cache write; not serializable')","preventionTips":["Always compile through the repo's AOT helper, not raw jit().compile()","Pin jaxlib version; private attributes like _unloaded_executable are brittle","Treat serialization as optional: wrap cache writes so failure degrades to no-op"],"tags":["jax","aot","serialization","version-compat"],"backgroundTag":"unsupported-serialization","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}