checkpoint method

Future<void> checkpoint()

Saves the state at the current position, for prefill to return to. Costs a copy of the conv histories (640 KB for LFM3-1.7B); a no-op with worker isolates.

Implementation

Future<void> checkpoint() async {
  _checkOpen();
  if (length == 0 || _checkpoints.containsKey(length)) return;
  final state = _gpu?.saveState() ?? await _executor!.saveState();
  if (state == null) return;
  _checkpoints[length] = state;
  if (_checkpoints.length > maxCheckpoints) {
    final positions = _checkpoints.keys.toList()..sort();
    _checkpoints.remove(positions[1]);
  }
}