Add DCAE and SAAF with dictionary context and AuxT support#356
Open
Yiozolm wants to merge 6 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two channel-slice image compression models from the per-model PR series:
This PR builds on the containerized entropy-stack direction from #355: both models use
HyperpriorLatentCodec+ChannelGroupsLatentCodec, with model-specific dictionary context heads layered on top instead of introducing a separate codec class.Pretrained weights are intentionally not bundled. Calling
pretrained=Trueraises a clearRuntimeErroruntil weights are hosted.Summary
compressai.models.dcae.DCAEandcompressai.models.saaf.SAAFmodel classes.compressai.layers.attn.dictionary.compressai.models._helpers.dictionary_context.compressai.models._helpers.auxt.TCMviause_auxt=True.compressai.layers.wavefor AuxT."dcae"and"saaf"using lazy imports.examples/convert_dcae_checkpoint.pyexamples/convert_saaf_checkpoint.pyexamples/convert_tcm_checkpoint.pyfor upstream TCM checkpoints that include AuxT keys.from_state_dictround trips, converters, dictionary helpers, AuxT helpers, and zoo registration.Design notes
DCAE and SAAF share the same outer entropy topology:
The model-specific variation lives in the per-slice dictionary context heads:
SharedDictionary;DictionaryMeanScaleContextHead;LRPGaussianLatentCodecleaf.SAAF reuses the DCAE entropy wiring and adds:
aux_enc/aux_decbranches;diffusion_losshead.TCM keeps AuxT optional through
use_auxt=True;from_state_dictauto-detects saved AuxT keys.State-dict layout
Upstream checkpoint layouts are converted into the CompressAI-native layout before loading:
The converters handle upstream-specific naming, including DCAE / SAAF dictionary keys, mean/scale hyper-synthesis renames, per-slice context heads, LRP transforms, Gaussian conditional buffers, and AuxT key normalization.
from_state_dictonly infers constructor kwargs from the converted CompressAI layout; it does not directly accept every upstream checkpoint layout.Commits
feat(layers): lift dictionary cross-attention building blocks to compressai.layers.attnfeat(models/_helpers): add SharedDictionary and DictionaryMeanScaleContextHeadfeat(models): add DCAE with containerized codecfeat(models): add AuxT primitives, helpers, and TCM use_auxt opt-infeat(models): add SAAF with containerized codec and integral AuxTtest,zoo: cover and register DCAE SAAF and AuxTTest plan
uv run pytest tests/test_models.py tests/test_models_helpers.py tests/test_layers.py -quv run pytest tests/test_zoo.py -quv run pytest tests/test_latent_codecs.py -quv run ruff format --check compressai tests examplesuv run ruff check compressai tests examplesNotes for reviewers
_helpers.auxtbecause it is used by SAAF and optionally by TCM, and is expected to be reusable by future models with the same side-branch pattern.