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

[Core] Add Downloader implementation for runtime #96

Merged
merged 12 commits into from
Aug 29, 2024

Conversation

brosoul
Copy link
Collaborator

@brosoul brosoul commented Aug 26, 2024

Pull Request Description

Support download model file from S3, huggingFace and TOS

Related Issues

Resolves: #81

Important: Before submitting, please complete the description above and review the checklist below.


Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

@Jeffwan Jeffwan changed the title [Core]add Downloader implement for runtime [Core] Add Downloader implement for runtime Aug 26, 2024
@Jeffwan Jeffwan changed the title [Core] Add Downloader implement for runtime [Core] Add Downloader implementation for runtime Aug 26, 2024
@@ -131,9 +134,20 @@ def download_model(self, local_path: Optional[str]):
if self._is_directory():
self.download_directory(model_path)
else:
self.download(self.model_uri, model_path)
self.download(
filename=self.model_uri,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel the naming is a little bit weird. file should be subset of the model_uri.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I also feel a bit awkward here. For TOS, bucket_name is in host_name of model_uri . For AWS, bucket_name is in the path of the model_uri. It is difficult to distinguish which subset of the model_uri is obtained in the base class. Or we should rename filename

Copy link
Collaborator

Choose a reason for hiding this comment

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

you mean TOS uri is like bucket-name-tos-beijing/path and S3 is s3://bucket-name/path? for the internal methods, I suggest to have two variables like bucket and path so we can construct the path as needed. but for the user's input. they probably give the URI directly, right? is there a way to split the string into bucket and path?

)

# create completed file to indicate download completed
completed_file = model_path.joinpath(".completed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

where do you use it for completion check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What I want is to first execute an entrypoint script in the main container to check if the file .completed exists in the model directory, and then execute the subsequent model startup logic. This can ensure the order of download and startup.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's say we use the vLLM, in that case, we need to change the entrypoint or add a wrapper?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's like using script content like the following as an entrypoint

#!/bin/bash

MODEL_PATH="/path/to/model"

while true; do
    if [ -e "$FILEPATH/.completed" ]; then
        echo "File exists. Continuing execution..."
        break
    else
        sleep 1
    fi
done

python3 -m vllm.entrypoints.openai.api_server $@ --model $MODEL_PATH

)
self.bucket_name = bucket_name
self.bucket_path = bucket_path
self.client = tos.TosClientV2(ak, sk, endpoint, region)
Copy link
Collaborator

Choose a reason for hiding this comment

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

just curious, tos claims they are s3 api compatible. can we use s3 sdk instead? do you know the best practice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel like it's difficult to find documents related to TOS, so I'll try to find them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

no worries, this should be low priority. I am just curious about TOS's maturity

def download(
self,
local_path: Path,
bucket_path: str,
Copy link
Collaborator

Choose a reason for hiding this comment

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

em. this is ok at this moment. I feel it's a little bit weird to have both of them. we can discuss it in future issues/prs.

@Jeffwan
Copy link
Collaborator

Jeffwan commented Aug 29, 2024

Looks good to me and feel free to merge it

@Jeffwan Jeffwan merged commit 1f5a273 into main Aug 29, 2024
2 checks passed
@Jeffwan Jeffwan deleted the linhui/runtime-download branch August 29, 2024 03:15
@Jeffwan
Copy link
Collaborator

Jeffwan commented Aug 29, 2024

I will merge it

gangmuk pushed a commit that referenced this pull request Jan 25, 2025
* feat: add huggingface downloader implement

* feat: add tos downloader implement

* fix: fix download single file from tos

* feat: add s3 downloader implement

* feat: add progress bar into s3 and tos downloader

* ci: add ruff format check

* style: remove unused import

* fix: huggingface downloader init model name

* refact: refact tos model uri use tos protocol

* refact: use bucket path

* style: fix code style

* refact: remove .complete file
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.

[RFC] Build AI Runtime as different Inference engines adapters
2 participants