Skip to content

vllm.models.kimi_k3.amd.specialized_decode.mono.common.debug

Wait records: which mailbox region a CTA's given-up wait was on.

Functions:

  • given_up_waits –

    Each CTA's first wait that gave up, the earliest first, from a rank's

  • region_id –

    A mailbox region's id in a wait record: its name's CRC-32 (31 bits), the

  • region_ids –

    Name -> region_id: a Mailbox's table.

given_up_waits(health, names)

Each CTA's first wait that gave up, the earliest first, from a rank's health words; names the regions a record may name.

Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/debug.py
def given_up_waits(health: torch.Tensor, names) -> list[str]:
    """Each CTA's first wait that gave up, the earliest first, from a rank's
    ``health`` words; ``names`` the regions a record may name."""
    by_id = {region_id(n): n for n in names}
    records = health.view(BLOCKS + 1, RECORD_WORDS)[1:]
    records = records[records[:, 0] != 0].tolist()
    t0 = min((r[6] for r in records), default=0)
    return [
        f"+{(at - t0) / 100:.0f} us CTA {cta}: {by_id.get(rid, rid)} pair {idx}"
        f" waited for tag {tag}, saw {seen}"
        for _, rid, idx, tag, seen, cta, at, _ in sorted(records, key=lambda r: r[6])
    ]

region_id(name)

A mailbox region's id in a wait record: its name's CRC-32 (31 bits), the same in every kernel and table that names it.

Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/debug.py
def region_id(name: str) -> int:
    """A mailbox region's id in a wait record: its name's CRC-32 (31 bits), the
    same in every kernel and table that names it."""
    return zlib.crc32(name.encode()) & 0x7FFFFFFF

region_ids(names)

Name -> region_id: a Mailbox's table.

Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/debug.py
def region_ids(names) -> dict[str, int]:
    """Name -> ``region_id``: a ``Mailbox``'s table."""
    return {n: region_id(n) for n in names}