{"record":{"id":"06f0a6413883603c","repo":"jax-ml/jax","slug":"init-is-not-implemented","errorCode":null,"errorMessage":"Init is not implemented","messagePattern":"Init is not implemented","errorType":"exception","errorClass":"std::runtime_error","httpStatus":null,"severity":"error","filePath":"jaxlib/jax.cc","lineNumber":377,"sourceCode":"             absl::StatusOr<std::string> serialized = layout.Serialize();\n             xla::ThrowIfError(serialized.status());\n             return nb::make_tuple(\n                 nb::bytes(serialized->data(), serialized->size()));\n           })\n      .def(\"__setstate__\", [](xla::PjRtLayout* self, nb::tuple t) {\n        nb::bytes serialized = nb::cast<nb::bytes>(t[0]);\n        absl::StatusOr<std::shared_ptr<const xla::PjRtLayout>> layout =\n            xla::PjRtLayout::Deserialize(\n                std::string_view(serialized.c_str(), serialized.size()));\n        xla::ThrowIfError(layout.status());\n        new (self) xla::PjRtLayout((*layout)->xla_layout());\n      });\n\n  nb::class_<xla::cpu::CpuCollectives> cpu_collectives(m, \"CpuCollectives\");\n  cpu_collectives\n      .def(\"Init\",\n           [](xla::cpu::CpuCollectives*) {\n             throw std::runtime_error(\"Init is not implemented\");\n           })\n      .def(\"Finalize\", [](xla::cpu::CpuCollectives*) {\n        throw std::runtime_error(\"Finalize is not implemented\");\n      });\n\n  m.def(\n      \"make_gloo_tcp_collectives\",\n      [](std::shared_ptr<xla::DistributedRuntimeClient> distributed_client,\n\n         std::optional<std::string> hostname,\n         std::optional<std::string> interface)\n          -> std::shared_ptr<xla::cpu::CpuCollectives> {\n#if defined(__linux__)\n        std::shared_ptr<xla::KeyValueStoreInterface> kv_store = nullptr;\n        if (distributed_client != nullptr) {\n          kv_store = GetDistributedKeyValueStore(distributed_client,\n                                                 /*key_prefix=*/\"cpu:\");\n        }","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jaxlib/jax.cc#L359-L395","documentation":"The CpuCollectives Python wrapper intentionally stubs out Init because initialization happens at construction/first use of the gloo/mpi collectives object; calling Init() explicitly is an API misuse.","triggerScenarios":"Calling jaxlib CpuCollectives.Init() from Python, usually by mirroring an older or different collective API that required explicit init.","commonSituations":"Code ported from other distributed libraries (NCCL-style init/finalize lifecycle) applied to jax's CPU collectives.","solutions":["Remove the Init() call — the constructor initializes the collectives","If you need re-initialization, construct a new collectives object via make_gloo_tcp_collectives/make_mpi_collectives"],"exampleFix":"# before\ncoll = jaxlib.make_gloo_tcp_collectives(...)\ncoll.Init()\n# after\ncoll = jaxlib.make_gloo_tcp_collectives(...)","handlingStrategy":"validation","validationCode":"pass  # do not call Init(); construction initializes","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat CpuCollectives as constructor-initialized"],"tags":["jax","collectives","cpu","api-misuse"],"backgroundTag":"unsupported-api-call","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}