Skip to content

refactor: extract shared virtual memory primitives. - #2468

Merged
liutongxuan merged 9 commits into
xLLM-AI:mainfrom
liutongxuan:features/kv_cache_refactor
Oct 13, 2026
Merged

liutongxuan merged 9 commits into
xLLM-AI:mainfrom
liutongxuan:features/kv_cache_refactor

Conversation

@liutongxuan

Copy link
Copy Markdown
Collaborator

Description

Related Issues

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor
  • Documentation
  • Test
  • Build or CI

Pull Request Checklist

Thank you for contributing to xLLM. Before requesting review, please make sure the following items are complete.

PR Title and Commit Messages

  • The PR title and each commit message follow the xLLM commit format: <type>: <subject>.

Allowed types: feat, bugfix, docs, test, refactor, chore, style, revert, perf, model, build, release.
The subject should use clear English, start with a verb, include at least 4 words, and end with ..

Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit or an equivalent command.
  • I have installed the hooks with pre-commit install.
  • I have run pre-commit run --all-files and fixed any reported issues.

If you are unsure how to set up pre-commit, see the pre-commit documentation.

Self Review

  • I have self-reviewed the code according to .agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.
  • I have rebased this PR onto the latest main branch.

Build and Test Coverage

  • Tests have been added or updated as needed.
  • CUDA: python setup.py build test has passed on a CUDA machine.
  • NPU: python setup.py build test has passed on an NPU machine.
  • MLU: python setup.py build test has passed on an MLU machine.

Reviewer Notes

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-13T09:38:11.551730Z edbe940 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 487 files, which is 187 over the limit of 300.

To get a review, reduce the PR to 300 files or fewer by splitting it into smaller PRs or changing its base branch.

Usage-priced reviews support at most 300 files.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 878b612e-34e0-4800-ac27-5ddc84d28f4e
📥 Commits

Reviewing files that changed from the base of the PR and between 0c399e7 and edbe940.

📒 Files selected for processing (487)
  • AGENTS.md
  • docs/src/content/docs/en/cli_reference.md
  • docs/src/content/docs/en/dev_guide/code_arch.md
  • docs/src/content/docs/zh/cli_reference.md
  • docs/src/content/docs/zh/dev_guide/code_arch.md
  • tests/api_service/mm_embedding_roundtrip_test.cpp
  • tests/core/CMakeLists.txt
  • tests/core/distributed_runtime/CMakeLists.txt
  • tests/core/distributed_runtime/distributed_virtual_memory_coordinator_test.cpp
  • tests/core/distributed_runtime/model_residency_coordinator_test.cpp
  • tests/core/distributed_runtime/worker_memory_rpc_bootstrap_test.cpp
  • tests/core/framework/CMakeLists.txt
  • tests/core/framework/allocator/CMakeLists.txt
  • tests/core/framework/allocator/mapped_virtual_memory_tensor_view_test.cpp
  • tests/core/framework/allocator/virtual_memory_test.cpp
  • tests/core/framework/allocator/virtual_memory_test_utils.h
  • tests/core/framework/allocator/worker_physical_page_budget_test.cpp
  • tests/core/framework/batch/CMakeLists.txt
  • tests/core/framework/batch/batch_factory_test.cpp
  • tests/core/framework/batch/batch_packed_input_test.cpp
  • tests/core/framework/batch/batch_test.cpp
  • tests/core/framework/batch/forward_input_factory_test.cpp
  • tests/core/framework/batch/rec_forward_input_factory_test.cpp
  • tests/core/framework/batch/vlm_forward_input_factory_test.cpp
  • tests/core/framework/block/CMakeLists.txt
  • tests/core/framework/block/block_manager_pool_test_peer.h
  • tests/core/framework/block/block_manager_test.cpp
  • tests/core/framework/block/composite_block_manager_test.cpp
  • tests/core/framework/block/embedding_block_manager_test.cpp
  • tests/core/framework/block/hierarchy_block_manager_pool_test.cpp
  • tests/core/framework/block/mtp_prefix_cache_test.cpp
  • tests/core/framework/config/config_json_test.cpp
  • tests/core/framework/config/config_test.json
  • tests/core/framework/hf_model_loader_test.cpp
  • tests/core/framework/kv_cache/CMakeLists.txt
  • tests/core/framework/model_loader/CMakeLists.txt
  • tests/core/framework/model_loader/weight/CMakeLists.txt
  • tests/core/framework/model_loader/weight/model_weight_allocator_test.cpp
  • tests/core/framework/model_loader/weight/weight_transfer_segments_test.cpp
  • tests/core/framework/request/CMakeLists.txt
  • tests/core/framework/request/sample_slot_test.cpp
  • tests/core/framework/transfer/CMakeLists.txt
  • tests/core/framework/transfer/mooncake_transfer_engine_test.cpp
  • tests/core/framework/xtensor/CMakeLists.txt
  • tests/core/framework/xtensor/page_allocator_test.cpp
  • tests/core/framework/xtensor/xtensor_bootstrap_test.cpp
  • tests/core/framework/xtensor/xtensor_test.cpp
  • tests/core/framework/xtensor/xtensor_weight_allocator_test.cpp
  • tests/core/kv_cache/CMakeLists.txt
  • tests/core/kv_cache/block/CMakeLists.txt
  • tests/core/kv_cache/block/concurrent_block_manager_test.cpp
  • tests/core/kv_cache/block/virtual_kv_cache_page_state_test.cpp
  • tests/core/kv_cache/layout/CMakeLists.txt
  • tests/core/kv_cache/layout/cache_layout_builder_test.cpp
  • tests/core/kv_cache/layout/kv_cache_estimation_test.cpp
  • tests/core/kv_cache/prefix/CMakeLists.txt
  • tests/core/kv_cache/prefix/linear_state_prefix_cache_test.cpp
  • tests/core/kv_cache/prefix/prefix_cache_test.cpp
  • tests/core/kv_cache/storage/CMakeLists.txt
  • tests/core/kv_cache/storage/kv_cache_test.cpp
  • tests/core/kv_cache/storage/virtual_kv_cache_memory_registry_test.cpp
  • tests/core/kv_cache/storage/virtual_kv_cache_page_allocator_impl_test.cpp
  • tests/core/kv_cache/transfer/CMakeLists.txt
  • tests/core/kv_cache/transfer/hierarchy_kv_cache_transfer_test.cpp
  • tests/core/kv_cache/transfer/host_transfer/basic_transfer_test.cpp
  • tests/core/kv_cache/transfer/host_transfer/compact_load_test.cpp
  • tests/core/kv_cache/transfer/host_transfer/compact_offload_test.cpp
  • tests/core/kv_cache/transfer/host_transfer/transfer_test.cpp
  • tests/core/kv_cache/transfer/kv_cache_store_test.cpp
  • tests/core/kv_cache/transfer/kv_transfer_completion_test.cpp
  • tests/core/kv_cache/transfer/mooncake_kv_cache_transfer_test.cpp
  • tests/core/kv_cache/transfer/pd_topology_guard_test.cpp
  • tests/core/kv_cache/transfer/push_route_test.cpp
  • tests/core/kv_cache/transfer/reshard_planner_test.cpp
  • tests/core/layers/cuda/rwkv7_decoder_layer_test.cpp
  • tests/core/layers/cuda/xattention_test.cpp
  • tests/core/layers/mlu/dcp_attention_merge_test.cpp
  • tests/core/layers/mlu/dcp_decode_context_test.cpp
  • tests/core/layers/mlu/dcp_indexer_candidate_test.cpp
  • tests/core/layers/mlu/deepseek_v2_attention_multi_device_test.cpp
  • tests/core/layers/mlu/deepseek_v2_decoder_layer_test.cpp
  • tests/core/layers/mlu/deepseek_v4_attention_test.cpp
  • tests/core/layers/mlu/deepseek_v4_decoder_layer_test.cpp
  • tests/core/layers/mlu/mla_test.cpp
  • tests/core/layers/mlu/qwen2_attention_test.cpp
  • tests/core/layers/mlu/qwen3_5_attention_test.cpp
  • tests/core/layers/mlu/qwen3_5_gated_delta_net_test.cpp
  • tests/core/platform/mlu/host_page_aligned_region_test.cpp
  • tests/core/platform/mlu/mlu_batch_memcpy_test.cpp
  • tests/core/runtime/CMakeLists.txt
  • tests/core/runtime/acl_graph_executor_test.cpp
  • tests/core/runtime/acl_graph_task_update_test.cpp
  • tests/core/runtime/dcu_graph_executor_test.cpp
  • tests/core/runtime/mlu_graph_executor_test.cpp
  • tests/core/runtime/mlu_linear_state_restore_worker_test.cpp
  • tests/core/runtime/mtp_host_offload_test.cpp
  • tests/core/runtime/slot_buffer_test.cpp
  • tests/core/runtime/worker_hierarchy_kv_cache_transfer_test.cpp
  • tests/core/runtime/worker_memory_resources_test.cpp
  • tests/core/scheduler/CMakeLists.txt
  • tests/core/scheduler/continuous_scheduler_test.cpp
  • tests/core/scheduler/disagg_pd_scheduler_test.cpp
  • tests/core/scheduler/profile/CMakeLists.txt
  • tests/core/scheduler/scheduler_policy_test.cpp
  • xllm/CMakeLists.txt
  • xllm/core/CMakeLists.txt
  • xllm/core/common/global_flags.h
  • xllm/core/common/types.h
  • xllm/core/distributed_runtime/CMakeLists.txt
  • xllm/core/distributed_runtime/comm_channel.h
  • xllm/core/distributed_runtime/disagg_pd_service.cpp
  • xllm/core/distributed_runtime/disagg_pd_service.h
  • xllm/core/distributed_runtime/disagg_pd_service_impl.cpp
  • xllm/core/distributed_runtime/disagg_pd_service_impl.h
  • xllm/core/distributed_runtime/distributed_virtual_memory_coordinator.cpp
  • xllm/core/distributed_runtime/distributed_virtual_memory_coordinator.h
  • xllm/core/distributed_runtime/distributed_worker_manager.h
  • xllm/core/distributed_runtime/engine.h
  • xllm/core/distributed_runtime/kv_cache_transfer_coordinator.h
  • xllm/core/distributed_runtime/llm_engine.cpp
  • xllm/core/distributed_runtime/llm_engine.h
  • xllm/core/distributed_runtime/llm_master.cpp
  • xllm/core/distributed_runtime/llm_master.h
  • xllm/core/distributed_runtime/master_factory.cpp
  • xllm/core/distributed_runtime/model_residency_coordinator.cpp
  • xllm/core/distributed_runtime/model_residency_coordinator.h
  • xllm/core/distributed_runtime/rec_engine.cpp
  • xllm/core/distributed_runtime/rec_engine.h
  • xllm/core/distributed_runtime/remote_worker.cpp
  • xllm/core/distributed_runtime/remote_worker.h
  • xllm/core/distributed_runtime/speculative_engine.cpp
  • xllm/core/distributed_runtime/speculative_engine.h
  • xllm/core/distributed_runtime/vlm_engine.cpp
  • xllm/core/distributed_runtime/vlm_master.cpp
  • xllm/core/distributed_runtime/vlm_master.h
  • xllm/core/distributed_runtime/worker_memory_rpc_client.cpp
  • xllm/core/distributed_runtime/worker_memory_rpc_client.h
  • xllm/core/distributed_runtime/worker_memory_rpc_options.h
  • xllm/core/distributed_runtime/worker_memory_rpc_server.cpp
  • xllm/core/distributed_runtime/worker_memory_rpc_server.h
  • xllm/core/distributed_runtime/worker_memory_rpc_service.cpp
  • xllm/core/distributed_runtime/worker_memory_rpc_service.h
  • xllm/core/distributed_runtime/worker_server.cpp
  • xllm/core/distributed_runtime/worker_service.cpp
  • xllm/core/framework/CMakeLists.txt
  • xllm/core/framework/allocator/CMakeLists.txt
  • xllm/core/framework/allocator/global_virtual_memory_region.cpp
  • xllm/core/framework/allocator/global_virtual_memory_region.h
  • xllm/core/framework/allocator/torch/CMakeLists.txt
  • xllm/core/framework/allocator/torch/mapped_virtual_memory_tensor_view.cpp
  • xllm/core/framework/allocator/torch/mapped_virtual_memory_tensor_view.h
  • xllm/core/framework/allocator/torch/mapped_virtual_memory_tensor_view_internal.h
  • xllm/core/framework/allocator/virtual_memory/CMakeLists.txt
  • xllm/core/framework/allocator/virtual_memory/mapped_virtual_memory_region.cpp
  • xllm/core/framework/allocator/virtual_memory/mapped_virtual_memory_region.h
  • xllm/core/framework/allocator/virtual_memory/physical_page.cpp
  • xllm/core/framework/allocator/virtual_memory/physical_page.h
  • xllm/core/framework/allocator/virtual_memory/physical_page_pool.cpp
  • xllm/core/framework/allocator/virtual_memory/physical_page_pool.h
  • xllm/core/framework/allocator/virtual_memory/shared_physical_page_mapping.cpp
  • xllm/core/framework/allocator/virtual_memory/shared_physical_page_mapping.h
  • xllm/core/framework/allocator/worker_physical_page_budget.cpp
  • xllm/core/framework/allocator/worker_physical_page_budget.h
  • xllm/core/framework/batch/batch_benchmark.cpp
  • xllm/core/framework/batch/beam_search.h
  • xllm/core/framework/batch/forward_input_builder.cpp
  • xllm/core/framework/block/CMakeLists.txt
  • xllm/core/framework/block/block_manager_pool.cpp
  • xllm/core/framework/block/block_manager_pool.h
  • xllm/core/framework/block/composite_block_manager.cpp
  • xllm/core/framework/block/composite_block_manager.h
  • xllm/core/framework/block/embedding_block_manager.cpp
  • xllm/core/framework/block/embedding_block_manager.h
  • xllm/core/framework/block/hierarchy_block_manager_pool.cpp
  • xllm/core/framework/block/hierarchy_block_manager_pool.h
  • xllm/core/framework/block/kv_cache_manager.h
  • xllm/core/framework/block/kv_cache_manager_factory.cpp
  • xllm/core/framework/block/kv_cache_manager_factory.h
  • xllm/core/framework/block/virtual_memory_kv_cache_block_manager.cpp
  • xllm/core/framework/block/virtual_memory_kv_cache_block_manager.h
  • xllm/core/framework/config/distributed_config.cpp
  • xllm/core/framework/config/distributed_config.h
  • xllm/core/framework/config/kv_cache_config.cpp
  • xllm/core/framework/config/kv_cache_config.h
  • xllm/core/framework/config/load_config.cpp
  • xllm/core/framework/config/parallel_config_validation.cpp
  • xllm/core/framework/kv_cache/CMakeLists.txt
  • xllm/core/framework/kv_cache/linear_state_restore.h
  • xllm/core/framework/kv_cache_transfer/mooncake_transfer_engine.cpp
  • xllm/core/framework/kv_cache_transfer/mooncake_transfer_engine.h
  • xllm/core/framework/model/causal_lm.h
  • xllm/core/framework/model/causal_vlm.h
  • xllm/core/framework/model/model_input_types.h
  • xllm/core/framework/model_context/model_context.h
  • xllm/core/framework/model_loader/CMakeLists.txt
  • xllm/core/framework/model_loader/model_loader.h
  • xllm/core/framework/model_loader/weight/CMakeLists.txt
  • xllm/core/framework/model_loader/weight/model_weight_store.cpp
  • xllm/core/framework/model_loader/weight/model_weight_store.h
  • xllm/core/framework/model_loader/weight/mooncake_weight_transfer.cpp
  • xllm/core/framework/model_loader/weight/mooncake_weight_transfer.h
  • xllm/core/framework/model_loader/weight/weight_allocation.cpp
  • xllm/core/framework/model_loader/weight/weight_allocation.h
  • xllm/core/framework/model_loader/weight/weight_page_coordinator.cpp
  • xllm/core/framework/model_loader/weight/weight_page_coordinator.h
  • xllm/core/framework/model_loader/weight/weight_transfer_segments.h
  • xllm/core/framework/model_loader/weight/weight_virtual_memory_manager.cpp
  • xllm/core/framework/model_loader/weight/weight_virtual_memory_manager.h
  • xllm/core/framework/request/CMakeLists.txt
  • xllm/core/framework/request/sequence.cpp
  • xllm/core/framework/request/sequence.h
  • xllm/core/framework/request/sequence_kv_state.h
  • xllm/core/framework/transfer/CMakeLists.txt
  • xllm/core/framework/transfer/byte_region.h
  • xllm/core/framework/transfer/mooncake_session_service.cpp
  • xllm/core/framework/transfer/mooncake_session_service.h
  • xllm/core/framework/transfer/mooncake_transfer_engine.cpp
  • xllm/core/framework/transfer/mooncake_transfer_engine.h
  • xllm/core/framework/xtensor/CMakeLists.txt
  • xllm/core/framework/xtensor/global_xtensor.h
  • xllm/core/framework/xtensor/model_memory_store.h
  • xllm/core/framework/xtensor/page_allocator.cpp
  • xllm/core/framework/xtensor/page_allocator.h
  • xllm/core/framework/xtensor/xtensor.cpp
  • xllm/core/framework/xtensor/xtensor.h
  • xllm/core/framework/xtensor/xtensor_allocator.cpp
  • xllm/core/framework/xtensor/xtensor_allocator.h
  • xllm/core/framework/xtensor/xtensor_cluster.cpp
  • xllm/core/framework/xtensor/xtensor_cluster.h
  • xllm/core/kv_cache/CMakeLists.txt
  • xllm/core/kv_cache/block/CMakeLists.txt
  • xllm/core/kv_cache/block/block.cpp
  • xllm/core/kv_cache/block/block.h
  • xllm/core/kv_cache/block/block_manager.cpp
  • xllm/core/kv_cache/block/block_manager.h
  • xllm/core/kv_cache/block/block_manager_impl.cpp
  • xllm/core/kv_cache/block/block_manager_impl.h
  • xllm/core/kv_cache/block/block_utils.cpp
  • xllm/core/kv_cache/block/block_utils.h
  • xllm/core/kv_cache/block/concurrent_block_manager_impl.cpp
  • xllm/core/kv_cache/block/concurrent_block_manager_impl.h
  • xllm/core/kv_cache/block/linear_state_block_manager.cpp
  • xllm/core/kv_cache/block/linear_state_block_manager.h
  • xllm/core/kv_cache/block/sliding_window_block_manager.cpp
  • xllm/core/kv_cache/block/sliding_window_block_manager.h
  • xllm/core/kv_cache/block/virtual_kv_cache_page_state.cpp
  • xllm/core/kv_cache/block/virtual_kv_cache_page_state.h
  • xllm/core/kv_cache/layout/cache_layout_builder.cpp
  • xllm/core/kv_cache/layout/cache_layout_builder.h
  • xllm/core/kv_cache/layout/cache_layout_types.h
  • xllm/core/kv_cache/layout/deepseek_v4_cache_policy.h
  • xllm/core/kv_cache/layout/kv_cache_capacity.h
  • xllm/core/kv_cache/layout/kv_cache_estimation.cpp
  • xllm/core/kv_cache/layout/kv_cache_estimation.h
  • xllm/core/kv_cache/layout/kv_cache_shape.cpp
  • xllm/core/kv_cache/layout/kv_cache_shape.h
  • xllm/core/kv_cache/layout/kv_cache_tensor_role.h
  • xllm/core/kv_cache/layout/kv_shard_layout.cpp
  • xllm/core/kv_cache/layout/kv_shard_layout.h
  • xllm/core/kv_cache/layout/layerwise_split_layout.h
  • xllm/core/kv_cache/prefix/CMakeLists.txt
  • xllm/core/kv_cache/prefix/block_hasher.cpp
  • xllm/core/kv_cache/prefix/block_hasher.h
  • xllm/core/kv_cache/prefix/linear_state_prefix_cache.cpp
  • xllm/core/kv_cache/prefix/linear_state_prefix_cache.h
  • xllm/core/kv_cache/prefix/prefix_cache.cpp
  • xllm/core/kv_cache/prefix/prefix_cache.h
  • xllm/core/kv_cache/prefix/prefix_cache_benchmark.cpp
  • xllm/core/kv_cache/prefix/prefix_cache_factory.cpp
  • xllm/core/kv_cache/prefix/prefix_cache_factory.h
  • xllm/core/kv_cache/storage/deepseek_v4_kv_cache_impl.cpp
  • xllm/core/kv_cache/storage/deepseek_v4_kv_cache_impl.h
  • xllm/core/kv_cache/storage/indexed_kv_cache_impl.cpp
  • xllm/core/kv_cache/storage/indexed_kv_cache_impl.h
  • xllm/core/kv_cache/storage/kpool_kv_cache_impl.cpp
  • xllm/core/kv_cache/storage/kpool_kv_cache_impl.h
  • xllm/core/kv_cache/storage/kv_cache.cpp
  • xllm/core/kv_cache/storage/kv_cache.h
  • xllm/core/kv_cache/storage/kv_cache_impl.cpp
  • xllm/core/kv_cache/storage/kv_cache_impl.h
  • xllm/core/kv_cache/storage/kv_cache_page_backend.h
  • xllm/core/kv_cache/storage/kv_cache_tensor_allocator.cpp
  • xllm/core/kv_cache/storage/kv_cache_tensor_allocator.h
  • xllm/core/kv_cache/storage/kv_cache_utils.cpp
  • xllm/core/kv_cache/storage/kv_cache_utils.h
  • xllm/core/kv_cache/storage/linear_attention_kv_cache_impl.cpp
  • xllm/core/kv_cache/storage/linear_attention_kv_cache_impl.h
  • xllm/core/kv_cache/storage/quantized_kv_cache_impl.cpp
  • xllm/core/kv_cache/storage/quantized_kv_cache_impl.h
  • xllm/core/kv_cache/storage/virtual_kv_cache_memory_regions.cpp
  • xllm/core/kv_cache/storage/virtual_kv_cache_memory_regions.h
  • xllm/core/kv_cache/storage/virtual_kv_cache_memory_registry.cpp
  • xllm/core/kv_cache/storage/virtual_kv_cache_memory_registry.h
  • xllm/core/kv_cache/storage/virtual_kv_cache_page_allocator.h
  • xllm/core/kv_cache/storage/virtual_kv_cache_page_allocator_impl.cpp
  • xllm/core/kv_cache/storage/virtual_kv_cache_page_allocator_impl.h
  • xllm/core/kv_cache/storage/virtual_kv_cache_tensor_allocator.cpp
  • xllm/core/kv_cache/storage/virtual_kv_cache_tensor_allocator.h
  • xllm/core/kv_cache/transfer/CMakeLists.txt
  • xllm/core/kv_cache/transfer/cache_layout.cpp
  • xllm/core/kv_cache/transfer/cache_layout.h
  • xllm/core/kv_cache/transfer/hierarchy_kv_cache_transfer.cpp
  • xllm/core/kv_cache/transfer/hierarchy_kv_cache_transfer.h
  • xllm/core/kv_cache/transfer/host_transfer/basic_transfer.cpp
  • xllm/core/kv_cache/transfer/host_transfer/basic_transfer.h
  • xllm/core/kv_cache/transfer/host_transfer/compact_load_executor.cpp
  • xllm/core/kv_cache/transfer/host_transfer/compact_load_executor.h
  • xllm/core/kv_cache/transfer/host_transfer/compact_offload_executor.cpp
  • xllm/core/kv_cache/transfer/host_transfer/compact_offload_executor.h
  • xllm/core/kv_cache/transfer/host_transfer/compact_transfer.cpp
  • xllm/core/kv_cache/transfer/host_transfer/compact_transfer.h
  • xllm/core/kv_cache/transfer/host_transfer/layout.cpp
  • xllm/core/kv_cache/transfer/host_transfer/layout.h
  • xllm/core/kv_cache/transfer/host_transfer/transfer.cpp
  • xllm/core/kv_cache/transfer/host_transfer/transfer.h
  • xllm/core/kv_cache/transfer/host_transfer/transfer_utils.cpp
  • xllm/core/kv_cache/transfer/host_transfer/transfer_utils.h
  • xllm/core/kv_cache/transfer/kv_cache_store.cpp
  • xllm/core/kv_cache/transfer/kv_cache_store.h
  • xllm/core/kv_cache/transfer/kv_cache_transfer.cpp
  • xllm/core/kv_cache/transfer/kv_cache_transfer.h
  • xllm/core/kv_cache/transfer/kv_cache_transfer_coordinator_base.h
  • xllm/core/kv_cache/transfer/kv_transfer_completion.cpp
  • xllm/core/kv_cache/transfer/kv_transfer_completion.h
  • xllm/core/kv_cache/transfer/mooncake_kv_cache_transfer.cpp
  • xllm/core/kv_cache/transfer/mooncake_kv_cache_transfer.h
  • xllm/core/kv_cache/transfer/mooncake_kv_cache_transfer_engine.cpp
  • xllm/core/kv_cache/transfer/mooncake_kv_cache_transfer_engine.h
  • xllm/core/kv_cache/transfer/mooncake_store_backend.cpp
  • xllm/core/kv_cache/transfer/mooncake_store_backend.h
  • xllm/core/kv_cache/transfer/pd_topology_guard.cpp
  • xllm/core/kv_cache/transfer/pd_topology_guard.h
  • xllm/core/kv_cache/transfer/prefetch_result.h
  • xllm/core/kv_cache/transfer/push_route.cpp
  • xllm/core/kv_cache/transfer/push_route.h
  • xllm/core/kv_cache/transfer/reshard_planner.cpp
  • xllm/core/kv_cache/transfer/reshard_planner.h
  • xllm/core/kv_cache/transfer/virtual_kv_cache_transfer_memory_provider.h
  • xllm/core/kv_cache/transfer/virtual_kv_cache_transfer_memory_provider_impl.cpp
  • xllm/core/kv_cache/transfer/virtual_kv_cache_transfer_memory_provider_impl.h
  • xllm/core/layers/common/attention_metadata_builder.h
  • xllm/core/layers/common/kv_shard_batch_metadata.h
  • xllm/core/layers/common/qwen2_attention.h
  • xllm/core/layers/cuda/attention.h
  • xllm/core/layers/cuda/base_attention_impl.h
  • xllm/core/layers/cuda/flashinfer_attention.cpp
  • xllm/core/layers/cuda/flashinfer_attention.h
  • xllm/core/layers/cuda/xattention.cpp
  • xllm/core/layers/cuda/xattention.h
  • xllm/core/layers/dcu/attention.h
  • xllm/core/layers/dcu/base_attention_impl.h
  • xllm/core/layers/dcu/deepseek_v2_attention.h
  • xllm/core/layers/dcu/deepseek_v2_decoder_layer_impl.h
  • xllm/core/layers/dcu/flash_attention.cpp
  • xllm/core/layers/dcu/flash_attention.h
  • xllm/core/layers/dcu/qwen3_5_decoder_layer.h
  • xllm/core/layers/dcu/qwen3_gated_delta_net_base.h
  • xllm/core/layers/dcu/torch_attention.cpp
  • xllm/core/layers/dcu/torch_attention.h
  • xllm/core/layers/deepseek_v4_decoder_layer.h
  • xllm/core/layers/ilu/attention.h
  • xllm/core/layers/minimax_m2_attention.h
  • xllm/core/layers/minimax_m2_decoder_layer.h
  • xllm/core/layers/mlu/attention.h
  • xllm/core/layers/mlu/dcp_decode_context.h
  • xllm/core/layers/mlu/deepseek_v2_attention.h
  • xllm/core/layers/mlu/deepseek_v2_decoder_layer_impl.h
  • xllm/core/layers/mlu/deepseek_v32_cp_context.h
  • xllm/core/layers/mlu/deepseek_v4/deepseek_v4_attention.h
  • xllm/core/layers/mlu/deepseek_v4/deepseek_v4_decoder_layer.h
  • xllm/core/layers/mlu/glm5_next/glm5_next_decoder_layer.cpp
  • xllm/core/layers/mlu/glm5_next/glm5_next_decoder_layer.h
  • xllm/core/layers/mlu/glm5_next/glm5_next_kda.cpp
  • xllm/core/layers/mlu/glm5_next/glm5_next_kda.h
  • xllm/core/layers/mlu/indexer.h
  • xllm/core/layers/mlu/qwen3_5/qwen3_5_attention.h
  • xllm/core/layers/mlu/qwen3_5/qwen3_5_decoder_layer.h
  • xllm/core/layers/mlu/qwen3_5/qwen3_5_gated_delta_net.cpp
  • xllm/core/layers/mlu/qwen3_5/qwen3_5_gated_delta_net.h
  • xllm/core/layers/mlu/qwen3_5/qwen3_5_hybrid_decoder_layer_base.h
  • xllm/core/layers/musa/attention.h
  • xllm/core/layers/musa/flashinfer_attention.cpp
  • xllm/core/layers/musa/flashinfer_attention.h
  • xllm/core/layers/musa/qwen3_gated_delta_net_base.h
  • xllm/core/layers/musa/qwen3_next_attention.h
  • xllm/core/layers/musa/qwen3_next_hybrid_decoder_layer_base.h
  • xllm/core/layers/npu/CMakeLists.txt
  • xllm/core/layers/npu/loader/base_loader.cpp
  • xllm/core/layers/npu/loader/base_loader.h
  • xllm/core/layers/npu/loader/rolling_weight_buffer.cpp
  • xllm/core/layers/npu/loader/rolling_weight_buffer.h
  • xllm/core/layers/npu/npu_base_layer.h
  • xllm/core/layers/npu/npu_eagle3_decoder_layer_impl.h
  • xllm/core/layers/npu/npu_glm4_decoder_layer_impl.h
  • xllm/core/layers/npu/npu_llama_decoder_layer_impl.h
  • xllm/core/layers/npu/npu_mistral_decoder_layer_impl.h
  • xllm/core/layers/npu/npu_qwen2_decoder_layer_impl.h
  • xllm/core/layers/npu/npu_qwen3_decoder_layer_impl.h
  • xllm/core/layers/npu/npu_rms_norm_impl.h
  • xllm/core/layers/npu_torch/attention.h
  • xllm/core/layers/npu_torch/deepseek_sparse_attention.h
  • xllm/core/layers/npu_torch/qwen3_gated_delta_net_base.h
  • xllm/core/layers/npu_torch/qwen3_next_attention.h
  • xllm/core/layers/npu_torch/qwen3_next_hybrid_decoder_layer_base.h
  • xllm/core/layers/onerec_block_layer.h
  • xllm/core/layers/qwen2_decoder_layer.h
  • xllm/core/layers/qwen3_moe_decoder_layer.h
  • xllm/core/layers/rwkv7_decoder_layer.h
  • xllm/core/layers/xlite/xlite_attn_meta_builder.h
  • xllm/core/layers/xlite/xlite_causal_lm_base.h
  • xllm/core/platform/vmm_api.cpp
  • xllm/core/runtime/CMakeLists.txt
  • xllm/core/runtime/acl_graph_executor_impl.cpp
  • xllm/core/runtime/acl_graph_executor_impl.h
  • xllm/core/runtime/base_executor_impl.h
  • xllm/core/runtime/cuda_graph_executor_impl.h
  • xllm/core/runtime/dcu_graph_executor_impl.h
  • xllm/core/runtime/dflash_worker_impl.cpp
  • xllm/core/runtime/dflash_worker_impl.h
  • xllm/core/runtime/draft_model_spec_worker_impl.cpp
  • xllm/core/runtime/embed_vlm_worker_impl.cpp
  • xllm/core/runtime/embed_worker_impl.cpp
  • xllm/core/runtime/executor.h
  • xllm/core/runtime/executor_impl.h
  • xllm/core/runtime/forward_shared_memory_manager.cpp
  • xllm/core/runtime/llm_worker_impl.cpp
  • xllm/core/runtime/mlu_graph_executor_impl.h
  • xllm/core/runtime/mm_embed_vlm_worker_impl.cpp
  • xllm/core/runtime/mtp_worker_impl.cpp
  • xllm/core/runtime/musa_graph_executor_impl.h
  • xllm/core/runtime/params_utils.h
  • xllm/core/runtime/py_executor_impl.h
  • xllm/core/runtime/speculative_worker_impl.cpp
  • xllm/core/runtime/task_execution_pipeline.cpp
  • xllm/core/runtime/task_execution_pipeline_speculative.cpp
  • xllm/core/runtime/vlm_executor_impl.h
  • xllm/core/runtime/vlm_worker_impl.cpp
  • xllm/core/runtime/worker.cpp
  • xllm/core/runtime/worker.h
  • xllm/core/runtime/worker_client.cpp
  • xllm/core/runtime/worker_client.h
  • xllm/core/runtime/worker_impl.cpp
  • xllm/core/runtime/worker_impl.h
  • xllm/core/runtime/worker_memory_resources.cpp
  • xllm/core/runtime/worker_memory_resources.h
  • xllm/core/runtime/worker_rendezvous.cpp
  • xllm/core/runtime/xlite_executor_impl.h
  • xllm/core/scheduler/CMakeLists.txt
  • xllm/core/scheduler/continuous_scheduler.cpp
  • xllm/core/scheduler/continuous_scheduler.h
  • xllm/core/scheduler/continuous_scheduler_benchmark.cpp
  • xllm/core/scheduler/disagg_pd_scheduler.cpp
  • xllm/core/scheduler/disagg_pd_scheduler.h
  • xllm/core/scheduler/scheduler_factory.h
  • xllm/core/scheduler/zero_eviction_scheduler.h
  • xllm/core/util/tensor_helper.h
  • xllm/models/dit/encoders/clip_text_model.h
  • xllm/models/dit/pipelines/pipeline_joyimage_edit_plus.h
  • xllm/models/llm/deepseek_v2.h
  • xllm/models/llm/llm_model_base.h
  • xllm/models/llm/npu/llm_model_base.h
  • xllm/models/llm/npu/mistral.h
  • xllm/models/llm/npu/mtp_model_base.h
  • xllm/models/llm/npu/qwen3_eagle3.h
  • xllm/models/llm/qwen3_next_hybrid_base.h
  • xllm/models/llm/rwkv7.h
  • xllm/models/model_registry.cpp
  • xllm/models/rec/rec_model_base.h
  • xllm/models/vlm/npu/glm4v.h
  • xllm/models/vlm/npu/glm4v_moe.h
  • xllm/models/vlm/npu/kimi_k25.h
  • xllm/models/vlm/npu/minicpmv.h
  • xllm/models/vlm/npu/mistral3.h
  • xllm/models/vlm/npu/oxygen_vlm.h
  • xllm/models/vlm/npu/qwen2_5_vl.h
  • xllm/models/vlm/npu/qwen2_vl.h
  • xllm/models/vlm/npu/qwen3_vl.h
  • xllm/models/vlm/npu/qwen3_vl_moe.h
  • xllm/processors/multimodal_processor.cpp
  • xllm/proto/CMakeLists.txt
  • xllm/proto/disagg_pd.proto
  • xllm/proto/model_memory_dist.proto
  • xllm/proto/mooncake_transfer_engine.proto
  • xllm/proto/worker.proto
  • xllm/proto/xservice.proto
  • xllm/server/xllm_server.cpp
  • xllm/xllm.cpp

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@liutongxuan liutongxuan changed the title Features/kv cache refactor refactor: extract shared virtual memory primitives. Oct 10, 2026
@liutongxuan
liutongxuan force-pushed the features/kv_cache_refactor branch 2 times, most recently from b36fca1 to 72baefc Compare October 11, 2026 13:56
Comment thread xllm/core/framework/model_loader/weight/mooncake_weight_transfer.cpp Outdated
Comment thread xllm/core/framework/model_loader/weight/mooncake_weight_transfer.cpp Outdated
Comment thread xllm/core/kv_cache/storage/kv_cache_memory_regions.h Outdated
@XuZhang99

Copy link
Copy Markdown
Collaborator

@codex

Comment thread docs/src/content/docs/en/dev_guide/code_arch.md
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Failed to sample tokens
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@liutongxuan
liutongxuan force-pushed the features/kv_cache_refactor branch from 72baefc to 32218a2 Compare October 12, 2026 02:55
Comment thread xllm/core/runtime/worker_memory_resources.cpp Outdated
Comment thread xllm/core/runtime/forward_shared_memory_manager.cpp Outdated
Comment thread xllm/core/framework/block/composite_block_manager.cpp Outdated
Comment thread xllm/core/framework/block/composite_block_manager.cpp Outdated
@liutongxuan
liutongxuan force-pushed the features/kv_cache_refactor branch 2 times, most recently from 66df8c9 to d8dc205 Compare October 12, 2026 12:38
- Synchronize English and Chinese directory maps and architecture diagrams.
- Explain injected KV backends, weight ownership, mapping leases and shared RPC compatibility.
- Record the remaining Sequence and configuration coupling for subsequent slices.
- Keep worker-local resources in runtime and distributed dispatch in explicit coordinators and RPC classes.
- Move KV page queues and preallocation behind an injected mapping backend in kv_cache storage.
- Reserve KV and weight wakeup capacity atomically and drain pending mappings before suspension.
- Migrate consumers, test targets, and architecture documentation while preserving the RPC wire schema.
- rename the memory RPC registration address to worker_memory_master_node_addr
- use the virtual_memory KV layout signature and synchronize docs and tests
- keep capability flag splitting for a separate pull request
- Open and close weight data sessions without using the Mooncake data
  endpoint as a BRPC control endpoint.
- Use ScalarType throughout the mapped-memory tensor and KV cache APIs.
- Remove the outdated directory listing from AGENTS.md.
@liutongxuan
liutongxuan force-pushed the features/kv_cache_refactor branch from d8dc205 to 80e01e7 Compare October 12, 2026 14:38
Comment thread xllm/core/framework/allocator/global_memory_region.h Outdated
Comment thread xllm/core/distributed_runtime/disagg_pd_service_impl.cpp Outdated
Comment thread xllm/core/distributed_runtime/distributed_memory_coordinator.h Outdated
Comment thread xllm/core/framework/allocator/torch/mapped_memory_tensor_view.cpp Outdated
Comment thread xllm/core/framework/allocator/virtual_memory/mapped_memory_region.h Outdated
Comment thread xllm/core/kv_cache/transfer/kv_cache_transfer_memory_provider.h Outdated
Comment thread xllm/core/kv_cache/transfer/kv_cache_transfer_memory_provider.h Outdated
Comment thread xllm/core/kv_cache/transfer/mooncake_kv_cache_transfer.cpp Outdated
Comment thread xllm/core/kv_cache/transfer/mooncake_kv_cache_transfer.h Outdated
Comment thread xllm/core/kv_cache/block/kv_cache_page_state.h Outdated
@liutongxuan
liutongxuan force-pushed the features/kv_cache_refactor branch from bb4adc4 to 9ff71fb Compare October 13, 2026 08:04
Comment thread xllm/core/distributed_runtime/disagg_pd_service_impl.cpp Outdated
Comment thread xllm/core/distributed_runtime/worker_memory_rpc_service.h Outdated
Comment thread xllm/core/distributed_runtime/worker_memory_rpc_service.h Outdated
Comment thread xllm/core/framework/allocator/torch/mapped_memory_tensor_view.cpp Outdated
Comment thread xllm/core/framework/allocator/virtual_memory/shared_page_mapping.h Outdated
- Distinguish virtual mappings and physical page budgets across cache,
  weight, runtime and protocol APIs while preserving protobuf field tags.
- Reuse external tensor construction with an explicit device and preserve
  empty-view storage and legacy caller behavior.
- Isolate device tests and move tensor validation death tests to a
  host-only target whose fixture permits GoogleTest inheritance.
- Align sampling tests with separate model and sampling storage accounting.
- Clarify KV block token units and consistently name virtual KV offset RPCs,
  mapped tensor views and shared physical page mappings.
@liutongxuan
liutongxuan force-pushed the features/kv_cache_refactor branch from 9ff71fb to edbe940 Compare October 13, 2026 09:30
@liutongxuan
liutongxuan merged commit 5de8be4 into xLLM-AI:main Oct 13, 2026
7 of 18 checks passed
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