Skip to content

feat(compression): update tooling to use DECODE operators - #3647

Draft
rkuester wants to merge 9 commits into
tensorflow:mainfrom
rkuester:feat-decode/queue
Draft

feat(compression): update tooling to use DECODE operators#3647
rkuester wants to merge 9 commits into
tensorflow:mainfrom
rkuester:feat-decode/queue

Conversation

@rkuester

@rkuester rkuester commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

This is a draft PR for running CI, review, and seeing the commits in
context. The commits along this branch will be individually submitted
for merge.

This replaces #3574, whose head branch was renamed to
feat-decode/queue for a stacked-commits workflow; renaming a fork
branch closes its cross-repo PR, so the draft is reopened here with
the same content under the new head.

See the linked issue for a description of the change.

BUG=implements #3256

An upcoming change switches compress() to emitting DECODE-based
models. The Python ops resolver registers the DECODE operator
unconditionally, so those models load successfully even in a build
without compression support. That breaks this test's original
approach, which ran a model through compress() and expected the load
to fail. Rewrite it to instead inject a raw COMPRESSION_METADATA
entry into the flatbuffer via model_editor, directly exercising the
HasCompressionMetadata() detection path for legacy-compressed models.

Decoupling the test from compress() output lets it verify the
legacy-rejection behavior independently of what compress() emits, so
it passes both before and after the switch.

BUG=part of tensorflow#3256
Replace monolithic compression logic with a dispatch table that routes
compression requests to plugin modules based on the spec's compression
method type. After compressing tensors, insert DECODE operators into the
model graph.

Warn when compression expands data, helping users identify tensors that
don't benefit from compression.

BUG=part of tensorflow#3256
Add tests that compress models with LUT compression, run them through
the TFLM Python interpreter, and verify outputs match uncompressed
originals. Cover per-tensor and per-channel quantization, various index
bitwidths, unquantized weights, and alternate decompression memory.

BUG=part of tensorflow#3256
Add a manual test for verifying compression on proprietary models that
can't be checked into the repository. See the module docstring for usage
instructions.

BUG=part of tensorflow#3256
Explicit inheritance from Protocol enables static type checking at
definition time and makes the interface self-documenting.

BUG=part of tensorflow#3256
The DECODE kernel and its dependencies are already compiled
unconditionally -- none are guarded by USE_TFLM_COMPRESSION. Remove the
#ifdef around AddDecode() in PythonOpsResolver so DECODE-based
compressed models work in a default Python build.

Remove the with_compression_enabled gating from compression and
proprietary integration tests, since they use DECODE-based models that
no longer require the flag.

BUG=part of tensorflow#3256
Add a test in which a CONCATENATION reads one compressed and one
uncompressed constant input. Insertion must decode only the compressed
tensor and leave the uncompressed input untouched. The existing tests
pair compressed weights with activations, so none of them pin the
behavior for an uncompressed constant beside a compressed one.

BUG=part of tensorflow#3256
An empty spec list passed to compress() previously returned an
unmodified model silently. Fail early with a clear error instead,
since an empty spec is almost certainly a mistake.

BUG=part of tensorflow#3256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant