Skip to main content

engine.solvers.curation

engine.solvers.curation

Trajectory curation solvers: what a recorded corpus may teach, and what collecting it costs.

Domain implementations behind mlsysim.solvers (added 2026-10-20). Each model is arithmetic on stated counts, rates, and service times: failures that counterfactual probes attribute to the system, and the price of training on all of them anyway; how often a random split of runs places one task on both sides; the expected checking time of an admission route run in different orders; one record class’s share of a pool under three denominators; and how fast a verifier timeout burst fills reserved staging.

Classes

Name Description
AdmissionOrderModel One admission route’s independent checks run in different orders, each stopping at its first failure.
CorpusDenominatorsModel One record class’s share of a retained pool counted three ways: records, stored tokens, selected targets.
FailureTriageModel Failures that counterfactual probes remove below the weights, and the price of training on all of them.
RunSplitLeakageModel Tasks whose runs a random split of runs places on both sides of the partition.
StagingBurstModel Reserved staging under a verifier timeout burst, with every record charged at its ceiling.

AdmissionOrderModel

engine.solvers.curation.AdmissionOrderModel()

One admission route’s independent checks run in different orders, each stopping at its first failure.

Every order admits the same records (the route yield is the product of the pass rates); the expected slot time per attempted record differs. Time per admitted record divides by the yield. The saving compares the cheapest order with the dearest.

Methods

Name Description
solve Compare expected checking time for short-circuit admission orders.
solve
engine.solvers.curation.AdmissionOrderModel.solve(
    checks,
    orders,
    candidates=None,
)

Compare expected checking time for short-circuit admission orders.

Parameters
Name Type Description Default
checks Mapping[str, tuple[float, Quantity]] Named (pass probability, positive service time) pairs; each probability is in (0, 1), times convertible to seconds. required
orders Sequence[Sequence[str]] Nonempty permutations of the same check names, each used once per order. required
candidates int Nonnegative attempted records for an expected admitted count; None omits it. None
Returns
Name Type Description
AdmissionOrderResult Service times in seconds, route yield, expected admissions, best-order index, and fractional saving.
See Also

mlsysim.physics.agents.calc_short_circuit_cost : Expected reach-weighted service cost and route yield.

Notes

Equation: E[T] = sum_i t_i product_{j<i} p_j; yield = product_i p_i; time per admitted record = E[T]/yield.

Assumptions: Check outcomes are independent and unchanged by order. Each route contains exactly the same checks; the implementation uses the first route yield for every order.

Excludes: Parallel checks, dependent rejection causes, and checking whether input orders are valid permutations.

References

Derivation: each check incurs cost only after all earlier checks pass; linearity of expectation sums those reach-weighted costs.

Examples
>>> result = AdmissionOrderModel().solve({"fast": (0.5, 1 * second), "slow": (0.5, 4 * second)}, [["fast", "slow"], ["slow", "fast"]])
>>> result.best_order == 0 and result.saving > 0
True

CorpusDenominatorsModel

engine.solvers.curation.CorpusDenominatorsModel()

One record class’s share of a retained pool counted three ways: records, stored tokens, selected targets.

Each class gives (records, stored tokens per record, selected target tokens per record). The admitted-token share counts stored tokens only over the classes the route admits.

Methods

Name Description
solve Compare a corpus class by record, stored-token, and target-token shares.
solve
engine.solvers.curation.CorpusDenominatorsModel.solve(classes, focus, admitted)

Compare a corpus class by record, stored-token, and target-token shares.

Parameters
Name Type Description Default
classes Mapping[str, tuple[int, Quantity, Quantity]] Named (nonnegative record count, stored tokens per record, target tokens per record) entries. Aggregate denominators must be positive. required
focus str Existing class name whose shares are reported; include it in admitted for an admitted-pool share. required
admitted Sequence[str] Existing class names admitted by the route; their stored-token total must be positive. required
Returns
Name Type Description
CorpusDenominatorsResult Record counts and token quantities, dimensionless shares, and context tokens per target token.
Notes

Equation: Stored_i = n_i*s_i; targets_i = n_i*u_i; each reported share divides the focus count by its corresponding pool total.

Assumptions: Fixed per-class record sizes. Each listed admitted class contributes once to the intended denominator; no deduplication is performed.

Excludes: Learning-quality weighting, stochastic lengths, and automatic validation that the focus belongs to the admitted pool.

References

Derivation: multiply each class count by its per-record token count, then normalize separately under each explicitly named denominator.

Examples
>>> result = CorpusDenominatorsModel().solve({"short": (2, 10 * token, 5 * token), "long": (1, 100 * token, 5 * token)}, "short", ["short", "long"])
>>> result.record_share > result.stored_share
True

FailureTriageModel

engine.solvers.curation.FailureTriageModel()

Failures that counterfactual probes remove below the weights, and the price of training on all of them.

runs x failure_rate failures; each probe removes its share (rounded to whole failures), and the rest survive every probe. Training on every failure for epochs epochs of sequence_tokens costs 6PD FLOPs, run on devices at peak_rate x utilization and billed per device-hour.

Methods

Name Description
solve Account for training work on all failures versus probe-surviving failures.
solve
engine.solvers.curation.FailureTriageModel.solve(
    runs,
    failure_rate,
    probe_shares,
    parameters,
    sequence_tokens,
    epochs,
    devices,
    peak_rate,
    utilization,
    hourly_price,
)

Account for training work on all failures versus probe-surviving failures.

Parameters
Name Type Description Default
runs int Positive number of observed runs. required
failure_rate float Failure fraction in (0, 1], yielding a positive rounded failure count. required
probe_shares Mapping[str, float] Disjoint attributed fractions of all failures, nonnegative and summing to at most one. required
parameters Quantity Model parameter count, convertible to param. required
sequence_tokens int Positive training tokens per failed run. required
epochs int Positive number of passes over the failure corpus. required
devices int Positive number of identical training devices. required
peak_rate Quantity Positive compute rate per device in flop/s. required
utilization float Supplied sustained-compute fraction in (0, 1]. required
hourly_price Quantity Nonnegative price per device-hour, convertible to USD/hour. required
Returns
Name Type Description
FailureTriageResult Rounded failure counts; tokens and FLOPs; wall time in hours, device-hours, and costs in USD.
See Also

mlsysim.physics.transformer.calc_transformer_training_flops : Parameter-dominated training work per processed token.

Notes

Equation: F = round(runs*failure_rate); residual = F - round(F*sum(probe_shares)); training work = 6*parameters*F*sequence_tokens*epochs; time = work/(devices*peak_rate*utilization).

Assumptions: Probe categories are mutually exclusive. Each removed category and the sum are rounded separately, so their integer counts need not add exactly. The training FLOP convention excludes recomputation.

Excludes: Overlapping attribution, causal identification of probe effects, communication, memory feasibility, and optimizer overhead.

References

Derivation: corpus token counts feed the parameter-dominated training accounting in calc_transformer_training_flops; divide work by aggregate sustained rate and multiply device-hours by the caller-supplied price.

Examples
>>> from mlsysim import Q_
>>> result = FailureTriageModel().solve(100, 0.2, {"runtime": 0.5}, Q_("1000 param"), 10, 1, 1, Q_("1e9 flop/s"), 0.5, Q_("1 USD/hour"))
>>> result.residual_cost < result.cost
True

RunSplitLeakageModel

engine.solvers.curation.RunSplitLeakageModel()

Tasks whose runs a random split of runs places on both sides of the partition.

Each run goes to training with probability f. A task with k runs straddles with probability 1 - f^k - (1 - f)^k; a test run has a sibling in training unless all k - 1 siblings also went to test. The majority count is the smallest k at which more than half the tasks straddle.

Methods

Name Description
solve Estimate task overlap caused by randomly splitting repeated runs.
solve
engine.solvers.curation.RunSplitLeakageModel.solve(
    attempts,
    train_fraction,
    tasks=None,
    max_attempts=64,
)

Estimate task overlap caused by randomly splitting repeated runs.

Parameters
Name Type Description Default
attempts int Positive number of runs per task. required
train_fraction float Independent probability in (0, 1) that a run enters training. required
tasks int Nonnegative task count for expected overlap; None omits that output. None
max_attempts int Positive search cap, default 64; must include a count whose overlap probability exceeds one half. 64
Returns
Name Type Description
RunSplitLeakageResult Dimensionless overlap probabilities, optional expected task count, and a majority-overlap threshold.
See Also

mlsysim.physics.agents.calc_split_straddle : Probability that repeated runs occupy both partitions.

Notes

Equation: P(straddle) = 1-fk-(1-f)k; P(training sibling | test run) = 1-(1-f)^(k-1).

Assumptions: Equal run counts per task and independent split assignment for every run.

Excludes: Task-level grouping, correlated split decisions, and actual semantic leakage detection. The majority search raises StopIteration if the cap is insufficient.

References

Derivation: subtract the disjoint all-training and all-test events from one; a test run lacks a training sibling only if every sibling is in test.

Examples
>>> result = RunSplitLeakageModel().solve(4, 0.5, tasks=100)
>>> result.straddle > result.whole
True

StagingBurstModel

engine.solvers.curation.StagingBurstModel()

Reserved staging under a verifier timeout burst, with every record charged at its ceiling.

Rollouts finish at rollouts / rollout_time; verifiers serve slots / mean_service nominally and slots / timeout once every check runs to its timeout. The difference, times the record ceiling, fills the store. Stopping dispatch leaves the running rollouts and the growth during the controller’s reaction delay, so dispatch must stop at or below 1 - (in flight + reaction growth) / store.

Methods

Name Description
solve Estimate staging growth while all verifier checks reach timeout.
solve
engine.solvers.curation.StagingBurstModel.solve(
    rollouts,
    rollout_time,
    slots,
    mean_service,
    timeout,
    record_ceiling,
    store,
    reaction,
)

Estimate staging growth while all verifier checks reach timeout.

Parameters
Name Type Description Default
rollouts int Positive concurrent rollout count. required
rollout_time Quantity Positive rollout completion time, convertible to seconds. required
slots int Positive parallel verifier slots. required
mean_service Quantity Positive nominal check duration, convertible to seconds. required
timeout Quantity Positive burst check duration, convertible to seconds. required
record_ceiling Quantity Positive worst-case bytes per completed rollout. required
store Quantity Positive reserved staging capacity in bytes. required
reaction Quantity Nonnegative controller reaction duration in seconds. required
Returns
Name Type Description
StagingBurstResult Rates in inverse seconds, growth in MB/s, fill time in seconds, reserves in GB, and fractional dispatch watermark.
Notes

Equation: arrival = rollouts/rollout_time; burst_capacity = slots/timeout; growth = (arrival-burst_capacity)*record_ceiling; watermark = 1-(in_flight+reaction*growth)/store.

Assumptions: A sustained burst, fixed rollout population, and positive net growth are required for the fill-time interpretation. Every record consumes its ceiling.

Excludes: Arrival variability, partial records, spill storage, and automatic clamping of negative watermarks or nonpositive growth.

References

Derivation: conservation of staged records subtracts completion service from arrivals; multiplying by record size converts backlog into byte growth.

Examples
>>> result = StagingBurstModel().solve(4, 1 * second, 1, 0.1 * second, 1 * second, 1 * MB, 1 * GB, 1 * second)
>>> result.growth.magnitude > 0 and result.high_watermark < 1
True
Back to top