bigscience-workshop / petals

🌸 Run LLMs at home, BitTorrent-style. Fine-tuning and inference up to 10x faster than offloading
https://petals.dev
MIT License
8.89k stars 490 forks source link

ImportError: cannot import name 'AutoDistributedModelForCausalLM' from partially initialized module 'petals' (most likely due to a circular import) #542

Closed lacksfish closed 7 months ago

lacksfish commented 7 months ago

I've been trying the latest version with a very basic setup and running into issues. I'm trying to follow the basic guide

Base information:

I've tried running: $ pip3 install git+https://github.com/bigscience-workshop/petals (no errors)

But then:

$ python3 -m petals.cli.run_server petals-team/StableBeluga2
/home/username/projectname/venv/bin/python3: Error while finding module specification for 'petals.cli.run_server' (ImportError: cannot import name 'AutoDistributedModelForCausalLM' from partially initialized module 'petals' (most likely due to a circular import) (/home/username/projectname/petals.py))

Any help with this is appreciated!

poedator commented 7 months ago

@lacksfish, try these ideas for starters: 1) check that there is no directory named petals where you launch your code from. It may confuse imports. 2) uninstall petals and make sure that import petals fails with ModuleNotFoundError. Then reinstall and test.

lacksfish commented 7 months ago
  1. For a second I thought I was missing this obvious issue, but even after renaming my testing file from petals.py to petal.py I still encountered the same issue
  2. It fails with ModuleNotFoundError after uninstall, after uninstalling with the recommended install command (installing v2.2.0) it failed with the same described ImportError

My solution was this:

$ pip3 install git+https://github.com/bigscience-workshop/petals.git@main

This installs the main/master branch which did not have the circular dependency issue anymore (versioned at v2.3.0 at commit 03cbe90234ccd4e3cf749d9370f53bea2a1dcb67)

Feel free to close the issue or investigate further. From my perspective, using the main branch directly fixed this issue.

poedator commented 7 months ago

thank you for exploring this, @lacksfish. I hope that the problem stays in the past with 2.2.0.