refactor: extract PathSharder module for shared multi-path selection#2982
refactor: extract PathSharder module for shared multi-path selection#2982sammshen merged 1 commit intoLMCache:devfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new PathSharder utility to centralize path-sharding logic for multi-path storage backends, refactoring GdsBackend and LocalDiskBackend to use this shared component. The review identified a potential bug in the _resolve_device_id helper function regarding "cpu" device handling and robustness against malformed device strings, for which a code suggestion was provided.
aea0776 to
fc8c14a
Compare
aaab7b6 to
e3fd684
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e3fd684. Configure here.
|
Hello @glimchb, Thanks for the hard work. Could you check bot review? |
Move the duplicated path-sharding logic (CSV parsing, device ID extraction, by_gpu strategy) from LocalDiskBackend and GdsBackend into a new PathSharder class in path_sharder.py. Both backends now delegate to PathSharder, keeping the policy in one place. The _resolve_device_id helper handles cuda:N, bare cuda, and cpu devices gracefully. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai> Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
DongDongJu
left a comment
There was a problem hiding this comment.
LGTM.
I left one nit question.
|
|
||
| def test_gds_path_sharding_default(self, temp_gds_path, async_loop): | ||
| """Default gds_path_sharding is 'by_gpu'.""" | ||
| """Default gds_path_sharding is 'by_gpu' (backend inits OK).""" |
There was a problem hiding this comment.
What does "backend inits OK" meaning?
…MCache#2982) Move the duplicated path-sharding logic (CSV parsing, device ID extraction, by_gpu strategy) from LocalDiskBackend and GdsBackend into a new PathSharder class in path_sharder.py. Both backends now delegate to PathSharder, keeping the policy in one place. The _resolve_device_id helper handles cuda:N, bare cuda, and cpu devices gracefully. Generated with [Devin](https://cli.devin.ai/docs) Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com> Co-authored-by: Devin <noreply@cognition.ai>
- Remove validate_nixl_path method from NixlStorageConfig - Update NixlFilePool to accept PathSharder instance - Update createPool to use PathSharder with buffer_device - Update tests to use PathSharder directly This aligns with PR LMCache#2982 which centralized path sharding logic.
- Remove validate_nixl_path method from NixlStorageConfig - Update NixlFilePool to accept PathSharder instance - Update createPool to use PathSharder with buffer_device - Update tests to use PathSharder directly This aligns with PR LMCache#2982 which centralized path sharding logic.
- Remove validate_nixl_path method from NixlStorageConfig - Update NixlFilePool to accept PathSharder instance - Update createPool to use PathSharder with buffer_device - Update tests to use PathSharder directly This aligns with PR LMCache#2982 which centralized path sharding logic. Signed-off-by: Ugur Kaynar <ugur.kaynar@dell.com>
…MCache#2982) Move the duplicated path-sharding logic (CSV parsing, device ID extraction, by_gpu strategy) from LocalDiskBackend and GdsBackend into a new PathSharder class in path_sharder.py. Both backends now delegate to PathSharder, keeping the policy in one place. The _resolve_device_id helper handles cuda:N, bare cuda, and cpu devices gracefully. Generated with [Devin](https://cli.devin.ai/docs) Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com> Co-authored-by: Devin <noreply@cognition.ai>

Move the duplicated path-sharding logic (CSV parsing, device ID extraction, by_gpu strategy) from LocalDiskBackend and GdsBackend into a new PathSharder class in path_sharder.py.
Both backends now delegate to PathSharder, keeping the policy in one place. The _resolve_device_id helper handles cuda:N, bare cuda, and cpu devices gracefully.
Generated with Devin
What this PR does / why we need it:
Special notes for your reviewers:
If applicable:
Note
Medium Risk
Touches storage backend initialization and path selection logic for both
LocalDiskBackendandGdsBackend, which could change which directory is used (and how invalid configs fail) in multi-GPU/multi-path deployments.Overview
Refactors multi-path cache directory selection by extracting the shared CSV parsing + by-GPU sharding logic into a new
PathSharderutility and switching bothGdsBackendandLocalDiskBackendto use it.Standardizes device-id resolution (handles
cuda:N, barecuda, andcpu) and changes unsupported sharding configuration failures fromAssertionErrortoValueError, with updated/new unit tests covering selection, directory creation, and edge cases.Reviewed by Cursor Bugbot for commit 1923414. Bugbot is set up for automated code reviews on this repo. Configure here.