-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[HiCache & HybridModel] mooncake backend support DSA & mamba model #21259
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
Merged
xiezhq-hermann
merged 50 commits into
sgl-project:main
from
antgroup:hicache/hicache-refactor4
Apr 14, 2026
Merged
Changes from 43 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
0d2651c
Init support for himamba tree offloading
hzh0425 638ff30
Fix mamba prefix match logic
hzh0425 3556ed6
Enhance evict logic & Loading host mamba into both req and node's mam…
hzh0425 282737a
Fix hang issue
hzh0425 f2a0629
Refactor prefetch logic; fix memory leak issue
hzh0425 7316d0e
Support 'page_first_direct' layout for mambaPoolHost
hzh0425 6874520
Optimize code style
hzh0425 a03ae57
Optimize code style
hzh0425 2836195
Optimize code style
hzh0425 91f954f
Remove pp filter
hzh0425 520ca17
Optimize layerwise waiting logic
hzh0425 3cd247d
Support loading mamba state only
hzh0425 77163eb
Using enum to replace str
hzh0425 df5867c
support MambaPoolHost layout
huangtingwei9988 0f2d251
rollback format
hzh0425 83c6104
Optimize code style
hzh0425 b67edcb
Simplify Code in hicache_storage.py
huangtingwei9988 18d724b
fix evict num
ispobock 3204f85
remove unused
ispobock abfc3d3
Simplify Code
huangtingwei9988 913626a
Merge remote-tracking branch 'origin/main' into hicache/hicache-refac…
hzh0425 6318d9c
Revert "Simplify Code"
hzh0425 571bce4
Add comment for io kernel
hzh0425 c825a08
Fix mixed chunk ci
hzh0425 0655c3c
Merge remote-tracking branch 'origin/main' into hicache/hicache-refac…
hzh0425 83b7663
Optimize log; Add CI
hzh0425 61f6670
support mooncake backend & dsa model
huangtingwei9988 e9e3c8d
fix bugs
huangtingwei9988 ffdf173
fix bugs while running dsa
huangtingwei9988 1d2134e
fix lint
huangtingwei9988 7dc50f9
merge main
huangtingwei9988 934874b
merge fix
huangtingwei9988 d957bc4
Merge branch 'main' into hicache/hicache-refactor4
huangtingwei9988 98048c5
fix
huangtingwei9988 aacc0e9
address comments
vladnosiv 1f506f9
fix metrics
huangtingwei9988 5d08e79
Merge branch 'main' into hicache/hicache-refactor4
huangtingwei9988 9bacae6
Reduce modifications in the HiRadix cache.
huangtingwei9988 75b15b1
fix
huangtingwei9988 8dd2287
fix
huangtingwei9988 d0acd7e
Merge branch 'main' into hicache/hicache-refactor4
huangtingwei9988 94bfc89
Merge branch 'main' into hicache/hicache-refactor4
huangtingwei9988 1777830
Merge branch 'main' into hicache/hicache-refactor4
huangtingwei9988 095baf3
fix
huangtingwei9988 11d67ce
resolve conflict
huangtingwei9988 586b337
opt
huangtingwei9988 973110d
build_mamba_hybrid_stack
huangtingwei9988 ebf777f
Merge branch 'main' into hicache/hicache-refactor4
huangtingwei9988 fccef9e
fix ci
huangtingwei9988 b15552e
Merge branch 'hicache/hicache-refactor4' of github.com:antgroup/sglan…
huangtingwei9988 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,6 +163,7 @@ def __init__( | |
| pp_rank: int = 0, | ||
| pp_size: int = 1, | ||
| transfer_layer_num: Optional[int] = None, | ||
| enable_storage_metrics: bool = False, | ||
| ): | ||
| startup_storage_backend = storage_backend | ||
| super().__init__( | ||
|
|
@@ -179,6 +180,7 @@ def __init__( | |
| storage_backend_extra_config=storage_backend_extra_config, | ||
| pp_rank=pp_rank, | ||
| pp_size=pp_size, | ||
| enable_storage_metrics=enable_storage_metrics, | ||
| ) | ||
| # Override layer_num: hybrid models transfer all layers (For example, Linear Model (KV + Mamba)), | ||
| # not just the full attention layers reported by full_kv_pool. | ||
|
|
@@ -230,7 +232,10 @@ def write( | |
| if host_indices is None: | ||
| return None | ||
| pool_transfers = self._resolve_pool_transfers_allocation( | ||
| extra_pools, alloc_host=True | ||
| extra_pools, | ||
| alloc_host=True, | ||
| kv_device_indices=device_indices, | ||
| kv_host_indices=host_indices, | ||
| ) | ||
| if pool_transfers is None and extra_pools: | ||
| self.mem_pool_host.free(host_indices) | ||
|
|
@@ -289,7 +294,10 @@ def load( | |
| device_indices = torch.empty((0,), dtype=torch.int64, device=self.device) | ||
|
|
||
| pool_transfers = self._resolve_pool_transfers_allocation( | ||
| extra_pools, alloc_host=False | ||
| extra_pools, | ||
| alloc_host=False, | ||
| kv_device_indices=device_indices, | ||
| kv_host_indices=host_indices, | ||
| ) | ||
| if pool_transfers is None and extra_pools: | ||
| if need_load_kv: | ||
|
|
@@ -415,6 +423,7 @@ def _storage_hit_query(self, operation) -> tuple[list[str], int]: | |
| def _page_transfer(self, operation): | ||
| # Transfer extra pools | ||
| if operation.pool_transfers and not operation.is_terminated(): | ||
| self._resolve_shared_pool_transfers(operation) | ||
| results = self.storage_backend.batch_get_v2(operation.pool_transfers) | ||
| operation.pool_storage_result.update_extra_pool_hit_pages(results) | ||
|
|
||
|
|
@@ -424,12 +433,20 @@ def _page_transfer(self, operation): | |
| def _page_backup(self, operation): | ||
| # Backup extra pools | ||
| if operation.pool_transfers: | ||
| self._resolve_shared_pool_transfers(operation) | ||
| results = self.storage_backend.batch_set_v2(operation.pool_transfers) | ||
| operation.pool_storage_result.update_extra_pool_hit_pages(results) | ||
|
|
||
| # Backup kv pools | ||
| super()._page_backup(operation) | ||
|
Comment on lines
433
to
441
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like atomic. But |
||
|
|
||
| def _resolve_shared_pool_transfers(self, operation): | ||
| for transfer in operation.pool_transfers: | ||
| entry = self.mem_pool_host.entry_map.get(transfer.name) | ||
| if entry.share_indices_with_anchor: | ||
| transfer.keys = operation.hash_value | ||
| transfer.host_indices = operation.host_indices | ||
|
|
||
| def _sync_trailing_keys( | ||
| self, | ||
| pool_transfers: list[PoolTransfer], | ||
|
|
@@ -454,6 +471,8 @@ def _resolve_pool_transfers_allocation( | |
| self, | ||
| extra_pools: Optional[list[PoolTransfer]], | ||
| alloc_host: bool, | ||
| kv_device_indices: Optional[torch.Tensor] = None, | ||
| kv_host_indices: Optional[torch.Tensor] = None, | ||
| ) -> Optional[list[PoolTransfer]]: | ||
| """Auto-alloc host or device indices for PoolTransfers where they are None.""" | ||
| if not extra_pools: | ||
|
|
@@ -463,6 +482,10 @@ def _resolve_pool_transfers_allocation( | |
| entry = self.mem_pool_host.entry_map.get(pool.name) | ||
| if entry is None: | ||
| continue | ||
| if entry.share_indices_with_anchor: | ||
| pool.device_indices = kv_device_indices | ||
| pool.host_indices = kv_host_indices | ||
| continue | ||
| if alloc_host: | ||
| if pool.host_indices is not None or pool.device_indices is None: | ||
| continue | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.