You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds two channel-slice image compression models from the per-model PR series:
DCAE (Dictionary-based Channel-wise Auto-regressive Entropy) from Lu et al., "Learned Image Compression with Dictionary-based Entropy Model", CVPR 2025.
SAAF (Sparse Attention with Adaptive Frequency) from Ma et al., "Learned Image Compression via Sparse Attention and Adaptive Frequency", CVPR 2026.
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=True raises a clear RuntimeError until weights are hosted.
Summary
New compressai.models.dcae.DCAE and compressai.models.saaf.SAAF model classes.
New dictionary cross-attention building blocks in compressai.layers.attn.dictionary.
New dictionary context helpers in compressai.models._helpers.dictionary_context.
New AuxT primitives and integration helpers in compressai.models._helpers.auxt.
Adds optional AuxT side-branch support to TCM via use_auxt=True.
Adds lightweight wavelet wrappers under compressai.layers.wave for AuxT.
Adds zoo entries for "dcae" and "saaf" using lazy imports.
Adds checkpoint converters:
examples/convert_dcae_checkpoint.py
examples/convert_saaf_checkpoint.py
Extends examples/convert_tcm_checkpoint.py for upstream TCM checkpoints that include AuxT keys.
Adds focused tests for model forward paths, from_state_dict round trips, converters, dictionary helpers, AuxT helpers, and zoo registration.
Design notes
DCAE and SAAF share the same outer entropy topology:
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_dict only infers constructor kwargs from the converted CompressAI layout; it does not directly accept every upstream checkpoint layout.
Commits
Commit
Scope
feat(layers): lift dictionary cross-attention building blocks to compressai.layers.attn
Shared dictionary attention primitives
feat(models/_helpers): add SharedDictionary and DictionaryMeanScaleContextHead
DCAE / SAAF dictionary context wiring
feat(models): add DCAE with containerized codec
DCAE model + converter support
feat(models): add AuxT primitives, helpers, and TCM use_auxt opt-in
AuxT helpers, wavelet wrappers, TCM integration
feat(models): add SAAF with containerized codec and integral AuxT
SAAF model + converter support
test,zoo: cover and register DCAE SAAF and AuxT
Zoo entries and focused tests
Test plan
uv run pytest tests/test_models.py tests/test_models_helpers.py tests/test_layers.py -q
uv run pytest tests/test_zoo.py -q
uv run pytest tests/test_latent_codecs.py -q
uv run ruff format --check compressai tests examples
uv run ruff check compressai tests examples
Notes for reviewers
DCAE-private and SAAF-private backbone blocks are intentionally kept inside their model files because they are not currently reused by other models.
The dictionary context helper is shared because it is used by both DCAE and SAAF.
AuxT is factored into _helpers.auxt because it is used by SAAF and optionally by TCM, and is expected to be reusable by future models with the same side-branch pattern.
ResidualBottleneckBlockWithStride and ResidualBottleneckBlockWithUpsample seem more model-specific than their names suggest. I would keep them inside the relevant model files, even if that means a tiny bit of duplication.
Rename MutiScaleDictionaryCrossAttentionGLU to MultiScaleDictionaryCrossAttentionGLU.
For TCM/AuxT, I think we can reduce the amount of TCM-specific alteration by making the augmented transforms the actual g_a / g_s.
Suggested changes:
Add AuxTTransform to compressai/models/_helpers/auxt.py:
Avoid adding extra from_state_dict() compatibility paths unless needed. The converter should produce the final expected key layout.
Any other modifications needed.
Please also check whether any related comments, docstrings, or exports need to be updated after these changes.
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
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.