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

Change default truss. #565

Merged
merged 6 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions truss/templates/custom/model/model.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
from typing import Any
"""
The `Model` class is an interface between the ML model that you're packaging and the model
server that you're running it on.

The main methods to implement here are:
* `load`: runs exactly once when the model server is spun up or patched and loads the
model onto the model server. Include any logic for initializing your model, such
as downloading model weights and loading the model into memory.
* `predict`: runs every time the model server is called. Include any logic for model
inference and return the model output.

See https://truss.baseten.co/quickstart for more.
"""


class Model:
def __init__(self, **kwargs) -> None:
self._data_dir = kwargs["data_dir"]
self._config = kwargs["config"]
self._secrets = kwargs["secrets"]
def __init__(self, **kwargs):
# Uncomment the following to get access
# to various parts of the Truss config.

# self._data_dir = kwargs["data_dir"]
# self._config = kwargs["config"]
# self._secrets = kwargs["secrets"]
self._model = None

def load(self):
# Load model here and assign to self._model.

Choose a reason for hiding this comment

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

I actually like the assign to self._model help text here

pass

def predict(self, model_input: Any) -> Any:
model_output = {}
# Invoke model on model_input and calculate predictions here.
model_output["predictions"] = []
return model_output
def predict(self, model_input):
# Run model inference here
return model_input
12 changes: 6 additions & 6 deletions truss/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def generate_default_config():
"requirements": [],
"resources": {
"accelerator": None,
"cpu": "500m",
"memory": "512Mi",
"cpu": "1",
"memory": "2Gi",
"use_gpu": False,
},
"secrets": {},
Expand All @@ -153,8 +153,8 @@ def test_default_config_not_crowded_end_to_end():
requirements: []
resources:
accelerator: null
cpu: 500m
memory: 512Mi
cpu: '1'
memory: 2Gi
use_gpu: false
secrets: {}
system_packages: []
Expand Down Expand Up @@ -192,8 +192,8 @@ def test_non_default_train():
updated_train = {
"resources": {
"accelerator": "A10G",
"cpu": "500m",
"memory": "512Mi",
"cpu": "1",
"memory": "2Gi",
"use_gpu": True,
},
"variables": {},
Expand Down
4 changes: 2 additions & 2 deletions truss/tests/test_truss_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@ def generate_default_config():
"requirements": [],
"resources": {
"accelerator": None,
"cpu": "500m",
"memory": "512Mi",
"cpu": "1",
"memory": "2Gi",
"use_gpu": False,
},
"secrets": {},
Expand Down
4 changes: 2 additions & 2 deletions truss/truss_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
DEFAULT_SPEC_VERSION = "2.0"
DEFAULT_PREDICT_CONCURRENCY = 1

DEFAULT_CPU = "500m"
DEFAULT_MEMORY = "512Mi"
DEFAULT_CPU = "1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changing these default will map to something that's not the supported lowest instance type (which is 1cpu, 2Gi memory minus daemonsets, which will need some buffer.

I think 750m, 1.5Gi should be safe but up to you.

Choose a reason for hiding this comment

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

Ah gotcha. We wanted to make that change because the default values weren't super intuitive (500m? 512Mi?) but we weren't sure if Baseten required the buffer.

We should work on a way to make specifying resources more intuitive but it doesn't have to block this release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changing these default will map to something that's not the supported lowest instance type (which is 1cpu, 2Gi memory minus daemonsets, which will need some buffer.

I tried deploying this and it did deploy on the 1x2 instance

DEFAULT_MEMORY = "2Gi"
DEFAULT_USE_GPU = False

DEFAULT_TRAINING_CLASS_FILENAME = "train.py"
Expand Down