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

Update DJLModel class for latest container releases #4754

Merged
merged 5 commits into from
Jun 25, 2024

Conversation

siddvenk
Copy link
Contributor

@siddvenk siddvenk commented Jun 21, 2024

Issue #, if available:

Description of changes:

The DJLModel class has not been updated in multiple container releases, and as such it's functionality is completely broken.

This change updates the DJLModel class for the latest DJL container releases. Furthermore, it simplifies the interface and functionality so that it is more future-proofed.

Specifically:

  • Removes the subclasses of DJLModel. All functionality and auto-configuration behavior is handled partly by the DJLModel class, but mostly by the container at runtime
  • Removes the configuration file serving.properties requirement in favor of environment variables. A serving.properties file can still be provided and used, but the DJLModel class will not read/parse this configuration.
  • Updates the interactions with ModelBuilder interface to reflect the changes here

Testing done:

  • Updated unit tests
  • Used DJLModel to deploy SM endpoints in dev account

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@siddvenk siddvenk changed the title simplify and refactor djl model for latest container releases [WIP] simplify and refactor djl model for latest container releases Jun 21, 2024
@siddvenk siddvenk marked this pull request as ready for review June 24, 2024 01:39
@siddvenk siddvenk requested a review from a team as a code owner June 24, 2024 01:39
@siddvenk siddvenk changed the title [WIP] simplify and refactor djl model for latest container releases Update DJLModel class for latest container releases Jun 24, 2024
doc/frameworks/djl/using_djl.rst Outdated Show resolved Hide resolved
doc/frameworks/djl/using_djl.rst Show resolved Hide resolved
fastertransformer_predictor = fastertransformer_model.deploy("ml.g5.12xlarge",
initial_instance_count=1)

Regardless of which way you choose to create your model, a ``Predictor`` object is returned. You can use this ``Predictor``
Copy link
Member

Choose a reason for hiding this comment

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

should we still leave in some docs explaining that a Predictor is returned on deploy()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea i can do that, I think i deleted this line by mistake!

Each ``Predictor`` provides a ``predict`` method, which can do inference with json data, numpy arrays, or Python lists.
Inference data are serialized and sent to the DJL Serving model server by an ``InvokeEndpoint`` SageMaker operation. The
``predict`` method returns the result of inference against your model.

By default, the inference data is serialized to a json string, and the inference result is a Python dictionary.

Model Directory Structure
Copy link
Member

Choose a reason for hiding this comment

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

is all of this removed information being moved to the LMI docs on the AWS documentation site?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we have this all on our LMI docs site.

We are not publishing on AWS docs anymore, but have aligned on all our docs living here https://docs.djl.ai/docs/serving/serving/docs/lmi/index.html. The model directory structure specifically is here https://docs.djl.ai/docs/serving/serving/docs/lmi/deployment_guide/model-artifacts.html

def _set_serve_properties(hf_model_config: dict, schema_builder: SchemaBuilder) -> tuple:
def _get_default_djl_configurations(
model_id: str, hf_model_config: dict, schema_builder: SchemaBuilder
) -> tuple:
Copy link
Member

Choose a reason for hiding this comment

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

nit: tuple[dict, int]

logger.info("Using provided engine %s", self.engine)
return self.engine

if self.task is not None:
Copy link
Member

Choose a reason for hiding this comment

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

nit: unnecessary, None == "text-embedding" is not an error

@siddvenk
Copy link
Contributor Author

@akrishna1995 - can you review this PR? I have two approvals, one from my team (owning DJLModel class), and one from the team that owns the ModelBuilder class.

@mufaddal-rohawala mufaddal-rohawala merged commit 327b5d9 into aws:master Jun 25, 2024
11 checks passed
@siddvenk siddvenk deleted the djl branch June 25, 2024 20:41
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