mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[PR #581] [MERGED] feat(topology): improve HCA selection by considering PCIe distance #1667
Labels
No labels
ascend
auto-closed
bug
bug
CI/Build
Common
documentation
enhancement
feature request
good first issue
help wanted
high priority
MetaX
nightly-failure
pull-request
PyTorch Backend
question
RFC
Roadmap
stale
Store
Tests
Transfer Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/Mooncake#1667
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/Mooncake/pull/581
Author: @staryxchen
Created: 7/2/2025
Status: ✅ Merged
Merged: 7/8/2025
Merged by: @wx-csy
Base:
main← Head:bugfix/distancecalc📝 Commits (1)
b4ca77dfeat(topology): improve HCA selection by considering PCIe distance📊 Changes
1 file changed (+20 additions, -3 deletions)
View changed files
📝
mooncake-transfer-engine/src/topology.cpp(+20 -3)📄 Description
Background
The function
getPciDistanceis used to determine the PCIe topological distance between two devices (e.g., GPU and NIC) by comparing their sysfs paths. Previously, the function only returned 0 if the two devices had exactly the same sysfs path prefix, i.e., their paths were identical except for the device itself. This approach failed to recognize that two devices under the same PCIe switch/root port, but with different device IDs, should also be considered as having a distance of 0.Problem Example
Suppose we have two PCIe devices with the following bus IDs and sysfs paths:
0000:bc:00.0, path1:/sys/devices/pci0000:b2/0000:b2:03.1/0000:b9:00.0/0000:ba:01.0/0000:bc:00.00000:bb:00.0, path2:/sys/devices/pci0000:b2/0000:b2:03.1/0000:b9:00.0/0000:ba:00.0/0000:bb:00.0In this case, both devices are under the same PCIe switch, but their sysfs paths differ only in the last component (the device itself). The previous implementation would not recognize them as being under the same switch and would return a non-zero distance.
Fix
This patch improves
getPciDistanceby first removing the last component (the device itself) from both sysfs paths, and then applying the original distance calculation algorithm. If the parent paths are identical, the function now correctly returns 0, indicating that the two devices are under the same PCIe switch/root port.Impact
If you have any questions about the patch or need more real-world examples, feel free to ask!
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.