Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
REQUIRED_COLUMNS = ["prompt", "response"]

MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER = 5
MAX_LLM_ENDPOINTS_PER_INTERNAL_USER = 15

MAX_SUFFIX_LENGTH = 28
# k8s labels need to be <= 62 characters, timestamp takes 13 characters, 2 characters for periods,
Expand Down Expand Up @@ -115,17 +114,14 @@ async def execute(self, user: User, request: CreateFineTuneRequest) -> CreateFin

current_jobs_and_endpoints = len(in_progress_jobs) + len(model_endpoints)

max_llm_endpoints_per_user = (
MAX_LLM_ENDPOINTS_PER_INTERNAL_USER
if user.is_privileged_user
else MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER
)

if current_jobs_and_endpoints >= max_llm_endpoints_per_user:
if (
not user.is_privileged_user
and current_jobs_and_endpoints >= MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER
):
raise LLMFineTuningQuotaReached(
f"Limit {max_llm_endpoints_per_user} fine-tunes/fine-tuned endpoints per user. "
f"Limit {MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER} fine-tunes/fine-tuned endpoints per user. "
f"Cancel/delete a total of "
f"{current_jobs_and_endpoints - max_llm_endpoints_per_user + 1} pending or "
f"{current_jobs_and_endpoints - MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER + 1} pending or "
f"running fine-tune(s) or fine-tuned endpoints to run another fine-tune."
)

Expand Down
8 changes: 4 additions & 4 deletions model-engine/tests/unit/domain/test_llm_use_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
UpstreamServiceError,
)
from model_engine_server.domain.use_cases.llm_fine_tuning_use_cases import (
MAX_LLM_ENDPOINTS_PER_INTERNAL_USER,
MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER,
CreateFineTuneV1UseCase,
GetFineTuneEventsV1UseCase,
is_model_name_suffix_valid,
Expand Down Expand Up @@ -1416,7 +1416,7 @@ async def test_create_fine_tune_limit(
fake_llm_fine_tuning_events_repository,
fake_file_storage_gateway,
)
user = User(user_id=test_api_key, team_id=test_api_key, is_privileged_user=True)
user = User(user_id=test_api_key, team_id=test_api_key, is_privileged_user=False)
request = CreateFineTuneRequest(
model="base_model",
training_file="file1",
Expand All @@ -1425,8 +1425,8 @@ async def test_create_fine_tune_limit(
hyperparameters={},
suffix=None,
)
for i in range(MAX_LLM_ENDPOINTS_PER_INTERNAL_USER):
if i == MAX_LLM_ENDPOINTS_PER_INTERNAL_USER:
for i in range(MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER):
if i == MAX_LLM_ENDPOINTS_PER_EXTERNAL_USER:
with pytest.raises(LLMFineTuningQuotaReached):
await use_case.execute(user=user, request=request)
else:
Expand Down