Skip to content

Declare and instrument PCIe H2D and D2H byte counter and per-device label telemetry metrics: - #950

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_982457553
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_982457553

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Sep 18, 2026

Copy link
Copy Markdown

Declare and instrument PCIe H2D and D2H byte counter and per-device label telemetry metrics:

  • Declare kH2dBytesTotal (h2d_bytes_total), kD2hBytesTotal (d2h_bytes_total), and kHostIp (host_ip) in metrics_backend.h, and register kH2dBytesTotal and kD2hBytesTotal in kAllMetrics (metrics_backend.h) with kPcieTransferLabels ({host_ip, local_rank}), while keeping kH2dTransferTimeMs and kD2hTransferTimeMs unlabeled with unchanged emission behavior.
  • Add anonymous-namespace helpers ComputeBytesPerShard (computing per-shard byte counts across layers from copy_sizes_major_dim for partial block transfers or full-layer physical_size / max_physical_size_ for full-buffer transfers), GetShardRankString, and JoinAndRecordTelemetry in kv_cache_manager_base.cc to increment h2d_bytes_total and d2h_bytes_total per shard upon successful transfer completion across H2dSyncDispatch, D2hSyncDispatch, D2hWrite, H2dDirect, D2hDirect, and CopyPoolBlocks.
  • Add unit tests in kv_cache_manager_test.cc and kv_cache_manager_with_transfer_test.cc verifying per-device H2D/D2H byte counter emission and partial block byte accounting.

@copybara-service copybara-service Bot changed the title Instrument P2P batch barrier timing and sent bytes telemetry in tpu_sync socket transport. Declare and instrument PCIe H2D and D2H byte counter and per-device label telemetry metrics: Sep 20, 2026
…abel telemetry metrics:

- Declare `kH2dBytesTotal` (`h2d_bytes_total`), `kD2hBytesTotal` (`d2h_bytes_total`), and `kHostIp` (`host_ip`) in `metrics_backend.h`, and register `kH2dBytesTotal` and `kD2hBytesTotal` in `kAllMetrics` (`metrics_backend.h`) with `kPcieTransferLabels` (`{host_ip, local_rank}`), while keeping `kH2dTransferTimeMs` and `kD2hTransferTimeMs` unlabeled with unchanged emission behavior.
- Add anonymous-namespace helpers `ComputeBytesPerShard` (computing per-shard byte counts across layers from `copy_sizes_major_dim` for partial block transfers or full-layer `physical_size` / `max_physical_size_` for full-buffer transfers), `GetShardRankString`, and `JoinAndRecordTelemetry` in `kv_cache_manager_base.cc` to increment `h2d_bytes_total` and `d2h_bytes_total` per shard upon successful transfer completion across `H2dSyncDispatch`, `D2hSyncDispatch`, `D2hWrite`, `H2dDirect`, `D2hDirect`, and `CopyPoolBlocks`.
- Add unit tests in `kv_cache_manager_test.cc` and `kv_cache_manager_with_transfer_test.cc` verifying per-device H2D/D2H byte counter emission and partial block byte accounting.

PiperOrigin-RevId: 982457553
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.

0 participants