dau_core.hero¶
The temporal-finance hero workflow: the predeclared
end-to-end pipeline composed from the dau_core.temporal goldens, plus the
avoided-materialization cost model that is the paper’s core evidence:
quotes ─┐
├─> backward as-of ─> [market-feature map] ─> time bars ─> rolling moments
trades ─┘ (align) (derive, fused) (bar) (roll)
The argument the model makes precise: the pipeline is a cardinality funnel.
The align stage emits one market row per matched trade (N_mkt); the bar stage
reduces those to a handful of bars per symbol (N_bar << N_mkt); the roll stage
runs over the bars. A staged execution writes each stage’s output to DDR and
the next stage reads it back — so it pays to materialize the large N_mkt market
intermediate the bar reduction is about to discard. A fused execution keeps
every intermediate on-chip and touches DDR only for the input stream and the
final rolling output. The gain is not a magic primitive: it is the avoided DMA of
the intermediate the bar reduction discards.
The per-row market-feature derivation (midpoint/spread/sign/signed_volume/dollar)
is a map that fuses into the bar tile’s front chain stage (the q1/q6 shape) — it
adds no materialized intermediate in either execution — so the cost model’s
materializing stages are align → bar → roll. market_features is still run and
returned as the feature output branch (not discarded).
Both paths are DMA-bound (compute overlapped), so the model computes each from the exact golden cardinalities and the measured per-tile record widths — a first-order estimate the silicon run validates, not a measured result.
No dataframe or numerical-runtime dependency: pure integer arithmetic over the temporal goldens.
Attributes¶
Classes¶
One materializing stage and its cardinality: |
|
The executed workflow: the materializing-stage cardinalities (the funnel), |
|
The avoided-materialization accounting for one workflow run. |
Functions¶
|
Run the predeclared workflow end to end over the goldens, recording each |
|
Fused vs staged DMA accounting for an executed workflow. Staged pays each |
Module Contents¶
- dau_core.hero.INPUT_BYTES = 24¶
- dau_core.hero.MARKET_BYTES = 32¶
- dau_core.hero.BAR_BYTES = 48¶
- dau_core.hero.ROLL_INPUT_BYTES = 8¶
- dau_core.hero.ROLL_BYTES = 24¶
- dau_core.hero.ROLL_FIELDS = ('open', 'high', 'low', 'close')¶
- class dau_core.hero.WorkflowStage(/, **data: Any)[source]¶
Bases:
dau_core.models.CheckedModelOne materializing stage and its cardinality:
in_rowsrecords ofin_bytesin,out_rowsrecords ofout_bytesout (the tile’s own input/output record widths). A staged run DMAs both; a fused run DMAs neither (except the pipeline endpoints).Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- name: str¶
- op: str¶
- in_rows: int¶
- in_bytes: int¶
- out_rows: int¶
- out_bytes: int¶
- property read_bytes: int¶
- property write_bytes: int¶
- class dau_core.hero.HeroResult(/, **data: Any)[source]¶
Bases:
dau_core.models.CheckedMixin,ccflow.ResultBaseThe executed workflow: the materializing-stage cardinalities (the funnel), the per-row feature branch, and the stage outputs (for a bit-exact comparison against a CPU reference).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- stages: tuple[WorkflowStage, ...]¶
- market_rows: tuple[dau_core.temporal.MarketRow, ...]¶
- features: tuple[dau_core.temporal.MarketFeatures, ...]¶
- bars: tuple[dau_core.temporal.TemporalBar, ...]¶
- moments: tuple[dau_core.temporal.RollingMoment, ...]¶
- property funnel: tuple[int, ...]¶
input → market → bars → rolling (the fused feature map does not change cardinality).
- Type:
Row counts down the reduction path
- dau_core.hero.run_hero_workflow(trades: list[dau_core.temporal.TradeRow], quotes: list[dau_core.temporal.QuoteRow], *, bar_width: int, roll_window: int, tolerance: int | None = None, roll_value: str = 'close') HeroResult[source]¶
Run the predeclared workflow end to end over the goldens, recording each materializing stage’s cardinality.
roll_valueselects the per-bar OHLC price the roll stage windows (ROLL_FIELDS);roll_windowis the count-based window (>= 2, the tile’s minimum). Both input streams must be pre-sorted by(symbol_id, time)(the shared as-of / bar precondition).
- class dau_core.hero.MaterializationCost(/, **data: Any)[source]¶
Bases:
dau_core.models.CheckedMixin,ccflow.ResultBaseThe avoided-materialization accounting for one workflow run.
stagedDMAs every stage’s read and write;fusedDMAs only the pipeline endpoints (the input stream in, the final rolling output out).avoidedis the intermediate materialization the fusion removes;dma_ratiois the DMA-bound speedup (both paths are DMA-bound with compute overlapped).Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- staged_bytes: int¶
- fused_bytes: int¶
- avoided_bytes: int¶
- input_bytes: int¶
- final_bytes: int¶
- staged_jobs: int¶
- fused_jobs: int¶
- property dma_ratio: float¶
Staged / fused DMA. A no-work run (both zero) has no speedup (1.0); a genuinely nonzero staged cost with a zero fused cost is unbounded.
- estimate_seconds(*, dma_bytes_per_sec: float, per_job_seconds: float = 0.0) tuple[float, float][source]¶
(staged, fused) wall-clock estimates: DMA time plus a per-job tail (device setup + the one-job compute tail the overlap runner cannot hide). A DMA-bound first-order model — the prediction the silicon run checks.
- dau_core.hero.materialization_cost(result: HeroResult) MaterializationCost[source]¶
Fused vs staged DMA accounting for an executed workflow. Staged pays each stage’s read + write (the intermediate is written by one job and read back by the next); fused pays only the input read and the final write.