Skip to content

feat: enable cpu affinity, pin loadgen to CPU-0#69

Merged
viraatc merged 5 commits intomainfrom
feat/viraatc-cpu-affinity
Jan 12, 2026
Merged

feat: enable cpu affinity, pin loadgen to CPU-0#69
viraatc merged 5 commits intomainfrom
feat/viraatc-cpu-affinity

Conversation

@viraatc
Copy link
Copy Markdown
Collaborator

@viraatc viraatc commented Dec 22, 2025

What does this PR do?

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor/cleanup

Related issues

Testing

  • Tests added/updated
  • All tests pass locally
  • Manual testing completed

Checklist

  • Code follows project style
  • Pre-commit hooks pass
  • Documentation updated (if needed)

@viraatc viraatc requested a review from a team as a code owner December 22, 2025 23:34
Copilot AI review requested due to automatic review settings December 22, 2025 23:34
@github-actions github-actions bot requested a review from arekay-nv December 22, 2025 23:34
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 22, 2025

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@github-actions github-actions bot requested a review from nvzhihanj December 22, 2025 23:34
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @viraatc, 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 introduces a significant new feature that enables CPU affinity for worker processes within the inference endpoint client. By allowing workers to be pinned to specific CPU cores, this enhancement aims to optimize resource utilization, potentially leading to improved performance and stability, particularly in demanding or specialized computing environments. The implementation provides flexible configuration options, including automatic core distribution and explicit core selection.

Highlights

  • New Configuration Option: Introduced a new cpu_affinity configuration option within HTTPClientConfig to control how worker processes are assigned to CPU cores.
  • CPU Affinity Implementation: Implemented the core logic to apply CPU affinity settings to newly spawned worker processes, allowing them to be pinned to specific CPU cores.
  • Flexible Core Assignment: The CPU affinity feature supports an 'auto' mode for round-robin core assignment and allows specifying a list of explicit CPU core IDs for pinning.
  • Robustness: Includes error handling for cases where setting CPU affinity might fail, logging warnings without halting the process.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds CPU affinity configuration to pin worker processes to specific CPU cores for performance optimization. The feature supports automatic core assignment, manual core specification, or can be disabled entirely.

Key Changes:

  • Added cpu_affinity configuration parameter supporting "auto", explicit core list, or None
  • Implemented CPU core pinning logic in worker spawn process with error handling

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/inference_endpoint/endpoint_client/configs.py Adds cpu_affinity configuration field with three modes: None (disabled), "auto" (automatic assignment), or explicit core list
src/inference_endpoint/endpoint_client/worker.py Implements CPU affinity logic that pins spawned workers to cores based on configuration, with fallback error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@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 CPU affinity for worker processes, allowing them to be pinned to specific CPU cores for better performance and stability. The implementation is mostly correct, but I've found a potential ZeroDivisionError that could crash the application if no available CPUs are found. My review includes a fix for this issue along with improved logging for better diagnostics.

@viraatc viraatc changed the title add cpu affinity feat: add cpu affinity Dec 22, 2025
@viraatc viraatc changed the title feat: add cpu affinity feat: add cpu affinity to http-client Dec 22, 2025
Copilot AI review requested due to automatic review settings December 22, 2025 23:49
@viraatc viraatc changed the title feat: add cpu affinity to http-client feat: enable cpu affinity, pin loadgen to CPU-0 Dec 22, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@viraatc viraatc force-pushed the feat/viraatc-cpu-affinity branch from bc575b2 to 9e1a96c Compare December 22, 2025 23:54
Copilot AI review requested due to automatic review settings December 22, 2025 23:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@arekay-nv arekay-nv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

Copilot AI review requested due to automatic review settings December 24, 2025 11:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 24, 2025 11:19
@viraatc viraatc force-pushed the feat/viraatc-cpu-affinity branch from 56dcefb to 1e22394 Compare December 24, 2025 11:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 2, 2026 22:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@viraatc viraatc force-pushed the feat/viraatc-cpu-affinity branch from 01ae2bf to 9022145 Compare January 2, 2026 22:26
Copilot AI review requested due to automatic review settings January 2, 2026 22:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 9, 2026 08:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@viraatc viraatc force-pushed the feat/viraatc-cpu-affinity branch from 4c9edb9 to 2a69896 Compare January 9, 2026 10:06
Copilot AI review requested due to automatic review settings January 9, 2026 10:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/inference_endpoint/utils/cpu_affinity.py:1

  • The comment references 'cpu_affinity.py' but this file itself is 'worker.py'. The comment should reference the module name 'inference_endpoint.utils.cpu_affinity' or clarify that it refers to the imported AVAILABLE_CPUS variable to avoid confusion.
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@viraatc viraatc force-pushed the feat/viraatc-cpu-affinity branch from 2a69896 to 860eefa Compare January 9, 2026 10:07
Copilot AI review requested due to automatic review settings January 9, 2026 10:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/inference_endpoint/endpoint_client/worker.py:1

  • The comment states 'excluding CPU 0', but the actual implementation excludes the loadgen CPU (which may not be CPU 0 if a different core is configured or detected as fastest). Update the comment to say 'excluding loadgen CPU' for accuracy.
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@arekay-nv arekay-nv left a comment

Choose a reason for hiding this comment

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

LGTM!
Thanks!

Copilot AI review requested due to automatic review settings January 12, 2026 04:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@viraatc viraatc force-pushed the feat/viraatc-cpu-affinity branch from b12ecb3 to 6020265 Compare January 12, 2026 19:53
@viraatc viraatc force-pushed the feat/viraatc-cpu-affinity branch from 6020265 to 2f10034 Compare January 12, 2026 19:54
Copilot AI review requested due to automatic review settings January 12, 2026 20:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@viraatc viraatc merged commit db27cce into main Jan 12, 2026
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2026
@viraatc viraatc deleted the feat/viraatc-cpu-affinity branch February 6, 2026 23:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants