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

[DO NOT REVIEW] AI gateway rate limits design & quick POC #9939

Closed
wants to merge 2 commits into from

Conversation

harupy
Copy link
Member

@harupy harupy commented Oct 13, 2023

Open in GitHub Codespaces

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

mlflow gateway start --config-path examples/gateway/openai/config.yaml
curl -X 'POST' 'http://127.0.0.1:5000/gateway/chat/invocations' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
  "max_tokens": 10,
  "messages": [
    {
      "role": "user",
      "content": "hello"
    }
  ]
}'

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/artifacts: Artifact stores and artifact logging
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages
  • area/examples: Example code
  • area/gateway: AI Gateway service, Gateway client APIs, third-party Gateway integrations
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/recipes: Recipes, Recipe APIs, Recipe configs, Recipe Templates
  • area/projects: MLproject format, project running backends
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/server-infra: MLflow Tracking server backend
  • area/tracking: Tracking Service, tracking client APIs, autologging

Interface

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/docker: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
  • area/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registry
  • area/windows: Windows support

Language

  • language/r: R APIs and clients
  • language/java: Java APIs and clients
  • language/new: Proposals for new client languages

Integrations

  • integrations/azure: Azure and Azure ML integrations
  • integrations/sagemaker: SageMaker integrations
  • integrations/databricks: Databricks integrations

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

@harupy harupy marked this pull request as draft October 13, 2023 10:25
@github-actions
Copy link

github-actions bot commented Oct 13, 2023

Documentation preview for 15ce328 will be available here when this CircleCI job completes successfully.

More info

@github-actions github-actions bot added the rn/none List under Small Changes in Changelogs. label Oct 13, 2023
Signed-off-by: harupy <hkawamura0130@gmail.com>
Signed-off-by: harupy <hkawamura0130@gmail.com>
Comment on lines +4 to +6
limit:
renewal_period: "minute"
calls: 1
Copy link
Member Author

Choose a reason for hiding this comment

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

Global limit vs. per-route limit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

per-route limit

@@ -6,8 +6,14 @@
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.responses import FileResponse, RedirectResponse
from pydantic import BaseModel
from slowapi import Limiter, _rate_limit_exceeded_handler
Copy link
Member Author

@harupy harupy Oct 16, 2023

Choose a reason for hiding this comment

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

@@ -1,6 +1,9 @@
routes:
- name: chat
route_type: llm/v1/chat
limit:
Copy link
Member Author

@harupy harupy Oct 16, 2023

Choose a reason for hiding this comment

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

Do we need multiple limits?

@harupy
Copy link
Member Author

harupy commented Oct 20, 2023

@TomeHirata Would you be interested in working on this?

@harupy harupy changed the title [POC] Gateway rate limits [POC] Gateway rate limits design Oct 20, 2023
@harupy harupy changed the title [POC] Gateway rate limits design [Gateway rate limits design & quick POC Oct 20, 2023
@harupy harupy changed the title [Gateway rate limits design & quick POC AI gateway rate limits design & quick POC Oct 20, 2023
@harupy harupy changed the title AI gateway rate limits design & quick POC [DO NOT REVIEW] AI gateway rate limits design & quick POC Oct 20, 2023
@TomeHirata
Copy link
Contributor

TomeHirata commented Oct 23, 2023

@harupy Yes, is there any ticket for this task? If so, please assign this task to me!

@TomeHirata
Copy link
Contributor

TomeHirata commented Dec 18, 2023

@harupy I read the doc and understood the overall direction. Before starting the implementation, can I ask if there is a way for me to see this link?
I also saw mlflow.gateway.get_limits is deprecated. Should I reuse the method? or recreate a new one?

@harupy
Copy link
Member Author

harupy commented Dec 19, 2023

can I ask if there is a way for me to see this link?

Sorry, this is a link to our internal repo.

I also saw mlflow.gateway.get_limits is deprecated. Should I reuse the method? or recreate a new one?

mlflow.gateway has been deprecated and replaced by mlflow.deployments. We no longer have get_limits. The rate limit info should be included in the response of get_endpoint. I can take care of that part.

@TomeHirata
Copy link
Contributor

TomeHirata commented Dec 20, 2023

Thank you for the reply. So what did the link refer to? Is it the same as the example code in the design doc?
Regarding the scope of the change, can I understand the necessary changes are as follows? Anything I'm missing?

  1. Read the rate limit configuration from the endpoint yaml
  2. Implement the rate limiting with slowapi
  3. Include the rate limit info in the response of get_endpoint

@harupy
Copy link
Member Author

harupy commented Dec 21, 2023

Is it the same as the example code in the design doc?

Yes :)

Regarding the scope of the change, can I understand the necessary changes are as follows? Anything I'm missing?

Yes, that's correct!

@TomeHirata
Copy link
Contributor

TomeHirata commented Dec 21, 2023

Thank you, let me start working on this shortly. Should I take over this PR? or create a new one?
->Update: I cannot take over this PR since this is not my repo, let me create a new one.

@TomeHirata TomeHirata mentioned this pull request Jan 4, 2024
37 tasks
@harupy harupy closed this Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn/none List under Small Changes in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants