Mooncake: sglang with mooncake prefill node fail with 'Failed to register memory' error

sglang and mooncake version:

mooncake-transfer-engine                 0.3.0b5
sglang                                   0.4.5.post2         /sgl-workspace/sglang/python

my gpu environment is:

Mon Apr 21 17:33:33 2025
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.125.06   Driver Version: 525.125.06   CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA A800-SXM...  Off  | 00000000:10:00.0 Off |                    0 |
| N/A   41C    P0    65W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   1  NVIDIA A800-SXM...  Off  | 00000000:16:00.0 Off |                    0 |
| N/A   37C    P0    61W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   2  NVIDIA A800-SXM...  Off  | 00000000:2A:00.0 Off |                    0 |
| N/A   37C    P0    64W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   3  NVIDIA A800-SXM...  Off  | 00000000:2E:00.0 Off |                    0 |
| N/A   38C    P0    63W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   4  NVIDIA A800-SXM...  Off  | 00000000:B7:00.0 Off |                    0 |
| N/A   38C    P0    65W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   5  NVIDIA A800-SXM...  Off  | 00000000:BC:00.0 Off |                    0 |
| N/A   40C    P0    66W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   6  NVIDIA A800-SXM...  Off  | 00000000:D0:00.0 Off |                    0 |
| N/A   37C    P0    63W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+
|   7  NVIDIA A800-SXM...  Off  | 00000000:D4:00.0 Off |                    0 |
| N/A   40C    P0    65W / 400W |      3MiB / 81920MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

prefill start command:

python3 -m sglang.launch_server --model-path /Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4 --disaggregation-mode prefill --port 30000 --host ${ip} --tp-size 2

and the error log is:

INFO 04-21 09:34:25 [__init__.py:239] Automatically detected platform cuda.
KV cache is forced as chunk cache for decode server
Overlap scheduler is disabled for prefill server
[2025-04-21 09:34:28] server_args=ServerArgs(model_path='/Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4', tokenizer_path='/Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4', tokenizer_mode='auto', skip_tokenizer_init=False, enable_tokenizer_batch_encode=False, load_format='auto', trust_remote_code=False, dtype='auto', kv_cache_dtype='auto', quantization=None, quantization_param_path=None, context_length=None, device='cuda', served_model_name='/Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4', chat_template=None, completion_template=None, is_embedding=False, revision=None, host='30.246.242.155', port=30000, mem_fraction_static=0.87, max_running_requests=None, max_total_tokens=None, chunked_prefill_size=8192, max_prefill_tokens=16384, schedule_policy='fcfs', schedule_conservativeness=1.0, cpu_offload_gb=0, page_size=1, tp_size=2, stream_interval=1, stream_output=False, random_seed=777934954, constrained_json_whitespace_pattern=None, watchdog_timeout=300, dist_timeout=None, download_dir=None, base_gpu_id=0, gpu_id_step=1, log_level='info', log_level_http=None, log_requests=False, log_requests_level=0, show_time_cost=False, enable_metrics=False, decode_log_interval=40, api_key=None, file_storage_path='sglang_storage', enable_cache_report=False, reasoning_parser=None, dp_size=1, load_balance_method='round_robin', ep_size=1, dist_init_addr=None, nnodes=1, node_rank=0, json_model_override_args='{}', lora_paths=None, max_loras_per_batch=8, lora_backend='triton', attention_backend=None, sampling_backend='flashinfer', grammar_backend='xgrammar', speculative_algorithm=None, speculative_draft_model_path=None, speculative_num_steps=None, speculative_eagle_topk=None, speculative_num_draft_tokens=None, speculative_accept_threshold_single=1.0, speculative_accept_threshold_acc=1.0, speculative_token_map=None, enable_double_sparsity=False, ds_channel_config_path=None, ds_heavy_channel_num=32, ds_heavy_token_num=256, ds_heavy_channel_type='qk', ds_sparse_decode_threshold=4096, disable_radix_cache=False, disable_cuda_graph=True, disable_cuda_graph_padding=False, enable_nccl_nvls=False, disable_outlines_disk_cache=False, disable_custom_all_reduce=False, enable_llama4_multimodal=None, disable_overlap_schedule=True, enable_mixed_chunk=False, enable_dp_attention=False, enable_ep_moe=False, enable_deepep_moe=False, deepep_mode='auto', enable_torch_compile=False, torch_compile_max_bs=32, cuda_graph_max_bs=160, cuda_graph_bs=None, torchao_config='', enable_nan_detection=False, enable_p2p_check=False, triton_attention_reduce_in_fp32=False, triton_attention_num_kv_splits=8, num_continuous_decode_steps=1, delete_ckpt_after_loading=False, enable_memory_saver=False, allow_auto_truncate=False, enable_custom_logit_processor=False, tool_call_parser=None, enable_hierarchical_cache=False, hicache_ratio=2.0, flashinfer_mla_disable_ragged=False, warmups=None, moe_dense_tp_size=None, n_share_experts_fusion=0, disable_chunked_prefix_cache=False, disable_fast_image_processor=False, debug_tensor_dump_output_folder=None, debug_tensor_dump_input_file=None, debug_tensor_dump_inject=False, disaggregation_mode='prefill', disaggregation_bootstrap_port=8998, disaggregation_transfer_backend='mooncake', disaggregation_ib_device=None)
[2025-04-21 09:34:28] The model is convertible to gptq_marlin during runtime. Using gptq_marlin kernel.
INFO 04-21 09:34:32 [__init__.py:239] Automatically detected platform cuda.
INFO 04-21 09:34:32 [__init__.py:239] Automatically detected platform cuda.
INFO 04-21 09:34:32 [__init__.py:239] Automatically detected platform cuda.
[2025-04-21 09:34:34 TP1] The model is convertible to gptq_marlin during runtime. Using gptq_marlin kernel.
[2025-04-21 09:34:34 TP0] The model is convertible to gptq_marlin during runtime. Using gptq_marlin kernel.
[2025-04-21 09:34:35 TP1] The model is convertible to gptq_marlin during runtime. Using gptq_marlin kernel.
[2025-04-21 09:34:35 TP1] Attention backend not set. Use flashinfer backend by default.
[2025-04-21 09:34:35 TP1] Init torch distributed begin.
[2025-04-21 09:34:35 TP0] The model is convertible to gptq_marlin during runtime. Using gptq_marlin kernel.
[2025-04-21 09:34:35 TP0] Attention backend not set. Use flashinfer backend by default.
[2025-04-21 09:34:35 TP0] Init torch distributed begin.
[2025-04-21 09:34:35 TP0] sglang is using nccl==2.21.5
[2025-04-21 09:34:35 TP1] sglang is using nccl==2.21.5
[2025-04-21 09:34:35 TP0] Init torch distributed ends. mem usage=0.87 GB
[2025-04-21 09:34:35 TP1] Init torch distributed ends. mem usage=0.87 GB
[2025-04-21 09:34:35 TP0] Load weight begin. avail mem=78.05 GB
[2025-04-21 09:34:35 TP1] Load weight begin. avail mem=78.05 GB
INFO 04-21 09:34:36 [gptq_marlin.py:235] Using MarlinLinearKernel for GPTQMarlinLinearMethod
INFO 04-21 09:34:36 [gptq_marlin.py:235] Using MarlinLinearKernel for GPTQMarlinLinearMethod
Loading safetensors checkpoint shards:   0% Completed | 0/2 [00:00<?, ?it/s]
Loading safetensors checkpoint shards:  50% Completed | 1/2 [00:00<00:00,  1.02it/s]
Loading safetensors checkpoint shards: 100% Completed | 2/2 [00:01<00:00,  1.62it/s]
Loading safetensors checkpoint shards: 100% Completed | 2/2 [00:01<00:00,  1.49it/s]

[2025-04-21 09:34:38 TP1] Load weight end. type=Qwen2ForCausalLM, dtype=torch.float16, avail mem=75.35 GB, mem usage=2.70 GB.
[2025-04-21 09:34:38 TP0] Load weight end. type=Qwen2ForCausalLM, dtype=torch.float16, avail mem=75.35 GB, mem usage=2.70 GB.
[2025-04-21 09:34:38 TP0] KV Cache is allocated. #tokens: 2440407, K size: 32.58 GB, V size: 32.58 GB
[2025-04-21 09:34:38 TP1] KV Cache is allocated. #tokens: 2440407, K size: 32.58 GB, V size: 32.58 GB
[2025-04-21 09:34:38 TP0] Memory pool end. avail mem=9.64 GB
[2025-04-21 09:34:38 TP1] Memory pool end. avail mem=9.64 GB
[2025-04-21 09:34:38 TP0]

CUDA Graph is DISABLED.
This will cause significant performance degradation.
CUDA Graph should almost never be disabled in most usage scenarios.
If you encounter OOM issues, please try setting --mem-fraction-static to a lower value (such as 0.8 or 0.7) instead of disabling CUDA Graph.

[2025-04-21 09:34:38 TP1]

CUDA Graph is DISABLED.
This will cause significant performance degradation.
CUDA Graph should almost never be disabled in most usage scenarios.
If you encounter OOM issues, please try setting --mem-fraction-static to a lower value (such as 0.8 or 0.7) instead of disabling CUDA Graph.

[2025-04-21 09:34:39 TP1] max_total_num_tokens=2440407, chunked_prefill_size=8192, max_prefill_tokens=16384, max_running_requests=4097, context_len=32768
[2025-04-21 09:34:39 TP0] max_total_num_tokens=2440407, chunked_prefill_size=8192, max_prefill_tokens=16384, max_running_requests=4097, context_len=32768
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0421 09:34:39.682588  4671 transfer_engine.cpp:86] Transfer Engine uses address 30.246.219.248 and port 16519 for serving local TCP service
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0421 09:34:39.685037  4670 transfer_engine.cpp:86] Transfer Engine uses address 30.246.219.248 and port 15696 for serving local TCP service
I0421 09:34:39.688733  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_5/
I0421 09:34:39.689913  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_5, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:2f
I0421 09:34:39.693037  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_6/
I0421 09:34:39.694192  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_6, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:5e
I0421 09:34:39.697597  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_7/
I0421 09:34:39.698680  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_5/
I0421 09:34:39.698740  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_7, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:be
I0421 09:34:39.699321  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_5, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:2f
I0421 09:34:39.701891  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_8/
I0421 09:34:39.702389  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_6/
I0421 09:34:39.703015  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_6, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:5e
I0421 09:34:39.703029  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_8, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:f8
I0421 09:34:39.706074  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_7/
I0421 09:34:39.706264  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_0/
I0421 09:34:39.706709  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_7, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:be
I0421 09:34:39.707089  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_0, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:f2:9b
I0421 09:34:39.710026  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_8/
I0421 09:34:39.710624  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_8, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:db:f8
I0421 09:34:39.711242  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_1/
I0421 09:34:39.712035  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_1, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:0c
I0421 09:34:39.713668  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_0/
I0421 09:34:39.714257  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_0, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:f2:9b
I0421 09:34:39.716200  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_2/
I0421 09:34:39.717345  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_1/
I0421 09:34:39.717381  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_2, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:74
I0421 09:34:39.717960  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_1, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:0c
I0421 09:34:39.721074  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_2/
I0421 09:34:39.721693  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_2, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:74
I0421 09:34:39.721833  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_3/
I0421 09:34:39.723008  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_3, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:a6
I0421 09:34:39.724808  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_3/
I0421 09:34:39.725432  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_3, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:a6
I0421 09:34:39.727155  4670 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_4/
I0421 09:34:39.728328  4670 rdma_context.cpp:125] RDMA device: mlx5_bond_4, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:d6
I0421 09:34:39.728621  4671 rdma_context.cpp:413] Find best gid index: 3 on mlx5_bond_4/
I0421 09:34:39.729239  4671 rdma_context.cpp:125] RDMA device: mlx5_bond_4, LID: 0, GID: (GID_Index 3) 00:00:00:00:00:00:00:00:00:00:ff:ff:1e:f6:da:d6
E0421 09:34:41.202507  4670 rdma_context.cpp:198] Failed to register memory 0x7ff278000000: Bad address [14]
[2025-04-21 09:34:41 TP0] Mooncake memory registration failed.
[2025-04-21 09:34:41 TP0] Scheduler hit an exception: Traceback (most recent call last):
  File "/sgl-workspace/sglang/python/sglang/srt/managers/scheduler.py", line 1999, in run_scheduler_process
    scheduler = Scheduler(server_args, port_args, gpu_id, tp_rank, dp_rank)
  File "/sgl-workspace/sglang/python/sglang/srt/managers/scheduler.py", line 431, in __init__
    self.init_disaggregation()
  File "/sgl-workspace/sglang/python/sglang/srt/managers/scheduler.py", line 594, in init_disaggregation
    self.disagg_prefill_pending_queue = PrefillBootstrapQueue(
  File "/sgl-workspace/sglang/python/sglang/srt/disaggregation/prefill.py", line 77, in __init__
    self.kv_manager = self._init_kv_manager()
  File "/sgl-workspace/sglang/python/sglang/srt/disaggregation/prefill.py", line 111, in _init_kv_manager
    kv_manager = kv_manager_class(
  File "/sgl-workspace/sglang/python/sglang/srt/disaggregation/mooncake/conn.py", line 115, in __init__
    self.register_buffer_to_engine()
  File "/sgl-workspace/sglang/python/sglang/srt/disaggregation/mooncake/conn.py", line 133, in register_buffer_to_engine
    self.engine.register(kv_data_ptr, kv_data_len)
  File "/sgl-workspace/sglang/python/sglang/srt/disaggregation/mooncake/transfer_engine.py", line 36, in register
    raise RuntimeError("Mooncake memory registration failed.")
RuntimeError: Mooncake memory registration failed.

About this issue

Most upvoted comments

The creation of the external allocator is just the same as the one in this reference.

This method indeed no longer throws an error, but I found that it causes a significant performance drop @bliu3650