Skip to content

[Do not merge] Testing inference - #107

Closed
seanshi-scale wants to merge 71 commits into
masterfrom
seanshi/add-model-bundle-hosted-inference
Closed

[Do not merge] Testing inference#107
seanshi-scale wants to merge 71 commits into
masterfrom
seanshi/add-model-bundle-hosted-inference

Conversation

@seanshi-scale

@seanshi-scale seanshi-scale commented Aug 24, 2021

Copy link
Copy Markdown
Contributor

@seanshi-scale
seanshi-scale requested a review from yixu34 August 25, 2021 22:08
@seanshi-scale seanshi-scale self-assigned this Aug 25, 2021

@yixu34 yixu34 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Think it's a bit too early to say more, but looks like the skeleton is coming together 💀

Comment thread pyproject.toml Outdated
dataclasses = { version = "^0.7", python = "^3.6.1, <3.7" }
aiohttp = "^3.7.4"
nest-asyncio = "^1.5.1"
dill = "^0.3.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Btw my latest script used cloudpickle.

Comment thread pyproject.toml
mypy = "^0.812"
coverage = "^5.5"
pre-commit = "^2.12.1"
torch = "1.7.1" # Test uploading model bundles only

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure if this too was temporary, but this brings up an interesting question around whether or not we want to package a certain version of pytorch in here. Seems like we should use whatever the user has installed locally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh the reason this is in here is that I wanted to test uploading model bundles, so I used some stuff from pytorch. This is only a dependency of one test case, and is under [requirements-test]. I definitely think it would be weird/bad if nucleus-python-client (the package) had torch = 1.7.1 as a dependency.

@seanshi-scale
seanshi-scale requested a review from syandroo August 27, 2021 00:04

@yixu34 yixu34 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will do another pass tomorrow.

Comment thread nucleus/experimental/README.md Outdated
@@ -0,0 +1,36 @@
n.b. doesn't look like this readme gets copied into the sphinx docs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't we want it to?

Comment thread nucleus/experimental/README.md Outdated

# Scale Deploy

Shamelessly copied from PRFAQ :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is no shame in copy and paste 🌚

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well actually, I'd say we want a smaller blurb here for now. Here's what it looks like for Nucleus:
image

It's a bit odd to have content that sounds like a press release or marketing material in a README 🤔

Comment thread nucleus/experimental/__init__.py Outdated
"""
# Scale Deploy

Shamelessly copied from PRFAQ :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can trim this down too.

self, api_key: str, endpoint: str = HOSTED_INFERENCE_ENDPOINT
):
"""
Initializes a HostedInference Client.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we actually want to rename all this public, user-facing stuff from hosted model inference -> deploy.

Comment thread nucleus/experimental/model_endpoint.py Outdated
# Try to upload resulting predictions to nucleus

def _infer(
def infer(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd say predict is a more common name that appears in these kinds of frameworks.


Parameters:
endpoint_id: The id of the endpoint to make the request to
s3url: A url that points to a file containing model input.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For synchronous requests, I think we want to support inline payloads as well, i.e. you just send an image payload directly. This does get tricky with large payloads, though, where we'd probably want to stream the data in.

Anyway, I guess the point is that for synchronous endpoints:

  • We might not know the specifics yet for inline payloads, but:
  • We're pretty sure we will want them, which means that S3 URLs are not the only way, and should thus be Optional.

Another observation re: s3 urls is that we probably want to abstract this into a generic URI. This is because HMI can be self-hosted, in which case we'd want to support other schemes. Nucleus is able to assume S3 URLs because it's Scale-hosted.

resp = self.connection.get(route=f"task/result/{async_task_id}")
return resp["data"]

def batch_request(self, endpoint_id, s3urls: List[str]):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I made a comment on @Tianwei-She 's PR here: https://github.com/scaleapi/models/pull/2315#discussion_r784440984 - wondering if we can just get rid of this method.

Comment thread nucleus/experimental/model_endpoint.py Outdated
A higher level abstraction for a Model Endpoint.
"""

def __init__(self, endpoint_id, client):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These could use some type annotations and docstring.

@@ -0,0 +1,161 @@
# This file contains all the Core Nucleus <-> HMI integrations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A couple of thoughts:

  1. Maybe we should just rename this folder to deploy. This is just going to go into a separate release branch in the meantime anyway.
  2. Regardless of what we name this folder (where the HMI/deploy stuff lives), I'd say that the integration code should go in an actual Nucleus folder. This way, it's clear that Nucleus depends on Deploy, without an inverse dependency too. Having this integration file here means that we can't just move this folder to a separate repo later, for instance.

Comment thread temp_test_e2e.py Outdated
hmi_client = HostedInference(
api_key="live_38aa469bc8ab436d89dce6e37e8d5258"
)
img_url = "s3://scale-ml-hosted-model-inference/tmp/hosted-model-inference-outputs/c3f3b5ed-f182-4fa1-bfa5-9b2e017feb74.pkl"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably best to remove any internal URLs in here. It's not the end of the world since's temporary and not a secret.

Comment thread nucleus/deploy/model_endpoint.py Outdated
"""
raise NotImplementedError

def edit_endpoint(self):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

todo delete

@seanshi-scale
seanshi-scale force-pushed the seanshi/add-model-bundle-hosted-inference branch from 92aa45b to 2168bc4 Compare January 19, 2022 00:19
@seanshi-scale

Copy link
Copy Markdown
Contributor Author

See #203

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.

2 participants