Skip to content

fix(import): strip file:// scheme from model path for local imports#10599

Open
Dennisadira wants to merge 1 commit into
mudler:masterfrom
Dennisadira:fix/import-local-file-uri-model-path-7461
Open

fix(import): strip file:// scheme from model path for local imports#10599
Dennisadira wants to merge 1 commit into
mudler:masterfrom
Dennisadira:fix/import-local-file-uri-model-path-7461

Conversation

@Dennisadira

Copy link
Copy Markdown
Contributor

What

Fixes #7461.

Importing a model from a local directory (a HuggingFace checkout, or an LM Studio store) via a file:// URI produced a config whose model: field kept the scheme verbatim:

backend: mlx
parameters:
  model: file:///Users/u/.lmstudio/models/mlx-community/Qwen3-Coder-30B-A3B-Instruct-4bit

The model imported fine, but loading failed because the mlx and vllm backends treat model: as a HuggingFace repo id or local path and reject the file:// form:

Error loading MLX model: Repo id must be in the form 'repo_name' or 'namespace/repo_name':
'file:///Users/.../Qwen3-Coder-30B-A3B-Instruct-4bit'. Use repo_type argument if needed.

Both mlx and vllm were reported (vllm in the issue comments).

Fix

  • Add a shared LocalModelPath helper (core/gallery/importers/helpers.go) that reduces a file:// URI to the bare filesystem path it points at, and leaves HuggingFace/HTTP URIs untouched.
  • Route the importers that pass details.URI straight into the model: field for from_pretrained-style loading through it: mlx, vllm, transformers, diffusers (the latter two share the identical pattern, so fixing them here heads off the same report for those backends).

Absolute (file:///abs) and relative (file://rel) local URIs both normalize correctly; remote URIs are unchanged, so the existing remote-load path and its tests are untouched.

Tests

  • Direct unit coverage for LocalModelPath (absolute, relative, HF/HTTP passthrough).
  • End-to-end file:// import specs for the mlx and vllm importers asserting the emitted model: no longer carries the scheme.

All importer specs pass; go vet and gofmt clean.

🤖 Generated with Claude Code

Importing a model from a local directory (e.g. a HuggingFace checkout or an
LM Studio store) via a file:// URI produced a config whose model field kept
the scheme verbatim, e.g. model: file:///Users/u/.../Qwen3-4bit. The mlx and
vllm backends treat that field as a HuggingFace repo id or local path and
reject the file:// form with "Repo id must be in the form 'repo_name' or
'namespace/repo_name'", so the model imported fine but failed to load (issue
mudler#7461).

Add a shared LocalModelPath helper that reduces a file:// URI to the bare
filesystem path it points at and leaves HuggingFace/HTTP URIs untouched, and
route the mlx, vllm, transformers and diffusers importers (all of which pass
details.URI straight into the model field for from_pretrained-style loading)
through it.

Cover the helper directly plus end-to-end file:// import specs for the mlx and
vllm importers.

Assisted-by: Claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Adira Denis Muhando <dennisadira@gmail.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.

Using MLX model imported from filesystem fails due to repo_type

1 participant