kyutai-labs / moshi

Apache License 2.0
6.69k stars 507 forks source link

M2 Pro Mac MLX installs, model loads, command line works, web version does not. #75

Closed abhinandanshahdev closed 1 month ago

abhinandanshahdev commented 1 month ago

Due diligence

Topic

The MLX implementation

Question

It shows microphone bars jumping up and down, no command line errors, just no audio out.

[Info] listening to http://localhost:8998 [Info] opening browser at http://localhost:8998 [Info] accepted connection [Info] connection closed [Info] done with connection [Info] accepted connection [Info] connection closed

kunci115 commented 1 month ago

same experience in macbook air m3

Gitterman69 commented 1 month ago

Those steps worked for me on M1 Pro (16gb)

Prerequisites

Step 1: Set Up the Environment

  1. Open Terminal on your Mac.

  2. Create a new directory for the project:

    mkdir ~/moshi_mmx
    cd ~/moshi_mmx
  3. Create a Python virtual environment:

    python3.12 -m venv .venv
  4. Activate the virtual environment:

    source .venv/bin/activate

Step 2: Clone the Repository

  1. Clone the Moshi repository:

    git clone https://github.com/kyutai-labs/moshi.git
  2. Navigate to the moshi_mlx directory:

    cd moshi/moshi_mlx

Step 3: Install the Package

Install the package in editable mode:

pip install -e .

Step 4: Create the AppleScript Launcher

  1. Open "Script Editor" on your Mac (Applications > Utilities > Script Editor).

  2. Copy and paste the following AppleScript code:

    on run
       set modelChoice to button returned of (display dialog "Choose a model:" buttons {"8-bit Model", "4-bit Model", "BF16 Model"} default button 1)
    
       set modelParams to ""
       if modelChoice is "8-bit Model" then
           set modelParams to "-q 8 --hf-repo kyutai/moshika-mlx-q8"
       else if modelChoice is "4-bit Model" then
           set modelParams to "-q 4 --hf-repo kyutai/moshika-mlx-q4"
       else
           set modelParams to "--hf-repo kyutai/moshiko-mlx-bf16"
       end if
    
       tell application "Terminal"
           activate
           set currentTab to do script "cd ~/moshi_mmx && source .venv/bin/activate && python -m moshi_mlx.local_web " & modelParams
       end tell
    
       -- Wait for the server to start (adjust the delay if needed)
       delay 5
    
       -- Open Safari and navigate to the local web interface
       tell application "Safari"
           activate
           open location "http://localhost:8998"
       end tell
    end run
  3. Save the script:

    • Click on File > Save in the menu bar.
    • Choose a name (e.g., "Launch Moshi MLX")
    • Select a location (e.g., your Desktop for easy access)
    • For "File Format", choose "Application"
    • Check "Stay open after run handler"
    • Click "Save"

Step 5: Running the Application

  1. Double-click the AppleScript application you created.
  2. Choose the model you want to use from the dialog box.
  3. The script will:
    • Open Terminal
    • Activate the virtual environment
    • Start the Moshi MLX web interface
    • Open Safari and navigate to the application

The web interface will be available at http://localhost:8998.

Troubleshooting

Closing the Application

To stop the application, close the Terminal window that was opened by the script.

Enjoy using Moshi MLX!

Gitterman69 commented 1 month ago

Quick mention: bf16 doesnt work on my 16gb ram machine... i guess its just not enough ram...

LaurentMazare commented 1 month ago

Right, moshi-mlx with a 16GB machine would be a bit tight as the weights alone are 15.4GB. Hopefully the q8 version should have an almost similar quality.

Gitterman69 commented 1 month ago

Mosshi feels unhinged and i love it haha

abhinandanshahdev commented 1 month ago

have you gotten APIs to work with it? say hosting a conversational AI server locally on a M2 / M1 mac? Talking to the model is fun, but Id love to do a serious use case. Thanks for the help!

Gitterman69 commented 1 month ago

actually im facing the problem that after about 2 minutes i reach this point and the server/inference webui crashes in console...

..... ror in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 error in encoder thread narrow invalid args start + len > dim_len: [4096, 32], dim: 0, start: 4096, len:2 [Info] connection closed [Info] done with connection

LaurentMazare commented 1 month ago

This last issue is likely reaching out the maximum conversation time, see #51 .

LaurentMazare commented 1 month ago

Closing as it's hopefully all good now, feel free to re-open/create a new one if you still encounter some issues.