ptwm_core
ptwm_core::compressor
PPG compressor entry point.
ptwm_core::compressor
PPG compressor entry point.
ptwm_core::compressor
crates/ptwm-core/src/compressor.rs:1mod compressorPPG compressor entry point.
`compress_model` takes per-tensor candidate `Chain`s, runs each forward
DAG via [`forward_chain`], routes every terminal plane through the
capability-keyed [`dispatch`] menu, fits Pass-2 shared state on the
chosen terminals, and writes a chain-registry-backed `.ptwm` container.
ptwm_core::compressor::compress_model
crates/ptwm-core/src/compressor.rs:654pub fn compress_model(writer: W, inputs: &[InputTensor<'_>], opts: CompressorOptions) -> Result<Vec<u16>, PtwmCoreError>PPG entry point. Each input tensor carries one or more candidate [`Chain`]s; the compressor selects the chain that produces the smallest total compressed payload (multi-chain trial-encode), then writes a chain-registry-backed `.ptwm` container.
Returns the per-tensor chosen chain *registry index* (after dedup) for
audit. The order matches the input slice.
**Pass-2 ordering note.** Shared-state fitting is performed *after*
Pass-1 multi-chain selection. This means the multi-chain ranker sees only
inline trial-encode payloads. For monotone shared-state codecs (PGC,
O1SAC), Inline is the lower bound on what the chain can achieve, so the
multi-chain ranking remains correct; per-terminal final encoding may
later switch to a `Shared` variant if it wins the re-trial.
ptwm_core::compressor::CompressorOptions
crates/ptwm-core/src/compressor.rs:91pub struct CompressorOptionsCompressor options.
ptwm_core::compressor::InputTensor
crates/ptwm-core/src/compressor.rs:71pub struct InputTensorPer-tensor input for the compressor. The caller supplies one or more candidate [`Chain`]s; the compressor runs each forward+trial-encode and keeps the chain with the smallest output (multi-chain trial-encode).
ptwm_core::compressor::source_descriptor_for
crates/ptwm-core/src/compressor.rs:163pub fn source_descriptor_for(dtype_code: u16, raw_byte_count: u64, shape: Option<&[u64]>) -> PlaneDescriptorBuild a default source `PlaneDescriptor` keyed on dtype code.
`element_width` and `is_nibble_packed` come from `transforms::source`,
which owns the dtype-code mapping. This function used to inline its own
copy of that match. The copy drifted: it kept packed FP4 in the byte
catch-all, so every plane reaching the trial encode was byte-width and
not nibble-packed, and `PerGroupCodebook` could accept none of them.
Call the mapping, do not restate it.
`length_bytes` is the raw byte count; `Layout::Rows{row_len}` applies
when `shape` is supplied, using the row-major last dimension.
Public so the PyO3 binding (`ptwm-py`) can build the same source
descriptor without duplicating the dtype-code → element-width mapping.