Skip to content

fix: rename platform.py to vllm_platform.py to avoid stdlib shadowing#185

Merged
waybarrios merged 1 commit intowaybarrios:mainfrom
dan-j-cooper:fix/platform-rename
Mar 31, 2026
Merged

fix: rename platform.py to vllm_platform.py to avoid stdlib shadowing#185
waybarrios merged 1 commit intowaybarrios:mainfrom
dan-j-cooper:fix/platform-rename

Conversation

@dan-j-cooper
Copy link
Copy Markdown
Contributor

platform.py shadows the stdlib module which causes a crash when running the server with uvicorn (which imports stdlib platform) added a prefix to resolve.

@Thump604
Copy link
Copy Markdown
Collaborator

Clean fix. Shadowing platform from stdlib is a real problem — uvicorn imports platform at the module level, and Python's import resolution picks up vllm_mlx/platform.py instead of the stdlib module when vllm-mlx is on the path. This causes a crash that's confusing to debug since the traceback points into uvicorn internals.

The rename covers all the right spots:

  • vllm_mlx/__init__.py (lazy import)
  • vllm_mlx/plugin.py (entry point string returned to vLLM)
  • tests/test_platform.py (all 5 import sites)
  • The pyproject.toml entry point goes through plugin.py:mlx_platform_plugin() which returns the string, so that's correctly handled indirectly.

One minor suggestion: you might consider keeping a thin platform.py shim that re-exports from vllm_platform.py with a deprecation warning, in case anyone has third-party code importing from vllm_mlx.platform import MLXPlatform directly. But given the project's stage, a clean break is probably fine.

+1 for merge.

Copy link
Copy Markdown
Collaborator

@Thump604 Thump604 left a comment

Choose a reason for hiding this comment

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

Straightforward fix. stdlib shadowing causes real crashes with uvicorn. +1

@waybarrios
Copy link
Copy Markdown
Owner

Reviewed the change. The rename covers all import sites correctly: init.py, plugin.py, tests, and the entry point string goes through plugin.py so pyproject.toml is handled indirectly. No missed references.

@waybarrios waybarrios merged commit 682ec4a into waybarrios:main Mar 31, 2026
janhilgard added a commit to janhilgard/vllm-mlx that referenced this pull request Apr 1, 2026
Brings in: prompt_tokens fix (waybarrios#236), ArraysCache batching (waybarrios#160),
platform rename (waybarrios#185), mlx-lm 0.31 compat (waybarrios#183, waybarrios#227),
base64 hash fix (waybarrios#206), streaming UTF-8 detokenizer (waybarrios#109),
and cleanup commits.

Conflicts resolved:
- scheduler.py: keep make_logits_processors import (fork feature)
- mllm_scheduler.py: take upstream stop-token skip in detokenizer
- models/mllm.py: keep SHA256 hash (fork fix for collision)
- utils/tokenizer.py: merge upstream error message with fork elif chain

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

3 participants