Skip to content

Commit 6ab7fc6

Browse files
benliangwcopybara-github
authored andcommitted
PUBLIC:
Release server_init_mu_ before executing SyncPull in KvCacheManagerBase to avoid holding it during the entire network transfer in SyncPull. ### Test Before the fix, cross-node transfer takes about With the fix, cross-node transfer takes about PiperOrigin-RevId: 969568450
1 parent dc5eb6b commit 6ab7fc6

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

tpu_sync/kv_cache/kv_cache_manager_base.cc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,15 +1195,24 @@ absl::StatusOr<raiden::PjRtCopyFuture> KVCacheManagerBase::H2hReadExplicit(
11951195
const std::vector<uint8_t*>& explicit_dst_ptrs, int parallelism,
11961196
tpu_raiden::transport::MajorOrder major_order,
11971197
tpu_raiden::transport::BlockReceivedCallback on_block_received) {
1198-
absl::MutexLock lock(server_init_mu_);
1199-
if (!server_) {
1198+
// Take the transport pointer under the lock but run the pull outside it
1199+
// (same pattern as StartPushInternal): SyncPull blocks for the whole
1200+
// network transfer, and holding server_init_mu_ across it serializes every
1201+
// concurrent pull in the process -- including the pull_pool_ pipeline in
1202+
// H2dRead, which degenerates to one round trip at a time.
1203+
tpu_raiden::transport::BlockTransport* transport_server = nullptr;
1204+
{
1205+
absl::MutexLock lock(server_init_mu_);
1206+
transport_server = server_.get();
1207+
}
1208+
if (!transport_server) {
12001209
return absl::FailedPreconditionError("Transport server is not running");
12011210
}
12021211
ASSIGN_OR_RETURN(
12031212
std::vector<int> allocated_ids,
1204-
server_->SyncPull({peer}, src_block_ids, local_block_ids,
1205-
explicit_dst_ptrs, parallelism, major_order,
1206-
on_block_received, kLeaseAuthorizedPullUuid));
1213+
transport_server->SyncPull({peer}, src_block_ids, local_block_ids,
1214+
explicit_dst_ptrs, parallelism, major_order,
1215+
on_block_received, kLeaseAuthorizedPullUuid));
12071216
return raiden::PjRtCopyFuture(std::vector<raiden::BufferHolder>{});
12081217
}
12091218

0 commit comments

Comments
 (0)