Skip to content

Updating Inference Optimization Validations #4971

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

Merged
merged 2 commits into from
Dec 19, 2024
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
10 changes: 5 additions & 5 deletions src/sagemaker/serve/builder/model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,15 +1433,15 @@ def _model_builder_optimize_wrapper(

# HF Model ID format = "meta-llama/Meta-Llama-3.1-8B"
# JS Model ID format = "meta-textgeneration-llama-3-1-8b"
llama_3_1_keywords = ["llama-3.1", "llama-3-1"]
is_llama_3_1 = self.model and any(
keyword in self.model.lower() for keyword in llama_3_1_keywords
is_llama_3_plus = self.model and bool(
re.search(r"llama-3[\.\-][1-9]\d*", self.model.lower())
)

if is_gpu_instance and self.model and self.is_compiled:
if is_llama_3_1:
if is_llama_3_plus:
raise ValueError(
"Compilation is not supported for Llama-3.1 with a GPU instance."
"Compilation is not supported for models greater "
"than Llama-3.0 with a GPU instance."
)
if speculative_decoding_config:
raise ValueError(
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/sagemaker/serve/builder/test_model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3270,7 +3270,7 @@ def test_optimize_with_gpu_instance_and_llama_3_1_and_compilation(

mock_pysdk_model = Mock()
mock_pysdk_model.model_data = None
mock_pysdk_model.env = {"HF_MODEL_ID": "meta-llama/Meta-Llama-3-1-8B-Instruct"}
mock_pysdk_model.env = {"HF_MODEL_ID": "meta-llama/Meta-Llama-3-2-8B-Instruct"}

sample_input = {"inputs": "dummy prompt", "parameters": {}}

Expand All @@ -3279,7 +3279,7 @@ def test_optimize_with_gpu_instance_and_llama_3_1_and_compilation(
dummy_schema_builder = SchemaBuilder(sample_input, sample_output)

model_builder = ModelBuilder(
model="meta-llama/Meta-Llama-3-1-8B-Instruct",
model="meta-llama/Meta-Llama-3-2-8B-Instruct",
schema_builder=dummy_schema_builder,
env_vars={"HF_TOKEN": "token"},
model_metadata={
Expand All @@ -3293,7 +3293,7 @@ def test_optimize_with_gpu_instance_and_llama_3_1_and_compilation(

self.assertRaisesRegex(
ValueError,
"Compilation is not supported for Llama-3.1 with a GPU instance.",
"Compilation is not supported for models greater than Llama-3.0 with a GPU instance.",
lambda: model_builder.optimize(
job_name="job_name-123",
instance_type="ml.g5.24xlarge",
Expand Down
Loading