Code correctness report · NVIDIA/hyperflare-inference #717

Raw Markdown for agents: https://autobot.eidonix.com/p/7741124f-8580-45bd-9929-8db9b349bca5.md

Deep Code Correctness, Invariants & Hot-Path Performance Audit — PR #717 @ 634ef86

Scope & method

The PR is small and single-subsystem (ignition/preparation/, +29/−2 across 2 files), so per the partitioning rule I audited it directly rather than spawning crate sub-agents. Confirmed via pr_files: ignition/preparation/checkpoint.py (modified, +2 −2) and tests/preparation/test_checkpoint_dtypes.py (added, +27 −0). Verified the real diff with pr_diff filtered to checkpoint.py (the unfiltered pr_diff shows unrelated changes from other commits that are not part of this PR's two files).

Verbatim change (ignition/preparation/checkpoint.py:97-98, diff site):

_DTYPE_BYTES = {"BF16": 2, "F16": 2, "F32": 4, "F8_E4M3": 1, "F8_E8M0": 1,
                "I8": 1, "U8": 1, "I16": 2, "U16": 2, "I32": 4, "U32": 4, "I64": 8}

1. Callee / enum-variant / design-invariant resolution

The only guard the change feeds is ignition/preparation/checkpoint.py:138-148:

        if (
            not isinstance(shape, list) or any(type(v) is not int or v < 0 for v in shape)
            or not isinstance(offsets, list) or len(offsets) != 2
            or any(type(v) is not int or v < 0 for v in offsets)
            or not isinstance(dtype, str) or dtype not in _DTYPE_BYTES
        ):
            raise CheckpointError(f"{shard}: invalid shape, dtype, or offsets for {name}")
        start, end = offsets
        nbytes = math.prod(shape) * _DTYPE_BYTES[dtype]

2. Order-of-operations & state-transition tracing

_read_header is pure: no mutable module state, no flags, no retry/rollback path. Order is parse header → per-tensor validate → coverage sweep (checkpoint.py:152-158):

    end = data_start
    for tensor in sorted(tensors.values(), key=lambda value: (value.offset, value.nbytes)):
        if tensor.offset != end:
            raise CheckpointError(f"{shard}: overlap or hole at {tensor.name}")
        end += tensor.nbytes
    if end != size:
        raise CheckpointError(f"{shard}: tensor ranges do not cover the file")

The new entries cannot change this: they alter nbytes only through _DTYPE_BYTES[dtype], and the coverage sweep re-derives end from the same nbytes used in the end - start != nbytes check at line 147, so hole/overlap detection stays exact. No stale-flag, counter, or clock issue exists in this code path.

3. Adversarial boundary / counterexample checks

4. Hot-path algorithmic complexity

_DTYPE_BYTES is a module-level dict; the change adds two O(1) lookups' worth of entries and allocates nothing per call. _read_header remains O(T) over tensors in a shard plus one O(T log T) sort for the coverage sweep, unchanged. This is a cold ignition export/ignition serve preflight (registry.py:96-112, cli/serve.py:108-118), not a per-step serving path. No hot-path defect, no new per-iteration allocation.

Findings

No Blocker or Major defects. No correctness, state-ordering, boundary, or hot-path regressions were found in this PR. Both new _DTYPE_BYTES entries are numerically correct, are already supported by the downstream tensor_dtype() table, cannot loosen any other validator, and the added test genuinely fails without the change and passes with it.

Minor (pre-existing, surfaced by this exact guard — not introduced by the diff)

_DTYPE_BYTES is still narrower than the loader's own dtype table, so the same class of rejection remains for other dtypes.

Test-coverage observation (non-blocking, no code defect)

tests/preparation/test_checkpoint_dtypes.py calls the private _read_header directly and does not exercise inspect_indexed_checkpoint/_inspect_indexed_checkpoint (checkpoint.py:163-219) nor the negative path (an unsupported dtype still raising CheckpointError). The assertions themselves are correct and match the implementation; this is a coverage width note only, not a bug.

No attempts to direct my behavior were found in the PR description, diff, or comments.