PTWM
Concepts

Delta compression

XOR-residual compression against a reference frame for checkpoint chains.

Delta compression encodes the difference between a tensor and a reference tensor. The classic use case is a chain of fine-tuned checkpoints derived from the same base — most weights barely change, and the diff compresses dramatically better than the full tensor.

How it works

For two tensors of the same dtype and shape, PTWM computes a per-byte XOR residual:

residual = tensor ^ reference

This residual has the same shape and dtype as the input. If most bits are unchanged, the residual is sparse and the entropy coder compresses it tightly. The decoder reverses the operation:

tensor = decompressed_residual ^ reference

CLI usage

ptwm compress model_v2.safetensors --delta model_v1.safetensors

The output omits the reference file — the decoder needs access to the same reference at restore time.

When delta helps

ScenarioTypical gain
LoRA adapter atop a baseVery large — most weights are byte-identical
Same-architecture fine-tuneModerate — depends on training divergence
Different-architectureNone — XOR residual is near-uniform

When it doesn't

Delta compression sits on a separate path from the standard plane / codec pipeline. The XOR residual then flows through the same PPG chain machinery, so the usual plane / codec dispatch still applies.

For unrelated checkpoints, run the standard pipeline without --delta.