mlx-audio icon indicating copy to clipboard operation
mlx-audio copied to clipboard

mlx_lm version mismatch

Open krzynio opened this issue 6 months ago • 7 comments

Hi, just letting you know that default installation is now broken, due to changes in mlx-lm 0.25 which is the newest version which installed automatically when installing from pip.

Traceback (most recent call last):
  File "/Users/krzynio/projects/outemlx/.venv/bin/mlx_audio.tts.generate", line 5, in <module>
    from mlx_audio.tts.generate import main
  File "/Users/krzynio/projects/outemlx/.venv/lib/python3.12/site-packages/mlx_audio/tts/generate.py", line 14, in <module>
    from .utils import load_model
  File "/Users/krzynio/projects/outemlx/.venv/lib/python3.12/site-packages/mlx_audio/tts/utils.py", line 15, in <module>
    from mlx_lm.utils import dequantize_model, quantize_model, save_config, save_weights
ImportError: cannot import name 'save_weights' from 'mlx_lm.utils' (/Users/krzynio/projects/outemlx/.venv/lib/python3.12/site-packages/mlx_lm/utils.py)

downgrading to 0.24.1 fixes the issue:

pip install "mlx-lm==0.24.1"

krzynio avatar Jun 03 '25 12:06 krzynio

As of 2025-06-10, it's also necessary to downgrade mlx-vlm to version 0.1.26 in order to then downgrade mlx-lm to 0.24.1 🤪

prehensile avatar Jun 10 '25 16:06 prehensile

Ran into this problem getting started. Furthermore, needs numpy 2.2 and nothing newer, so the dependency chain looks like this

pip install "mlx-vlm<=0.1.26" "mlx-lm<=0.24.1" "numpy<=2.3" "misaki>=0.8.2 ; python_version < '3.13'"

if you only use uv (what im doing lately) you also need pip

uv pip install  "mlx-vlm<=0.1.26" "mlx-lm<=0.24.1" "numpy<=2.2" "misaki>=0.8.2 ; python_version < '3.13'" pip

Cool repo, excited to try this out!

Update...

Looks like it also needs pip...

/Users/{users_folder}/.venv/bin/python3: No module named pip
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.scope, self.receive, self.send
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/middleware/cors.py", line 93, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    await self.app(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/routing.py", line 714, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/routing.py", line 734, in app
    await route.handle(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 214, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/starlette/concurrency.py", line 37, in run_in_threadpool
    return await anyio.to_thread.run_sync(func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        func, args, abandon_on_cancel=abandon_on_cancel, limiter=limiter
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 967, in run
    result = context.run(func, *args)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/mlx_audio/server.py", line 182, in tts_endpoint
    for segment in results:
                   ^^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/mlx_audio/tts/models/kokoro/kokoro.py", line 278, in generate
    pipeline = self._get_pipeline(lang_code)
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/mlx_audio/tts/models/kokoro/kokoro.py", line 262, in _get_pipeline
    self._pipelines[lang_code] = KokoroPipeline(
                                 ~~~~~~~~~~~~~~^
        model=self,
        ^^^^^^^^^^^
        repo_id=self.REPO_ID if self.repo_id is None else self.repo_id,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        lang_code=lang_code,
        ^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/mlx_audio/tts/models/kokoro/pipeline.py", line 99, in __init__
    self.g2p = en.G2P(
               ~~~~~~^
        trf=trf, british=lang_code == "b", fallback=fallback, unk=""
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/misaki/en.py", line 501, in __init__
    spacy.cli.download(name)
    ~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/spacy/cli/download.py", line 90, in download
    download_model(filename, pip_args)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/spacy/cli/download.py", line 176, in download_model
    run_command(cmd)
    ~~~~~~~~~~~^^^^^
  File "/Users/{users_folder}/.venv/lib/python3.13/site-packages/spacy/util.py", line 1046, in run_command
    sys.exit(ret.returncode)
    ~~~~~~~~^^^^^^^^^^^^^^^^
SystemExit: 1

I am now pondering the orb as intended :)

exdysa avatar Jun 13 '25 17:06 exdysa

Or just with uvx:

uvx --from mlx-audio --with pip --with mlx-lm==0.24.1 mlx_audio.tts.generate --text "Hello, world"

schniggie avatar Jun 21 '25 14:06 schniggie

same issue

madroidmaq avatar Jul 09 '25 07:07 madroidmaq

hi @Blaizzy , I found that this issue has been resolved in the commit at https://github.com/Blaizzy/mlx-audio/pull/194, but there is no new version released yet. Could you please release a new version to address this issue? Thank you.

madroidmaq avatar Jul 09 '25 07:07 madroidmaq

hi @Blaizzy , I found that this issue has been resolved in the commit at https://github.com/Blaizzy/mlx-audio/pull/194, but there is no new version released yet. Could you please release a new version to address this issue? Thank you.

So that this project can coexist and be used simultaneously with the latest mlx-lm project.

https://github.com/Blaizzy/mlx-audio/issues/191 is also the same issue https://github.com/Blaizzy/mlx-audio/issues/207 is also the same issue https://github.com/Blaizzy/mlx-audio/issues/203 is also the same issue

madroidmaq avatar Aug 04 '25 04:08 madroidmaq

This is resolved in the latest version.

drewbitt avatar Aug 22 '25 03:08 drewbitt