Skip to content

Commit bbf9308

Browse files
committed
Add assertion to validate shape of k_hash_compute against slot mapping
1 parent 4aab99c commit bbf9308

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ucm/sparse/kvcomp/kvcomp_hbm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ def attention_begin(
365365
self.is_tensor_computed = True
366366

367367
k_hash_compute = self.hash_encoder.compute_hash(key)
368+
assert k_hash_compute.shape[0] == attn_metadata.slot_mapping.numel(), f"shape mismatch: k_hash_compute.shape[0]={k_hash_compute.shape[0]} != attn_metadata.slot_mapping.numel()={attn_metadata.slot_mapping.numel()}"
368369
k_hash_compute = (
369370
k_hash_compute.transpose(0, 1)
370371
.reshape(-1, k_hash_compute.shape[-1])

0 commit comments

Comments
 (0)