Skip to content

Extend inferenceService API for Accelerator Support#258

Merged
slin1237 merged 1 commit into
mainfrom
yifeliu/inference-extension
Aug 31, 2025
Merged

Extend inferenceService API for Accelerator Support#258
slin1237 merged 1 commit into
mainfrom
yifeliu/inference-extension

Conversation

@pallasathena92
Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind feature
/kind design

What this PR does / why we need it:

Users need a way to specify which accelerators their InferenceService should use. This can range from simple preferences (e.g., "use cheapest GPU") to specific requirements (e.g., "must use H100"). The API should support both explicit selection and constraint-based selection.

Add accelerator selection capabilities to the InferenceService API, allowing users to specify accelerator preferences and constraints for their model deployments.

Does this PR introduce a user-facing change?

It introduced some new parameters in inferenceService. All these parameters with optional marker, it won't impact current customer behavior.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @pallasathena92, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly extends the InferenceService API to provide robust support for accelerator selection. It empowers users to define precise requirements and preferences for the accelerators used by their model deployments, offering both explicit selection and constraint-based filtering. This enhancement aims to improve resource utilization and operational flexibility for AI/ML workloads, with all new parameters being optional to ensure backward compatibility.

Highlights

  • Enhanced Accelerator Selection: Introduced a new "acceleratorSelector" field within "InferenceServiceSpec" allowing users to specify accelerator preferences, including explicit "AcceleratorClass" selection or constraint-based filtering.
  • Detailed Accelerator Constraints: Added "AcceleratorConstraints" with fields for "MinMemory", "MaxMemory", "MinComputeCapability", "RequiredFeatures", "ExcludedClasses", and "ArchitectureFamilies" to enable fine-grained control over accelerator selection.
  • Flexible Selection Policies: Implemented "AcceleratorSelectionPolicy" with options like "BestFit", "Cheapest", "MostCapable", and "FirstAvailable" to define how accelerators are chosen when multiple options meet the criteria.
  • Component-Level Accelerator Overrides: Included "acceleratorOverride" fields in "EngineSpec" and "DecoderSpec" to allow specific components of an InferenceService to use different accelerator selections than the global service-level setting.
  • Accelerator Status Reporting: Added "SelectedAccelerator" to "ComponentStatusSpec" to provide visibility into which accelerator was ultimately selected for a component, along with the reason, node selector, and resource requests.
  • CRD Integration: Integrated the new "AcceleratorClass" CRD into the kustomization configurations, laying the groundwork for defining and managing accelerator resources within the cluster.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a well-designed API for accelerator selection in InferenceService, which is a great feature. The use of AcceleratorSelector with constraints and policies provides good flexibility for users.

I have a few suggestions to improve the API's consistency with Kubernetes conventions. These involve using fixed-width integer types for resource constraints and adopting the standard v1.ResourceList for resource requests in the status. These changes will require regenerating the deepcopy and OpenAPI files.

Comment on lines +81 to +83
// ResourceRequests that were applied to pods
// +optional
ResourceRequests map[string]string `json:"resourceRequests,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The ResourceRequests field should use the standard Kubernetes type v1.ResourceList instead of map[string]string to represent resource requests. This provides a structured way to handle resource quantities and is consistent with the rest of the Kubernetes API.

Suggested change
// ResourceRequests that were applied to pods
// +optional
ResourceRequests map[string]string `json:"resourceRequests,omitempty"`
// ResourceRequests that were applied to pods
// +optional
ResourceRequests v1.ResourceList `json:"resourceRequests,omitempty"`

Comment on lines +78 to +80
// MinMemory in GB
// +optional
MinMemory *int `json:"minMemory,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other API fields and to avoid platform-dependent integer sizes, it's better to use *int64 instead of *int for MinMemory.

Suggested change
// MinMemory in GB
// +optional
MinMemory *int `json:"minMemory,omitempty"`
// MinMemory in GB
// +optional
MinMemory *int64 `json:"minMemory,omitempty"`

Comment on lines +82 to +84
// MaxMemory in GB (useful for cost control)
// +optional
MaxMemory *int `json:"maxMemory,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other API fields and to avoid platform-dependent integer sizes, it's better to use *int64 instead of *int for MaxMemory.

Suggested change
// MaxMemory in GB (useful for cost control)
// +optional
MaxMemory *int `json:"maxMemory,omitempty"`
// MaxMemory in GB (useful for cost control)
// +optional
MaxMemory *int64 `json:"maxMemory,omitempty"`

Comment on lines +86 to +88
// MinComputeCapability in TFLOPS
// +optional
MinComputeCapability *int `json:"minComputeCapability,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other API fields and to avoid platform-dependent integer sizes, it's better to use *int64 instead of *int for MinComputeCapability.

Suggested change
// MinComputeCapability in TFLOPS
// +optional
MinComputeCapability *int `json:"minComputeCapability,omitempty"`
// MinComputeCapability in TFLOPS
// +optional
MinComputeCapability *int64 `json:"minComputeCapability,omitempty"`

@slin1237 slin1237 merged commit 1452192 into main Aug 31, 2025
24 checks passed
@slin1237 slin1237 deleted the yifeliu/inference-extension branch September 6, 2025 17:06
slin1237 pushed a commit that referenced this pull request Dec 22, 2025
add api inference extension with acceleratorClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants