Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Swarm Mode #344

Closed
wants to merge 28 commits into from

Conversation

filopedraz
Copy link
Contributor

Description

Added support for Swarm Mode which starts the necessary processes in order to be part of the Petals Swarm. The User can Enable the mode from Settings. Tauri will spawn a thread that installs the dependencies and runs the python process.

The PR contains all the building blocks in order to implement the complete POC functionality.

Limitations

  • UI/UX must be drastically improved. No CSS changes have been made.
  • It currently works only if the User has Python installed on its machine.

@tiero @casperdcl @sekulicd @Janaka-Steph please have a look.

@what-the-diff
Copy link

what-the-diff bot commented Sep 1, 2023

PR Summary

  • Introduction of a checking mechanism for Python
    A new functionality is added to verify that Python is correctly installed on the machine.

  • Enhanced support for Swarm Mode
    New functions have been introduced to allow for better handling of Docker's Swarm Mode. Specifically, these functions enable us to check the running status of Swarm Mode, start it, and stop it when needed.

  • Addition of SwarmMode Component
    A new component named SwarmMode is created to incorporate Docker's Swarm Mode features into our application UI. This component is added as part of our Settings module, empowering users with more operational flexibility.

  • Utilities for Swarm Mode
    Additional utility functions for handling Docker Swarm Mode are implemented. These help us to verify the operational status of Swarm Mode, stop it, or start it based on user input or application requirements.

src-tauri/src/main.rs Outdated Show resolved Hide resolved
println!("🚀 Starting the Swarm...");

let _ = Command::new("/usr/bin/python3")
.args(&["-m", "pip", "install", "git+https://github.com/bigscience-workshop/petals",])
Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially fallback to pip install --user before giving up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally, we should install python, conda, create a conda env, and then install, but I want your opinion on that on how to make this installation super smooth.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest:

  1. try to find mamba on $PATH
  2. try to find conda on $PATH
  3. try to find python3 on $PATH
  4. install https://github.com/conda-forge/miniforge#mambaforge

for (1), (2) and (4): create/activate an env called prem before installing

What' the Tauri problem with $PATH?

src-tauri/src/main.rs Show resolved Hide resolved
src-tauri/src/main.rs Show resolved Hide resolved
Copy link
Contributor

@Janaka-Steph Janaka-Steph left a comment

Choose a reason for hiding this comment

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

LGTM

@filopedraz
Copy link
Contributor Author

@casperdcl @sekulicd @Janaka-Steph @tiero instead of passing "--public_name", "prem-app" we should pass the User username/identifier (like a nostr pubkey) :)

@casperdcl
Copy link
Contributor

could just use current username

@filopedraz
Copy link
Contributor Author

Good point. I ll apply the changes you suggested above.

Copy link
Contributor

@casperdcl casperdcl left a comment

Choose a reason for hiding this comment

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

lgtm :shipit: but maybe open follow-up issues for:

@filopedraz
Copy link
Contributor Author

I ll address the remaining points in this PR soon. I want first the new services to be working and then I ll move on with this. :)

@filopedraz
Copy link
Contributor Author

Missing

  • Give the User the possibility to decide which model to contribute to.
  • Check if the User can run Swarm mode (only available for Mac users), otherwise don't enable the functionality.
  • Give the User the possibility to decide how many blocks to contribute giving some tooltips in terms of how much memory is required per block.

@casperdcl casperdcl added the enhancement New feature or request label Oct 9, 2023
@nsosio
Copy link
Contributor

nsosio commented Oct 12, 2023

  • Give the User the possibility to decide which model to contribute to.
  • Check if the User can run Swarm mode (only available for Mac users), otherwise don't enable the functionality.
  • Give the User the possibility to decide how many blocks to contribute giving some tooltips in terms of how much memory is required per block.

@casperdcl can you check it? @Janaka-Steph can you enhance the style of swarm settings?

@nsosio
Copy link
Contributor

nsosio commented Oct 16, 2023

@filopedraz, @tiero should we update it as user_name@premAI or keep it as user_name? Where user name is what specified by the user (with default prem-app)

pip install -r $REQUIREMENTS_FILE_PATH

# Package the Python script
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
Copy link
Contributor

@tiero tiero Oct 16, 2023

Choose a reason for hiding this comment

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

This will not work on all architectures, please build one for each architecture

Suggested change
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-aarch64-apple-darwin

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will not be enough. If is not possible to make an universal binary with single name, we must package both in the App

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

If we manage to make an universal binary, we should them call it petals-universal-apple-darwin otherwsie when you will be up to compile

       Error failed to bundle project: Failed to copy external binaries: Failed to copy external binaries: path matching bin/python/petals-universal-apple-darwin not found.: path matching bin/python/petals-universal-apple-darwin not found.

Copy link
Contributor

Choose a reason for hiding this comment

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

if not possible to have universal binary, we must also change how we build the desktop app and file naming (splitting Apple SIlicon and Apple Intel) on website, documentations etc..

Copy link
Contributor

@casperdcl casperdcl Oct 16, 2023

Choose a reason for hiding this comment

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

universal bin may or may not be possible1:

Suggested change
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean -n petals-x86_64-apple-darwin
pyinstaller --onefile $PYTHON_SCRIPT_PATH --distpath $DIST_PATH --clean --target-arch universal2 -n petals-universal-apple-darwin

plus tauri build --target universal-apple-darwin23

Note, however, that this increases your bundle size significantly4

Footnotes

  1. https://pyinstaller.org/en/stable/feature-notes.html#macos-multi-arch-support

  2. https://tauri.app/v1/api/cli/#build

  3. https://github.com/premAI-io/prem-app/blob/a7df7ed5c915dd0fcd79525cb78314a3e7b19faf/.github/workflows/on-tag.yaml#L97

  4. https://tauri.app/v1/guides/building/macos/#binary-targets

package.json Outdated Show resolved Hide resolved
@tiero
Copy link
Contributor

tiero commented Oct 16, 2023

@filopedraz, @tiero should we update it as user_name@premAI or keep it as user_name? Where user name is what specified by the user (with default prem-app)

We should start with a default name taken from user-space ie. $whoami@premAI, and not sure how much worth is to allow user to change it 🤔

@filopedraz
Copy link
Contributor Author

@tiero it will be a public name. User should be able to provide what they want.

@tiero
Copy link
Contributor

tiero commented Oct 16, 2023

I did little tweaks to UI and compiled also aarch64 version to test for Apple SIlicon, please @nsosio pull before commiting more work

@tiero
Copy link
Contributor

tiero commented Oct 16, 2023

@tiero it will be a public name. User should be able to provide what they want.

Ok I will reintroduce the Input, but once they start the swarm

@tiero
Copy link
Contributor

tiero commented Oct 16, 2023

Starting the Swarm on any model crashes once click on Start
https://www.loom.com/share/43213eaf03b14a8a840488cf91150a1b

@nsosio
Copy link
Contributor

nsosio commented Oct 17, 2023

  • enabled swarm-mode only for aarch64
  • petals sidecar only for aarch64
  • added get_username Tauri command retrieving whoami
  • moved script for petals binary to scripts

CC @filopedraz @casperdcl @tiero

@filopedraz
Copy link
Contributor Author

@nsosio LGTM. @tiero can you update the UI accordingly?

@tiero
Copy link
Contributor

tiero commented Oct 18, 2023

Currently does not work on my Mac M1, investigating. @filopedraz If you have time to test on your device let me know if you experience the same.

@filopedraz
Copy link
Contributor Author

Just tested, to me works.

@casperdcl
Copy link
Contributor

casperdcl commented Oct 18, 2023

@Janaka-Steph
Copy link
Contributor

It would be nice to move the Petals rust code into its own file rather than in main.rs

@casperdcl
Copy link
Contributor

follow-up: apparently tauri build --target universal-apple-darwin wants ALL THREE of:

  • petals-aarch64-apple-darwin
  • petals-x86_64-apple-darwin
  • petals-universal-apple-darwin

Just one or two of the above isn't enough.

@casperdcl
Copy link
Contributor

casperdcl commented Oct 19, 2023

CI-built *.dmg + binaries if anyone wants to test things :)

@tiero tiero closed this Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants