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

[Performance]: Process affinity to CPU cores with multiple sockets support #2171

Merged
merged 5 commits into from
Nov 25, 2024

Conversation

HaiShaw
Copy link
Collaborator

@HaiShaw HaiShaw commented Nov 25, 2024

Motivation

Setting process affinity to designated cpu ids, to avoid unwanted process migrations (cost high in case of multiple sockets)

Modifications

Assign specific process to designated cores, handle multiple sockets, and HT (hyper threading: 1 Physical core runs as 2 logical cores)

Online benchmarking shows notable improvement (request rate: 4/8/16) on MI300X system with dual socket CPUs.

Checklist

  • [+] Format your code according to the Contributor Guide.
  • [+] Add unit tests as outlined in the Contributor Guide.
  • [+] Update documentation as needed, including docstrings or example tutorials.

Copy link
Contributor

@merrymercy merrymercy left a comment

Choose a reason for hiding this comment

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

We have multiple threads, not sure whether we need to call them all.
also call it here

with torch.cuda.stream(self.forward_stream):

@HaiShaw
Copy link
Collaborator Author

HaiShaw commented Nov 25, 2024

We have multiple threads, not sure whether we need to call them all. also call it here

with torch.cuda.stream(self.forward_stream):

We don't need to call this per thread, currently we look forward to binding at process level. :)

@merrymercy merrymercy merged commit 10189d0 into sgl-project:main Nov 25, 2024
12 of 14 checks passed
@HaiShaw HaiShaw deleted the affinity branch November 26, 2024 00:22
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants