[None][refactor] Modularize resource_manager.py into a package#12883
Draft
eopXD wants to merge 7 commits intoNVIDIA:mainfrom
Draft
[None][refactor] Modularize resource_manager.py into a package#12883eopXD wants to merge 7 commits intoNVIDIA:mainfrom
eopXD wants to merge 7 commits intoNVIDIA:mainfrom
Conversation
Split the 2,956-line monolithic resource_manager.py into a resource_manager/ package with focused submodules: - base.py: BaseResourceManager ABC, ResourceManager coordinator, enums - kv_cache_manager.py: KVCacheManager (v1, C++ binding-backed) - kv_cache_manager_v2.py: KVCacheManagerV2 (Python runtime-backed) - vswa.py: Variable Sliding Window Attention calculation utilities - kv_cache_spec_ops.py: Spec-dec x KV-cache cross-cutting operations - peft_cache_manager.py: PeftCacheManager for LoRA adapters - simple_managers.py: SlotManager and BlockManager utilities - __init__.py: Full re-exports for backward compatibility All 36+ existing importers work unchanged. No runtime behavior changes. Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
…ation - Fix P0: Restore `mpi_rank() == 0` check (was incorrectly changed to `mpi_disabled()`) for KV cache event manager creation on rank 0 - Fix P0: Remove stale `model_config=` kwarg in vswa.py call to `adjust_window_sizes_for_vswa` (would cause TypeError at runtime) - Fix P1: Update copyright year to 2026 on all new files - Fix P1: Remove `_locate_accepted_draft_tokens` from __init__.py re-exports (private helper, no external consumers) Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
Add DecodingBaseConfig and AttentionMetadata under TYPE_CHECKING to fix F821 (undefined name) errors in kv_cache_manager.py and kv_cache_manager_v2.py. Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
Break long log/error message strings to comply with 120-char line limit enforced by ruff in CI. Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
These files are not in the legacy-files list, so CI runs ruff-format instead of yapf. Apply ruff-format as the authoritative formatter. Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
Collaborator
Author
|
/bot run |
Collaborator
|
PR_Github #42499 [ run ] triggered by Bot. Commit: |
Collaborator
|
PR_Github #42499 [ run ] completed with state
|
…nager The method was removed during the VSWA extraction refactor but is still called by disaggregated serving code (kv_extractor, test_mamba_transfer). Re-add it as a thin wrapper around the extracted standalone function. Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
3e6802d to
7bfc3d0
Compare
Collaborator
Author
|
/bot run --disable-fail-fast |
Collaborator
|
PR_Github #42646 [ run ] triggered by Bot. Commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resource_manager.pyinto aresource_manager/package with 7 focused submodules__init__.pyre-exports — zero external changes requiredKVCacheManager) and v2 (KVCacheManagerV2) into independent files, reducing merge conflict surfaceModule breakdown
base.pyBaseResourceManagerABC,ResourceManagercoordinator, enumskv_cache_manager.pyKVCacheManager(v1, C++ binding-backed)kv_cache_manager_v2.pyKVCacheManagerV2(Python runtime-backed)vswa.pykv_cache_spec_ops.pypeft_cache_manager.pyPeftCacheManagerfor LoRA adapterssimple_managers.pySlotManager,BlockManager__init__.pyMotivation
See
docs/rfcs/resource-manager-modularization.mdin this repo for the full RFC with problem analysis, design rationale, and migration strategy.Test plan
py_compile)tensorrt_llm, 3-dot for_torch, 2-dot forpyexecutor)__init__.pyCacheTypeCppandDataTypebinding aliases re-exported formamba_cache_manager.pycompatibility