chain
ptwm_core::chain::runtime
PPG DAG runtime — forward executor, inverse executor, fusion picker.
ptwm_core::chain::runtime
PPG DAG runtime — forward executor, inverse executor, fusion picker.
ptwm_core::chain::runtime
crates/ptwm-core/src/chain/runtime.rs:1mod runtimePPG DAG runtime — forward executor, inverse executor, fusion picker.
ptwm_core::chain::runtime::chain_terminal_descriptors
crates/ptwm-core/src/chain/runtime.rs:290pub fn chain_terminal_descriptors(chain: &Chain) -> Result<Vec<PlaneDescriptor>, PtwmCoreError>Recover the [`PlaneDescriptor`] of every chain terminal in `chain.terminals` order, without the original tensor bytes.
The reconstruction runs [`forward_chain`] over a **placeholder source
buffer** of zero bytes (length matching the `Source` op's declared
shape × dtype). Forward execution honours fusion, role overrides, and
every op's actual descriptor flow, so the descriptors returned here
match exactly what an end-to-end forward pass on the real tensor
would produce.
The decoder calls this to feed faithful `Plane` values into
[`inverse_chain`].
Cross-tensor delta ops are out of scope here: the placeholder forward
would need real dep planes. Chains containing `XorDelta` /
`FloatDelta` cannot reconstruct terminal descriptors via this helper
alone — the compressor driver owns that orchestration.
ptwm_core::chain::runtime::forward_chain
crates/ptwm-core/src/chain/runtime.rs:106pub fn forward_chain(chain: &Chain, ctx: &ForwardContext<'_>) -> Result<ForwardResult, PtwmCoreError>Execute the chain in forward (encode) order.
Node 0 must be `Source`; its output wraps `ctx.source_bytes` in a
`Plane`. Each subsequent node comes from `op_from_id`, and the runtime
calls `forward` with the gathered input planes. Terminal refs collect
at the end in `chain.terminals` order.
ptwm_core::chain::runtime::ForwardContext
crates/ptwm-core/src/chain/runtime.rs:85pub struct ForwardContextContext supplied by the caller for a forward (encode) pass.
`source_bytes` is borrowed: the runtime owns the single allocation that
seeds node 0's `Plane`, sparing callers (e.g. multi-chain trial-encode)
from cloning the raw tensor for every candidate.
ptwm_core::chain::runtime::ForwardResult
crates/ptwm-core/src/chain/runtime.rs:95pub struct ForwardResultOutput of a forward pass.
ptwm_core::chain::runtime::FusedExecution
crates/ptwm-core/src/chain/runtime.rs:538pub struct FusedExecutionA fused execution pair: producer node merged with consumer node.
ptwm_core::chain::runtime::inverse_chain
crates/ptwm-core/src/chain/runtime.rs:354pub fn inverse_chain(chain: &Chain, ctx: &InverseContext<'_>) -> Result<Plane, PtwmCoreError>Execute the chain in inverse (decode) order, reconstructing the source plane.
The traversal walks nodes in reverse topological order. For each node,
`op.inverse` runs on the node's output planes (from the working state)
to reconstruct the input planes, then stores them under the
corresponding source edges.
After the traversal, the plane at `(0, 0)` is the reconstructed source.
ptwm_core::chain::runtime::InverseContext
crates/ptwm-core/src/chain/runtime.rs:339pub struct InverseContextContext supplied by the caller for an inverse (decode) pass.
ptwm_core::chain::runtime::try_fuse_at
crates/ptwm-core/src/chain/runtime.rs:558pub fn try_fuse_at(chain: &Chain, node_idx: u8) -> Option<FusedExecution>Check whether `node_idx` is the CONSUMER in a fusable pair. If so, return a `FusedExecution` with `producer_node` set to the upstream node.
Conditions for fusion:
1. The connecting edge has no `role_override` and empty `vendor_bytes`.
2. No other edge or terminal consumes the producer's output.
3. The (producer.op, consumer.op) pair is in the fusion table.