Skip to content

Give each xdist worker its own mlx compile cache as a stopgap - #90

Merged
hertschuh merged 2 commits into
mainfrom
jit-cache-per-worker
Oct 8, 2026
Merged

hertschuh merged 2 commits into
mainfrom
jit-cache-per-worker

Conversation

@MarcosAsh

Copy link
Copy Markdown
Collaborator

This is a temporary stopgap, delete it once CI runs an mlx release that includes ml-explore/mlx#4638.

The linux leg keeps failing on "Could not load C++ shared library /tmp/mlx/0.32.3/cpu/lib...so: file too short", on a different random test each time (6 of the last 8 linux runs, including #85 and #86 three times in a row). mlx 0.32.3 shares its CPU compile cache across processes and treats "the .so exists" as done, so one xdist worker can load a kernel another worker is still linking. mlx#4638 fixes that properly with a temp file plus rename, it's merged but not in a release yet (latest is still 0.32.3).

Until then this adds a small pytest plugin, loaded with -p only on the linux xdist step, that points each worker's TMPDIR at its own folder. mlx builds the cache path from TMPDIR on every compile, so no two workers ever share a kernel file. Only the linux test step uses it, the sklearn step and the macOS leg run a single process. The plugin lives in .github/pytest/ so the PYTHONPATH entry doesn't also make .github/workflows/config importable. Two full local runs with it had no flakes and every kernel in a per-worker folder, while runs without it flaked once or twice each.

We don't pin mlx to the fixed commit because that means building mlx from source on every run, and the requirement is mlx[cpu]>=0.32 with no upper pin, so CI picks up the fixed release by itself. Removing this plugin and the -p flag is the only follow up.

@hertschuh hertschuh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, good catch!

@hertschuh
hertschuh merged commit bb82ef8 into main Oct 8, 2026
10 checks passed
@hertschuh
hertschuh deleted the jit-cache-per-worker branch October 8, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants