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

Adding support for patching #296

Merged
merged 10 commits into from
May 30, 2023
Merged

Adding support for patching #296

merged 10 commits into from
May 30, 2023

Conversation

aspctu
Copy link
Collaborator

@aspctu aspctu commented May 22, 2023

Overview

This PR adds support to Truss to apply monkeypatches to various libs. It also adds a new field in the config enable_patches (defaults to True) which enables/disables this behavior.

This PR also includes 2 patches:

  1. Huggingface patch to parallelize model downloads
  2. Whisper patch to make Whisper downloads b10cp compatible

Testing

I tested the following flows

  1. Local server flow with the flag enabled / disabled
  2. Docker image flow with the flag enabled (this requires building a new base image, instructions below).

To test the docker flow, following the steps below:

  1. You'll need to create a new base image using the helper script in bin/generate_base_images.py. To conserve space on your device (this script can create many images at once), you can run the following command to produce a non-GPU, non-live reload, serving image:
python bin/generate_base_images.py --version-tag 5 --job-type server --use-gpu n --live-reload n --python-version "3.9" 
  1. Once you have this image, you'll create an iPython shell and run the following commands
import truss
tr = truss.load("path to truss with huggingface / whisper model to test patches")
tr.set_base_image("baseten/truss-server-base:3.9-5")

tr.docker_predict({"prompt" : "man on moon"})

@aspctu aspctu marked this pull request as ready for review May 23, 2023 20:16
truss/contexts/local_loader/load_model_local.py Outdated Show resolved Hide resolved
truss/templates/server/common/patches.py Outdated Show resolved Hide resolved
truss/templates/server/common/patches.py Outdated Show resolved Hide resolved
truss/truss_config.py Outdated Show resolved Hide resolved
@pankajroark
Copy link
Collaborator

Would be great to have at least some unit tests for the patches.

@bolasim bolasim requested a review from pankajroark May 30, 2023 21:44
@bolasim
Copy link
Collaborator

bolasim commented May 30, 2023

@ujjwal @pankajroark I addressed all comments with the exception of the unit tests for the specific patches. Don't want to get blocked on that for rolling this out. Let's do that in a followup.

Let me know if there is anything else that needs to get addressed here before rollout

@bolasim bolasim removed their request for review May 30, 2023 23:00
logger.info(f"{patch_name} patch applied successfully")
except Exception as e:
logger.debug(
f"{patch_name} patch could not be applied. Exception: {str(e)}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should double check that these logs don't show up. I think it will be common that not all patches would apply for a model.

@bolasim bolasim merged commit 6c0cc2a into main May 30, 2023
3 checks passed
@bolasim bolasim deleted the abuqader/add-mp-support branch May 30, 2023 23:18
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.

None yet

4 participants