Why for-loops Are Not Batch Processing
Document Statement
This is not a Rust tutorial.
This is the fourth article in the Rust Quant Operator series, focused on defining batch execution as a first-class semantic constraint.
Author
yuer
Author of EDCA OS
Proposer of controllable AI standards
Repository: https://github.com/yuer-dsl
Contact: lipxtk@gmail.com
- Why batch ≠ loop
Batch execution is often implemented as:
for x in data {
operator.apply(x);
}
This is semantically incorrect once consistency matters.
- Definition: Batch Consistency
Batch Consistency means:
under identical time semantics and inputs,
batch execution and step execution must be semantically equivalent.
Equivalent does not mean identical execution paths.
- Why loops break consistency
Implicit assumptions:
commutative state updates
per-step time progression
irrelevant intermediate states
These assumptions fail for windowed and stateful operators.
- Batch as a semantic object
pub struct BatchInput {
pub values: &[T],
pub times: &[Time],
}
- BatchOperator interface
pub trait BatchOperator {
fn apply_batch(
&mut self,
input: BatchInput,
) -> OperatorResult;
}
Batch execution is not a wrapper—it is a semantic commitment.
- Time semantics are preserved
Batch execution must not weaken time ordering.
- Vectorization under constraints
Vectorization is an implementation strategy.
Consistency is non-negotiable.
- Invariants
step ≡ batch semantics
time ordering preserved
no hidden state shortcuts
- Artifacts frozen
Batch Consistency
BatchInput
BatchOperator
Vectorization invariants
- Roadmap hook
The final article will generalize the operator model beyond quant systems.
If someone argues that
“batch execution should behave differently,”
then this document has succeeded.
Top comments (0)