Skip to content

Commit db34eb3

Browse files
fix move_indices
1 parent 67e70d4 commit db34eb3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

python/sglang/srt/managers/cache_controller.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,12 @@ def move_indices(self, host_indices, device_indices):
495495
if self.io_backend == "kernel":
496496
return host_indices.to(self.mem_pool_device.device), device_indices
497497
elif self.io_backend == "direct":
498-
device_indices = device_indices.cpu()
499-
host_indices, idx = host_indices.sort()
500-
return host_indices, device_indices.index_select(0, idx)
498+
if self.mem_pool_host.layout == "layer_first":
499+
device_indices = device_indices.cpu()
500+
host_indices, idx = host_indices.sort()
501+
return host_indices, device_indices.index_select(0, idx)
502+
elif self.mem_pool_host.layout == "page_first_direct":
503+
return host_indices, device_indices.cpu()
501504
else:
502505
raise ValueError(f"Unsupported io backend")
503506

0 commit comments

Comments
 (0)