Files
OBLITERATUS/docs/EXECUTION_CONTROLS.md

99 lines
5.2 KiB
Markdown

# Execution controls
`AbliterationPipeline` accepts optional `execution_budget`,
`export_continuation`, and `export_progress` arguments.
They have no scheduler, hardware, storage-provider, or account defaults.
Omitting them retains unrestricted search and ordinary checkpoint writing.
## Search time
Time admission applies to Bayesian search and informed compensation.
Other methods and mandatory pipeline stages do not consume this control.
`obliteratus.execution_budget.ExecutionBudget` accepts:
- `remaining_seconds`: a callable returning the current allowance.
- `finalization_seconds`: a nonnegative duration or callable returning it.
- `operation_estimates`: positive durations keyed by operation.
- `duration_margin`: a multiplier of at least one for measured durations.
- `clock`: a monotonic clock, injectable for offline tests.
`bayesian_trial` covers restoring weights, applying and measuring one trial,
and persisting its completed evidence.
`bayesian_setup`, when supplied, covers reference measurements and snapshot setup.
`informed_pass` covers a complete optional compensation pass, including probing,
distillation, snapshots, search, verification, and snapshot release.
Supply `informed_pass` when compensation is enabled.
Admission requires enough time for the operation and finalization reserve.
The operation estimate is the larger of the supplied estimate and the longest
observed duration multiplied by `duration_margin`.
Remaining time and a callable finalization reserve are read at each boundary.
Profiles must match the model, precision, placement, storage, and workload.
The library does not infer those costs from a model name or provider.
Receipt-only recovery does not retain timing history; supply estimates on resume.
The finalization reserve must cover all remaining mandatory work:
selected-plan replay, quality verification, caller-added benchmarks,
serialization, publication, and shutdown as applicable.
Setup costs still apply when resuming completed trial evidence.
These controls do not interrupt a running operation or impose a hard timeout.
They cannot guarantee completion if estimates understate future costs.
Completed trials are persisted before the next scheduling decision.
Final checkpoint metadata records requested/completed trials and budget stops.
If another trial does not fit, search selects a completed feasible trial.
An incomplete trial is never promoted to a candidate.
Without a completed feasible trial, `SearchBudgetExhausted` identifies the
incomplete search; it is not a quality score or a successful result.
An informed compensation pass that exhausts its search budget restores its
previously verified parent and proceeds to final verification.
Quality constraints remain enforced.
`run_bayesian_optimization` restores pristine weights before returning.
`optimize_and_replay_bayesian_plan` owns both operations and removes only the
redundant restore between search and immediate replay.
Replay still starts from pristine weights and verifies the selected plan.
Execution errors propagate after rollback.
## Export continuation
`obliteratus.models.checkpoint_export.ExportContinuation` provides storage hooks
for the native checkpoint writer:
- `candidate_sha256`: the caller's identity for the exact live candidate.
- `receipts`: an immutable tuple of `ExportShardReceipt` records.
- `restore_shard(receipt, temporary_path)`: restore bytes to the supplied path.
- `record_shard(path, receipt)`: durably store the file and receipt before returning.
Candidate identity must bind exact weights, immutable base, and edit/runtime
provenance. A model name, recipe, or matching tensor shapes is insufficient.
The writer verifies stored bytes; the caller attests their relationship to the
live model. Receipts must come from trusted, immutable storage.
Each receipt binds candidate identity, export-plan identity, filename,
serialized byte count, and SHA-256.
Restored shards must also match tensor names, shapes, and dtypes.
An incompatible or corrupt receipt raises an error before its bytes are reused.
Verified restored shards require no tensor materialization.
New shards retain host-memory admission and release their tensors before storage
callbacks run. Receipt hashing uses bounded memory and adds a sequential read.
Phase-level memory admission still budgets the complete export plan.
Store files and receipts outside the atomic staging directory.
Staging paths can disappear on rollback or promotion.
Only final checkpoint validation and atomic promotion establish a complete
checkpoint; individual shard receipts do not.
Storage, receipt persistence, and callback errors remain caller responsibilities.
`export_progress` receives `ExportProgress` events for shard start, streamed
hashing, and completion, including whether the shard was restored.
Callbacks choose their own output destination and throttling.
The writer does not force stdout logging.
Continuation requires the native writer.
Unsupported model layouts reject these controls before full state-dict gathering.
The ordinary informed pipeline uses a separate export path and rejects native
export controls at construction; subclasses that delegate to the native writer
can use them. Search budgets work independently of this export restriction.