From 8e649be4d0fa46fae184d10377783087286639da Mon Sep 17 00:00:00 2001 From: Angelos Katharopoulos Date: Thu, 16 Apr 2026 01:23:35 -0700 Subject: [PATCH] Fix jaccl init bug (#3418) --- mlx/distributed/jaccl/lib/jaccl/jaccl.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mlx/distributed/jaccl/lib/jaccl/jaccl.cpp b/mlx/distributed/jaccl/lib/jaccl/jaccl.cpp index b7b68578..42d665ed 100644 --- a/mlx/distributed/jaccl/lib/jaccl/jaccl.cpp +++ b/mlx/distributed/jaccl/lib/jaccl/jaccl.cpp @@ -190,13 +190,16 @@ bool is_available() { std::shared_ptr init(bool strict /* = false */) { auto cfg = Config::from_env(); - if (!cfg.has_value() && strict) { - std::ostringstream msg; - msg << "[jaccl] You need to provide via environment variables a rank " - << "(JACCL_RANK/MLX_RANK), a device file (JACCL_IBV_DEVICES/" - << "MLX_IBV_DEVICES) and a coordinator ip/port (JACCL_COORDINATOR/" - << "MLX_JACCL_COORDINATOR)."; - throw std::runtime_error(msg.str()); + if (!cfg.has_value()) { + if (strict) { + std::ostringstream msg; + msg << "[jaccl] You need to provide via environment variables a rank " + << "(JACCL_RANK/MLX_RANK), a device file (JACCL_IBV_DEVICES/" + << "MLX_IBV_DEVICES) and a coordinator ip/port (JACCL_COORDINATOR/" + << "MLX_JACCL_COORDINATOR)."; + throw std::runtime_error(msg.str()); + } + return nullptr; } return init(*cfg, strict);