Skip to content

Addressing Apple Silicon MPS restricting and Laya Lazy loading of transformers - #4

Merged
androiddrew merged 3 commits into
mainfrom
drew/multi-worker-model-bug
Sep 25, 2026
Merged

androiddrew merged 3 commits into
mainfrom
drew/multi-worker-model-bug

Conversation

@androiddrew

Copy link
Copy Markdown
Owner

There was a startup race laya.load imports transformers lazily, and two threads doing that at once fail with cannot import name 'AutoTokenizer'. The current solution is to have laya_engine.py run the first load in the process alone, then the other copies load in parallel.

PyTorch's MPS backend shares one Metal command stream per process, so concurrent predict calls trip the driver assertion
_status < MTLCommandBufferStatusCommitted. That assertion aborts the process with no traceback. So currently we are going to try and restrict apple silicon to running only with a single worker process.

@androiddrew
androiddrew merged commit 07f1955 into main Sep 25, 2026
6 checks passed
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.

1 participant