fix(mlx): relax context-store timeout by default (#7141)

This commit is contained in:
Long Yixing 2026-07-18 04:13:19 +08:00 committed by GitHub
commit 57785f92d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -49,6 +49,11 @@ logger = get_logger(__name__)
# and spawn workers copy os.environ. setdefault so an explicit user override wins.
os.environ.setdefault("CUDA_DEVICE_ORDER", "PCI_BUS_ID")
# Studio workers can import MLX without importing unsloth first, so mirror the
# package bootstrap here. Keep an explicit user value authoritative.
if platform.system() == "Darwin" and platform.machine() == "arm64":
os.environ.setdefault("AGX_RELAX_CDM_CTXSTORE_TIMEOUT", "1")
# ========== Device Enum ==========

View file

@ -16,6 +16,11 @@ import os, importlib.util, platform
os.environ["UNSLOTH_IS_PRESENT"] = "1"
# Relax Metal's context-store timeout before MLX modules can initialize Metal.
# Keep an explicit user value authoritative.
if platform.system() == "Darwin" and platform.machine() == "arm64":
os.environ.setdefault("AGX_RELAX_CDM_CTXSTORE_TIMEOUT", "1")
# ── Windows console UTF-8 safety ─────────────────────────────────────────────
# Legacy Windows consoles (cp1252) can't encode Unsloth's emoji/box-drawing
# glyphs and crash with UnicodeEncodeError. Force stdout/stderr to UTF-8 only on