[QSA] Count skipped ring commits
Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -222,6 +222,7 @@ def _qsa_prepare_kernel(
|
||||
num_k_work,
|
||||
num_requests, # bounds-guard instrumentation
|
||||
guard_ctr, # bounds-guard instrumentation: persistent int64[3]
|
||||
ring_skip_ctr, # ring-skip telemetry, persistent int64[3], SITE_QSA_RING_SKIP
|
||||
HQ: tl.constexpr,
|
||||
D: tl.constexpr,
|
||||
TILE_T_Q: tl.constexpr,
|
||||
@@ -555,6 +556,19 @@ def _qsa_prepare_kernel(
|
||||
valid_slot = (
|
||||
valid_token & (slot >= 0) & (slot < num_state_blocks * STATE_SIZE)
|
||||
)
|
||||
# Ring-skip telemetry: a live token whose slot fails the range check
|
||||
# has its ring row silently NOT written (every store below is
|
||||
# masked by valid_slot). That token's raw key is then absent
|
||||
# from the ring the next step reads (a candidate cause). Count
|
||||
# it -- the write stays skipped, the reconciliation is the ring-row tag fix.
|
||||
skipped = valid_token & ~valid_slot
|
||||
tl.atomic_add(ring_skip_ctr, 1, mask=skipped)
|
||||
tl.atomic_max(
|
||||
ring_skip_ctr + 1, token.to(tl.int64) + _GUARD_BIAS, mask=skipped
|
||||
)
|
||||
tl.atomic_max(
|
||||
ring_skip_ctr + 2, slot.to(tl.int64) + _GUARD_BIAS, mask=skipped
|
||||
)
|
||||
safe_slot = tl.maximum(slot, 0)
|
||||
state_row = (
|
||||
state_cache_ptr
|
||||
@@ -712,6 +726,7 @@ def qsa_prepare(
|
||||
num_k_work,
|
||||
min(query_start_loc.numel() - 1, state_block_table.shape[0]),
|
||||
guard_telemetry.counter(guard_telemetry.SITE_QSA_PRE_INDEXER, q.device),
|
||||
guard_telemetry.counter(guard_telemetry.SITE_QSA_RING_SKIP, q.device),
|
||||
HQ=num_q_heads,
|
||||
D=head_dim,
|
||||
TILE_T_Q=TILE_T_Q,
|
||||
|
||||
Reference in New Issue
Block a user