Description
apply_sparse_delta in grail/infrastructure/delta_checkpoint.py (line 137) crashes with an unhandled StopIteration exception when base_state is an empty dict and target_dtype is None.
if target_dtype is None:
target_dtype = next(iter(base_state.values())).dtype # StopIteration if base_state == {}
This is called from checkpoint_consumer.py at lines 439-444 and 1315-1319 with target_dtype=None, making those call sites vulnerable to the crash.
Steps to Reproduce
from grail.infrastructure.delta_checkpoint import apply_sparse_delta
apply_sparse_delta({}, {}, {}, target_dtype=None)
# StopIteration raised, not caught by caller
Expected Behavior
A clear ValueError with a descriptive message: "Cannot infer target_dtype: base_state is empty".
Actual Behavior
StopIteration propagates up through the call stack, crashing the caller.
Description
apply_sparse_deltaingrail/infrastructure/delta_checkpoint.py(line 137) crashes with an unhandledStopIterationexception whenbase_stateis an empty dict andtarget_dtypeisNone.This is called from
checkpoint_consumer.pyat lines 439-444 and 1315-1319 withtarget_dtype=None, making those call sites vulnerable to the crash.Steps to Reproduce
Expected Behavior
A clear
ValueErrorwith a descriptive message:"Cannot infer target_dtype: base_state is empty".Actual Behavior
StopIterationpropagates up through the call stack, crashing the caller.