Skip to content

Move zfp from the 0.3.1 codec to CODEC 5 - #146

Merged
ayzk merged 1 commit into
fzfrom
zfp-on-fz
Sep 15, 2026
Merged

ayzk merged 1 commit into
fzfrom
zfp-on-fz

Conversation

@ayzk

@ayzk ayzk commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Replaces the vendored zfp 0.3.1 (May 2015) with CODEC 5 from zfp 1.0.1, as two composable
FZ modules rather than a fused compressor.

  • ZFPDecomposition does the exponent alignment, cast, transform and negabinary reorder,
    and carries no error bound. ZFPEncoder takes the bound and runs the embedded coder.
  • ALGO_ZFP is those two plus Lossless_bypass, so the algorithm and a hand-wired
    pipeline are the same thing. ZFPCompressor is gone.
  • 1D/2D/3D, float and double; 4D rejected rather than instantiated.
  • The vendored tree mirrors upstream's layout. NOTICE lists the four edits.

Streams are byte-identical to upstream zfp 1.0.1 wherever upstream's own output is defined
(640/640 configurations, cross-checked by decoding SZ3's streams with libzfp). 54/54 tests.

Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 15, 2026 15:22
@ayzk

ayzk commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator Author

zfp modules vs native zfp 1.0.1

Same absolute bound on both sides, best of 3, single thread, Apple M-series.

field eb (of value range) CR FZ comp zfp comp FZ decomp zfp decomp
hurricane CLOUDf48 0.001 23.49 1359 1514 1418 2347
hurricane CLOUDf48 1e-06 9.05 1142 1248 959 1356
hurricane Pf48 0.001 9.08 527 533 786 858
hurricane Pf48 1e-06 2.51 374 377 358 392
miranda density 0.001 20.63 558 563 1259 1389
miranda density 1e-06 7.73 408 403 741 831
nyx baryon_density 0.001 149.89 1155 1221 2431 2950
nyx baryon_density 1e-06 8.97 473 480 655 720
cesm CLOUD 0.001 5.16 525 538 584 673
cesm CLOUD 1e-06 2.37 433 439 357 403

MB/s. Compression ratio and reconstruction are identical on both sides at every point --
the streams are byte-identical, so they are the same bytes.

Compression runs at 0.90-1.01x native, decompression at 0.60-0.92x. The split materialises
a coefficient array the size of the field, which native zfp never writes, and that costs
most where there is least coded data.

These are the modules. SZ_compress additionally runs a whole-input zstd trial whenever the
ratio lands below 3, which drops the two CR < 3 rows to 241 and 267 MB/s. That is the
dispatcher, not this change.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical buffer-capacity and endian-format issues, plus a moderate data-version compatibility issue, block approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Replaces the vendored zfp 0.3.1 integration with zfp 1.0.1 CODEC 5 using composable SZ3 stages for 1D–3D float and double data.

Changes:

  • Adds ZFPDecomposition and ZFPEncoder.
  • Wires ALGO_ZFP through the generic pipeline and removes the fused compressor.
  • Replaces vendored zfp sources and updates tests, documentation, and metadata.
File summaries
File Reviewed change / finding
tools/test/modules/test_zfp.cpp Expands ZFP module and API coverage.
tools/test/modules/test_encoder.cpp Updates encoder test coverage.
tools/sz3/demo/zfp_demo.cpp Removes the obsolete ZFP demo.
README.md Updates bundled zfp documentation.
include/SZ3/utils/thirdparty/zfp/zfptransform.h Vendored CODEC 5 transform source.
include/SZ3/utils/thirdparty/zfp/zfpcodec2.h Vendored CODEC 5 2D codec source.
include/SZ3/utils/thirdparty/zfp/zfpcodec1.h Vendored CODEC 5 1D codec source.
include/SZ3/utils/thirdparty/zfp/zfpcodec.h Vendored CODEC 5 codec definitions.
include/SZ3/utils/thirdparty/zfp/zfp_inst.inc Updates codec instantiation.
include/SZ3/utils/thirdparty/zfp/zfp_codec.hpp Updates the zfp codec wrapper.
include/SZ3/utils/thirdparty/zfp/types.h Vendored zfp type definitions.
include/SZ3/utils/thirdparty/zfp/src/traitsf.h Vendored float traits.
include/SZ3/utils/thirdparty/zfp/src/traitsd.h Vendored double traits.
include/SZ3/utils/thirdparty/zfp/src/template/template.h Vendored codec template support.
include/SZ3/utils/thirdparty/zfp/src/template/revencodef.c Vendored float reverse encoder.
include/SZ3/utils/thirdparty/zfp/src/template/revencode3.c Vendored 3D reverse encoder.
include/SZ3/utils/thirdparty/zfp/src/template/revencode2.c Vendored 2D reverse encoder.
include/SZ3/utils/thirdparty/zfp/src/template/revencode1.c Vendored 1D reverse encoder.
include/SZ3/utils/thirdparty/zfp/src/template/revencode.c Vendored reverse encoder support.
include/SZ3/utils/thirdparty/zfp/src/template/revdecodef.c Vendored float reverse decoder.
include/SZ3/utils/thirdparty/zfp/src/template/revdecode3.c Vendored 3D reverse decoder.
include/SZ3/utils/thirdparty/zfp/src/template/revdecode2.c Vendored 2D reverse decoder.
include/SZ3/utils/thirdparty/zfp/src/template/revdecode1.c Vendored 1D reverse decoder.
include/SZ3/utils/thirdparty/zfp/src/template/revdecode.c Vendored reverse decoder support.
include/SZ3/utils/thirdparty/zfp/src/template/revcodecf.c Vendored float reverse codec support.
include/SZ3/utils/thirdparty/zfp/src/template/encodef.c Vendored float encoder.
include/SZ3/utils/thirdparty/zfp/src/template/encode3.c Vendored 3D encoder.
include/SZ3/utils/thirdparty/zfp/src/template/encode2.c Vendored 2D encoder.
include/SZ3/utils/thirdparty/zfp/src/template/encode1.c Vendored 1D encoder.
include/SZ3/utils/thirdparty/zfp/src/template/encode.c Vendored encoder support.
include/SZ3/utils/thirdparty/zfp/src/template/decodef.c Vendored float decoder.
include/SZ3/utils/thirdparty/zfp/src/template/decode3.c Vendored 3D decoder.
include/SZ3/utils/thirdparty/zfp/src/template/decode2.c Vendored 2D decoder.
include/SZ3/utils/thirdparty/zfp/src/template/decode1.c Vendored 1D decoder.
include/SZ3/utils/thirdparty/zfp/src/template/decode.c Vendored decoder support.
include/SZ3/utils/thirdparty/zfp/src/template/codecf.c Vendored float codec support.
include/SZ3/utils/thirdparty/zfp/src/template/codec3.c Vendored 3D codec.
include/SZ3/utils/thirdparty/zfp/src/template/codec2.c Vendored 2D codec.
include/SZ3/utils/thirdparty/zfp/src/template/codec1.c Vendored 1D codec.
include/SZ3/utils/thirdparty/zfp/src/template/codec.h Vendored codec declarations.
include/SZ3/utils/thirdparty/zfp/src/template/codec.c Vendored codec implementation.
include/SZ3/utils/thirdparty/zfp/src/block3.h Vendored 3D block support.
include/SZ3/utils/thirdparty/zfp/src/block2.h Vendored 2D block support.
include/SZ3/utils/thirdparty/zfp/src/block1.h Vendored 1D block support.
include/SZ3/utils/thirdparty/zfp/NOTICE Updates vendored attribution metadata.
include/SZ3/utils/thirdparty/zfp/LICENSE Includes vendored zfp licensing.
include/SZ3/utils/thirdparty/zfp/intrinsics.h Vendored intrinsic operations.
include/SZ3/utils/thirdparty/zfp/intcodec64.h Vendored 64-bit integer codec.
include/SZ3/utils/thirdparty/zfp/intcodec16.h Vendored 16-bit integer codec.
include/SZ3/utils/thirdparty/zfp/intcodec04.h Vendored 4-bit integer codec.
include/SZ3/utils/thirdparty/zfp/intcodec.h Vendored integer codec support.
include/SZ3/utils/thirdparty/zfp/include/zfp/internal/zfp/types.h Vendored internal type definitions.
include/SZ3/utils/thirdparty/zfp/include/zfp/internal/zfp/system.h Vendored system portability support.
include/SZ3/utils/thirdparty/zfp/include/zfp/internal/zfp/macros.h Vendored internal macros.
include/SZ3/utils/thirdparty/zfp/include/zfp/internal/zfp/inline.h Vendored inline helpers.
include/SZ3/utils/thirdparty/zfp/include/zfp/bitstream.h Vendored public bitstream definitions.
include/SZ3/utils/thirdparty/zfp/fixedpoint64.h Vendored 64-bit fixed-point support.
include/SZ3/utils/thirdparty/zfp/fixedpoint32.h Vendored 32-bit fixed-point support.
include/SZ3/utils/thirdparty/zfp/bitstream.h Vendored bitstream implementation.
include/SZ3/encoder/ZFPEncoder.hpp Adds CODEC 5 framing and encoding; moderate (1 vote): old streams remain incompatible without a version bump or compatibility path; critical (2 votes): framing uses host-endian fields instead of endian-aware serialization.
include/SZ3/decomposition/ZFPDecomposition.hpp Adds the composable ZFP transform stage.
include/SZ3/compressor/ZFPCompressor.hpp Removes the legacy fused compressor.
include/SZ3/api/impl/SZAlgoZFP.hpp Wires the modular ZFP pipeline; critical (2 votes): Lossless_bypass ignores dstCap, allowing oversized streams to overflow the output buffer.
CLAUDE.md Updates project documentation.
.gitignore Updates repository ignore metadata.
Review details

Suppressed comments (2)

include/SZ3/encoder/ZFPEncoder.hpp:82

  • decode receives only the coefficient count, not the number of bytes available in bytes. For a truncated or otherwise malformed ALGO_ZFP payload, this memcpy reads the 16-byte private header before any validation, and the subsequent copy can also read header[1] bytes past the decompressed buffer. Pass the remaining payload length through the generic encoder interface (or validate it in SZGenericCompressor) before reading this header.
        uint64_t header[2] = {0, 0};
        std::memcpy(header, bytes, sizeof(header));

include/SZ3/encoder/ZFPEncoder.hpp:54

  • The new ZFP framing makes existing ALGO_ZFP streams incompatible: the decoder now expects the generic pipeline metadata plus this block-count/coded-length header, whereas the removed compressor wrote the old ZFP layout. However, SZ3_DATA_VERSION remains 3.3.2, so old files are accepted and dispatched to this decoder instead of being rejected as incompatible. Bump the data format version (or add an explicit compatibility path) with this codec replacement.
        // zfp's bitstream does no bounds checking. Record the block count and the coded size so
        // decode() can cross-check them against the length its caller passes.
  • Files reviewed: 66/67 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +28 to +29
return make_compressor_sz_generic<T, N>(ZFPDecomposition<T, Int, N>(), ZFPEncoder<Int, N>(conf),
Lossless_bypass());
Comment thread include/SZ3/encoder/ZFPEncoder.hpp Outdated
Comment on lines +67 to +68
const uint64_t header[2] = {static_cast<uint64_t>(n_blocks), static_cast<uint64_t>(coded)};
std::memcpy(start, header, sizeof(header));
The vendored codec was zfp 0.3.1 (May 2015). CODEC 5 replaced it in zfp 0.5.0 with a
different transform, coder and bitstream, and 0.3.1 is deprecated upstream. This takes
CODEC 5 from zfp 1.0.1.

ZFPDecomposition and ZFPEncoder keep their names and roles: the decomposition does the
exponent alignment, the block-floating-point cast, the transform and the reordering into
negabinary, and carries no error bound; the encoder takes the bound and derives each
block's precision before running the embedded coder. That is where zfp already divides
the work, and the division is clean because upstream's default rounding mode is
ZFP_ROUND_NEVER. It is not clean in one place: upstream also skips the transform for a
block the bound makes irrelevant, which the decomposition cannot know. It skips on the
exponent alone instead -- the exponent is what decides whether the cast's scale factor
overflows, which is the case that matters.

ZFPCompressor is gone. ALGO_ZFP is now the two modules composed with Lossless_bypass, so
the algorithm and a hand-wired pipeline are the same thing. 1D, 2D and 3D in float and
double, as before; 4D is rejected rather than instantiated.

Upstream expands its block codec through macros, one translation unit per (scalar type,
dimensionality), and keeps every stage function static, so its public API starts past
the point a composable pipeline has to cut. Rather than strip static -- as the 0.3.1
copy did by turning protected: into public: -- zfp_codec.hpp repeats that expansion
inside its own namespace and wraps the stages. The NOTICE lists the four upstream edits
that remain.

The streams are byte-identical to upstream zfp 1.0.1 wherever upstream's own output is
defined, and ALGO_ZFP round-trips within the bound in 1D, 2D and 3D. Below 2^-97 in
magnitude upstream's scale factor is infinite and the conversion that follows it is
undefined; there this writes zero coefficients instead, decoding to the same values or
closer ones in a fraction of the bytes (152 against 5000 for a 16^3 float block at 1e-30).

Three inherited zfp behaviours are documented in the NOTICE rather than fixed, because
they are upstream's: the error bottoms out at about 2^-25 of the block maximum for float
and 2^-57 for double whatever bound is asked, so a smooth order-1 float field misses any
bound under about 3e-8; float data below 2^-97 misses a bound under about 4e-28; and NaN
and infinities come back as finite numbers.

.gitignore's bare `test` pattern is anchored to /test. It matched tools/test/ at any
depth, so new test files were silently dropped -- git add and git status both say
nothing, and only a clean checkout shows it.

Co-Authored-By: Claude Opus 5 <[email protected]>
@ayzk
ayzk merged commit c3a7de8 into fz Sep 15, 2026
5 checks passed
@ayzk
ayzk deleted the zfp-on-fz branch September 15, 2026 16:10
ayzk added a commit that referenced this pull request Sep 15, 2026
Brings in the CODEC 5 zfp modules (#146). Five conflicts:

  ZFPCompressor.hpp   deleted on fz, so deleted here. fz-dev had only a <memory>
                      include and two loop-index fixes in it.
  ZFPDecomposition.hpp
  ZFPEncoder.hpp      took fz's. fz-dev's changes were signed/unsigned fixes and an
                      include of intcodec04.h, all against the 0.3.1 code that fz
                      replaced; none of it applies to the new implementation.
  .gitignore          took fz-dev's, a superset -- both sides had anchored `test` to
                      `/test` independently.
  CLAUDE.md           one table row from each side: fz-dev's decomposition names,
                      fz's zfp version. SPERRDecomposition and SPERRFusedDecomposition
                      both exist, so both are listed.

199 tests pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
ayzk added a commit that referenced this pull request Sep 15, 2026
The `pull_request: [closed]` trigger runs on refs/pull/N/merge, which the github-pages
environment does not accept, so it fails every time. It first fired when #146 merged:
run 34993302305 failed while the push to fz at the same moment (34993301679) deployed
the same docs successfully. The push trigger already covers merges into fz.

Co-Authored-By: Claude Opus 5 <[email protected]>
ayzk added a commit that referenced this pull request Sep 16, 2026
…posable (#142)

* Drop 31 no-op ALWAYS_INLINE keywords + fix SDRBench dataset URLs (#140)

* Drop 31 no-op ALWAYS_INLINE keywords

Benchmarking on Anvil (EPYC 7763; GCC 10.2/11.2/14.2, AOCC clang 12) and
locally (GCC 16.2, AppleClang) shows the attribute changes nothing at 31 of
the 49 sites: the compilers already inline these, and removing the keyword
either yields a byte-identical binary or measures zero.

What the data says to keep, and why this is not a bulk removal:

  LinearQuantizer (5) + BlockwiseIterator (9) carry the entire effect.
  Downgrading just those two groups costs ~7.5%; downgrading everything
  else together costs ~0.2%. No single group crosses GCC's inlining
  threshold on its own, so per-group numbers hide this -- it only shows up
  when the two are isolated. They keep the attribute.

  Config.hpp to_lower keeps its inline: it is the only namespace-scope
  non-template among the sites, and without it the library stops linking.

  interp_akima / interp_pchip keep theirs: both are multi-line with
  branches, both currently have no callers, so the byte-identical result
  for them is vacuous and says nothing about future use.

  QuantOptimization.hpp lorenzo_predict_3d keeps its attribute; the
  function is dead code today but is expected to come back.

Deleted rather than downgraded to plain inline: 27 of the 31 are in-class
definitions (implicitly inline) and 4 are namespace-scope templates (already
weak/COMDAT), so no keyword is needed to preserve linkage.

Included here are the two on ComposedPredictor::predict/estimate_error,
which is where GCC 16 actually hard-errors: the class is itself a
PredictorInterface and may nest, so speculative devirtualization recurses
into itself until the inline budget is exhausted -- and a failed
always_inline is an error, not a warning. That is what broke the MinGW CI
job on the fz branch.

Verified: builds clean under GCC 16.2 and AppleClang; ALGO_LORENZO_REG,
ALGO_INTERP_LORENZO, ALGO_INTERP and ALGO_NOPRED all round-trip within the
error bound on the in-tree smoke file and on miranda 384x384x256.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Fix SDRBench dataset URLs: Globus endpoint moved

All eight integration-test datasets return 404. SDRBench moved to a new
Globus endpoint, changing both the host and the path prefix:

  g-8d6b0.fd635.8443.data.globus.org/ds131.2/Data-Reduction-Repo/raw-data/
  g-d0cd3f.fd635.8443.data.globus.org/raw-data/

exaalt-copper and exaalt-helium were also renamed upstream, from
SDRBENCH-exaalt-* to SDRBENCH-EXAALT-*, so the host swap alone still left
those two at 404.

New URLs taken from https://sdrbench.github.io/datasets.html and confirmed
reachable (HTTP 206 on a range request) for all eight. The integration test
matrix covers exactly these datasets, so CI on this PR is the real check
that each archive still unpacks to the filenames datasets.json expects.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>

* Add 12 CPU modules + tests; fix 10 pre-existing bugs

MGARD/SPERR fused paths kept as *FusedDecomposition and still drive
ALGO_MGARD / ALGO_SPERR; the composable compositions take the default names.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Add missing <memory> includes

libstdc++ does not provide std::make_shared transitively; the new test
translation units changed the include order enough to expose it.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Add module acceptance gate

Group-level contract checks (ModuleContract.hpp) and a header self-containment
check, both runnable and wired into CI; docs/MODULE_ACCEPTANCE.md records what a
module must satisfy to enter the library. Each check comes from a defect class
that has shipped here.

Fixes found by the two checks: 9 headers were not self-contained, and
MemoryUtil::read guarded remaining_length with assert, which Release compiles
out, so a truncated stream read past the buffer.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Make every header self-contained under libstdc++ too

The check only ran under libc++ locally, which provides more transitively; 17
headers were missing <limits>, <cmath>, <cstddef>, def.hpp or a project header.
CI now runs the check on the macOS job as well, so a clean run under one
standard library no longer passes for both.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Charge the encoded size when loading regression coefficients

RegressionPredictor::load debited remaining_length by the decoded bin count
(coeff_size * sizeof(int)) while decode() advances the cursor by the much
smaller encoded byte count, so the budget ran out early. Harmless while the
guard in MemoryUtil::read was an assert compiled out of Release builds; now
that it throws, the HDF5 filter path hit it on miranda velocity fields at
eb=1e-4.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Size the HDF5 filter's compressed buffer from SZ_compress_size_bound

sizeof(T) * num * 2 is below SZ_compress's own minimum for a small chunk, so an
explicit chunk of a few hundred elements aborted with "The buffer for
compressed data is not large enough". The integration test now covers an
explicit small chunk alongside the full and auto-chunked cases.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Add the Decomposition group contract

Six decompositions did not override size_est(), so SZGenericCompressor sized
its buffer from 0 while the quantizer's unpredictable list could be arbitrarily
large; three are fixed here and the rest already had one.

The contract also records MGARD's bound limitation: it quantizes coefficients
per level and never checks the reconstruction, so the transform's own round-off
passes through and the absolute bound holds only while max|x| * epsilon<T> << eb.

Also restores the H5Z filter's buffer headroom on top of SZ_compress's minimum.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Make Lossless_bypass respect its destination capacity

compress() memcpy'd srcLen bytes into dst regardless of dstCap, so any payload
larger than the caller's buffer was an unconditional heap overflow.
Lossless_zstd already checks and throws; bypass now does the same.

Caught by AddressSanitizer on Linux: ALGO_BIOMDXTC pairs its codec with
Lossless_bypass, so nothing shrinks the payload, and the HDF5 filter's buffer
was sized from SZ_compress's minimum, which assumes it does. glibc reported it
as "munmap_chunk(): invalid pointer"; macOS's allocator did not abort, which is
why it only showed up in CI. The filter's headroom is restored here too - it
was lost restoring a backup during an earlier A/B.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Account for the selection stream in ComposedPredictor::load

decode() advances the cursor but leaves remaining_length untouched, so the
bound check was too loose for everything read after it. Same defect class as
RegressionPredictor::load, in the opposite direction.

MemoryUtil::read now compares by division so the size computation cannot
overflow on its own.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Complete the module acceptance gate; add the module benchmark tool

Contracts now cover the Lossless group as well; its destination-capacity check
is what Lossless_bypass was missing. Adds tests for SZGenericCompressor's two
guards on get_out_range, which had none.

GranularBitRoundQuantizer's tests move out of test_quantizer_cluster.cpp into
their own file.

tools/bench/module_bench.cpp (BUILD_SZ3_BENCH=ON) measures a composition's
compression ratio, achieved error and throughput on a real dataset and prints
CSV. Module characteristics can only be measured, not authored, so this is the
piece the composition metadata will need.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Bring the docs level with the modules

modules.json was missing 8 modules; CLAUDE.md's quantizer list predated five of
them and had no preprocessor list at all. Both now also point at the acceptance
gate and the benchmark tool.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Install the group contracts; record composition constraints

ModuleContract.hpp moves to include/SZ3/testing/ so it ships with the library:
the gate is meant to apply to modules submitted from outside this tree, which
cannot reach a header under tools/test/.

modules.json gains a `composition` block on the 13 modules that constrain what
they can be composed with -- an encoder that cannot derive its own bin range, a
decomposition that only works with one encoder, bins that are not a countable
domain, the regime an error bound holds in, a measured bad pairing. These are
the facts a composition engine needs before any measured characteristic, and
each one is already enforced by a test or by the code. SZ3_ModulesJson checks
the file against the tree so the two cannot drift.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Make MGARD honour its error bound unconditionally

MGARD quantized coefficients per level and never checked the reconstruction, so
the synthesis round-off -- which scales with the field's magnitude -- passed
through. For float at eb = 1e-2 a magnitude of 1e6 reached 1.17x eb and 1e7
reached 6.25x; every other decomposition checks the value it writes back and
diverts to an unpredictable list.

Both MGARD compositions now replay the decoder's inverse transform and record
what still misses into an OutlierQuantizer, carried in save() the way
LinearQuantizer carries its unpredictable list.

Costs an inverse transform and a copy of the input on the compress side:
miranda velocityx 301 MB, 500 -> 293 MB/s compressing, decompression and
compression ratio unchanged (201.35 vs 201.36 at relative eb 1e-2).

Changes the ALGO_MGARD stream only; the other seven algorithms are byte-identical.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Record what the MGARD outlier pass costs

The bound now holds unconditionally, but not for free everywhere: outliers cost
nothing where the transform already met the bound, trade compression for the
bound where it did not, and degenerate to near-lossless on a field that leaves
the per-level quantizer saturated. The measured numbers are in the header.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Give each branch and pull request one CI run at a time

Every push added a full matrix without retiring the one in flight, so the long
integration jobs of older runs were evicted mid-test instead of finishing --
hacc and exaalt-helium died at 13-17 and 25-30 minutes across three runs while
the same jobs completed in 2h10m and 46m on a branch that was not being pushed
to repeatedly.

master and fz still keep every commit's build result; only feature branches and
superseded pull-request runs are cancelled.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Consolidate the pending bug fixes: 8 open PRs plus the fz-branch findings

Bug fixes only. Nothing here changes the compressed format or an interface
signature, and every algorithm's output is byte-identical to master's (verified
over 31 dataset/algorithm/error-bound combinations, plus decompressing files
master produced).

From the open pull requests, reviewed line by line:

  #131  Config::load read one byte past the end of the config blob
  #132  bounds-check the whole decompression path (see the two skips below)
  #133  shift-by-64 UB for a single-symbol Huffman tree
  #134  bounds-check HuffmanEncoderV2 tree loading
  #135  bounds-check XtcBasedEncoder's magicInts index; plug a leaked buffer
  #137  remaining_length accounting after Huffman decode in both predictors
  #138  non-finite float to int64_t cast UB in LinearQuantizer
  #139  scratch buffers leaked when compression throws; OMP chunk capacity was
        missing room for the size header Lossless_zstd writes

Two parts of #132 are deliberately not taken:

  - It moves the quant_inds count from after the encoder's tree to before it so
    the tree is immediately followed by its encoded stream. That is a compressed
    format change and it is not versioned, so files written by any released SZ3
    fail to decode. The bound it was buying is recovered instead by letting the
    caller supply it: HuffmanEncoder::set_decode_bound(), called by
    SZGenericCompressor once it has consumed the count, and by both predictors.
    load() no longer guesses the bound from its own buffer -- the tree and the
    stream are not required to share a buffer, and test_encoder.cpp puts them in
    separate ones.
  - It reinterprets LosslessInterface::decompress's `dstLen` as an input
    capacity when the caller provides the buffer. The declared contract is that
    it is an output, and callers do pass uninitialised values, so this fails
    nondeterministically (it broke LosslessTest.LosslessBypass here). The
    self-allocating branch, where a non-zero value is opt-in, is kept.

Also fixed while reviewing:

  - HuffmanEncoderV2 sized its dense tables from an unbounded `maxval` read
    straight from the stream; #134 bounds the node count but not this.
  - HuffmanEncoderV2's node count is an int holding a value read as 64-bit, so
    the new bound is checked with an explicit sign test rather than an implicit
    conversion.
  - test_lossless.cpp passed an uninitialised size to decompress().

From the fz branch, verified to reproduce here:

  Lossless_bypass::compress ignored its destination capacity, so any payload
  larger than the caller's buffer was an unconditional heap overflow;
  TimeSeriesDecomposition violated its error bound 1.94x on the
  null-reference-frame path; ArithmeticEncoder sign-extended a shift, corrupting
  about half of all streams; HuffmanEncoder's stateNum narrowing overflowed on a
  wide bin range; RunlengthEncoder and two decompositions had no size_est(), so
  the compressor sized its buffer from 0; KmeansUtil had reserve+operator[] UB
  and an off-by-one read; the HDF5 filter sized its buffer below SZ_compress's
  own minimum; 24 headers were not self-contained under libstdc++ or libc++;
  .gitignore's bare `test` pattern hid every test file.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Restore PR #135's XtcBasedEncoder bounds

Taking the fz-branch fixes file by file overwrote them. The magicInts index
and the packed-data size both come from the compressed stream and were used
unchecked.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Compare by division in the bounded array read

num_elements * sizeof(T1) can overflow on its own, which is the computation the
check is supposed to guard. Matches the scalar overload and PR #132.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Drop PR #132's bound on the internal decompression buffer

It bounds that buffer by SZ_compress_size_bound, which is the size of the
*output* buffer. compress() sizes the internal one as max(1000, 2 *
(decomposition.size_est() + encoder.size_est() + sizeof(Q) * bins)), so for a
64-bit bin type it is far larger and valid streams are rejected. Every module in
this tree emits int bins, so the bound happens to hold and these tests cannot
reach it -- the fz branch has three modules that do (BitplaneEncoder,
BitTruncationQuantizer, FixedPointQuantizer) and all three failed.

A corrupted declared size is still caught, after the allocation, by the zstd
frame check and the size comparison this PR adds to Lossless_zstd::decompress.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Validate config contents only for a compressed-stream trailer

PR #132 rejects N outside [1, 4] and dimensions whose product differs from the
element count. Both hold for a config read from the end of a compressed stream,
and neither holds for the HDF5 filter's cd_values: those carry placeholder zeros
that set_local fills in later, as cdvalueHelper.py says in as many words. The
check killed the whole filter -- 80 of cesm-atm's 160 integration cases aborted
with "invalid number of dimensions", across every algorithm.

The single-argument overload, which is what the filter and the OpenMP path use,
now says so explicitly and skips the content checks; the bounded overload used
by SZ_decompress keeps them.

Verified against the real cesm-atm field through the HDF5 filter: five
algorithms pass, and removing the guard reproduces the abort.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Validate config contents only for a compressed-stream trailer

The check PR #132 adds for N outside [1, 4] and for dimensions whose product
differs from the element count holds for a config read from the end of a
compressed stream, and not for the HDF5 filter's cd_values: those carry
placeholder zeros that set_local fills in later, as cdvalueHelper.py says in as
many words. It killed the whole filter -- 80 of cesm-atm's 160 and 96 of
exaalt-copper's 192 integration cases aborted with "invalid number of
dimensions", across every algorithm.

Verified against the real cesm-atm field through the HDF5 filter.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Bound the integration build's parallelism

A bare "-j" means unlimited parallel compilation. This tree now has 56
translation units against master's 9, and they pull in MGARD, SPERR and Eigen,
so the peak at link time is enough to get a 15 GB runner terminated: hacc died
three times at exit 143 immediately after "100% Linking CXX executable
sz3ToHDF5", with no error of its own, 86 GB of disk still free and every other
dataset passing.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Make the integration test's output survive a killed job

Python block-buffers stdout into the log pipe, so everything the driver prints --
including the captured output of every test it runs -- is lost when the job is
terminated. The log then stops at the last write from a subprocess, which is the
build, and says nothing about where the run actually died. hacc has failed four
times with exit 143 and a log that ends at the same line; that line is where the
visible output stops, not where the failure is, and two hypotheses I drew from it
were wrong for exactly that reason.

Runs the driver with -u, and flushes around dataset preparation so the phase is
identifiable even without it.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Stream each integration case's output instead of capturing it

capture_output=True prints the child's output only after it exits, so a case that
never returns leaves no trace of how far it got. hacc has now failed five times;
the log ends at the "command:" line for its first case -- a single 1.12 GB field
written as one chunk -- and everything that case printed is still invisible.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Bound the HDF5 filter test's small-chunk mode

The mode asked for 8-element chunks over the whole field. On a 1D field of 280
million elements that is 35 million chunks, and the HDF5 chunk index alone took
the process to 15.3 GiB of a CI runner's 16 GiB -- hacc and exaalt-helium were
killed there. Restricting the mode to a leading slice of at most 4096 chunks
brings the peak to 9.6 GiB and leaves the mode's coverage intact: an unfixed
filter still fails it on every algorithm at ordinary dataset sizes.

Also stop tracking a stray __pycache__ entry.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Register the four newer algorithms in the HDF5 cd_values helper

The helper's name-to-enum map stopped at ALGO_BIOMDXTC, so ALGO_SVD, ALGO_ZFP,
ALGO_SPERR and ALGO_MGARD could not be requested through the HDF5 filter at all.
All four round-trip correctly through the filter, on the in-tree smoke file and
on a 256x384x384 field, in every chunk mode.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Cover the HDF5 filter's compressed-buffer sizing

The filter has to size its output buffer from SZ_compress_size_bound rather than
from the raw chunk size, and nothing in the suite exercised that: a chunk small
enough for the compressed block to exceed it never appeared. This adds a third
chunk mode that asks for 8-element chunks, which the pre-fix filter rejects with
"buffer not large enough" on every algorithm.

The mode is restricted to a leading slice of at most 4096 chunks. Over a whole
field it would mean tens of millions of chunks, and the HDF5 chunk index alone
takes the process past a CI runner's memory.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Stop the docs workflow from deploying on a closed pull request

The `pull_request: [closed]` trigger runs on refs/pull/N/merge, which the github-pages
environment does not accept, so it fails every time. It first fired when #146 merged:
run 34993302305 failed while the push to fz at the same moment (34993301679) deployed
the same docs successfully. The push trigger already covers merges into fz.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Drop the two capability traits the merge made unnecessary

quantizer_size_est() detected whether a quantizer has size_est(). QuantizerInterface now
declares it with a default of zero, the way DecompositionInterface already declares its own,
so every quantizer answers and the detection is not needed. The four that had none encode
every value and have no unpredictable list, which is what zero means.

encoder_has_decode_bound detected set_decode_bound(), which decode()'s byte-budget parameter
replaced; nothing called either, and the member the setter wrote was read by a check that
could no longer fire.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Take out what the merge and the review left behind

The include unions the merge produced left five headers including the same thing twice.
Two comments in HuffmanEncoder described members the previous commit removed, one of them
sitting above an unrelated field; two of its checks repeat the loop bound `maxBits` already
enforces, one per bit of the decoded stream. InterpolationDecomposition's only change was a
comment saying the same thing at greater length, and an include it does not use; so were
the <limits> in the two predictors and the blank lines in BlockwiseIterator.

SZAlgoZFP asserts without including <cassert>; it had been getting it through a header that
no longer offers it.

module_bench has no caller — no workflow, no test, no documentation outside its own option.
It measures rather than asserts, so it cannot become a test, but it belongs with them rather
than behind an option of its own.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Fix the doubled include guard and a stray blank line

SPERRDecomposition guards on SZ3_SZ3_SPERR_DECOMPOSITION_HPP. No guard in the tree collides,
so nothing was being skipped, but the name says the file twice.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Say what the module contract covers, and list the uid it omits

The contract header claimed every module in the library passes it and pointed at a file that
does not exist. Eight do not: OutlierQuantizer deliberately, since it is a second pass held
inside three decompositions whose bins never reach SZGenericCompressor, so its range spans the
bin type instead of starting at zero.

The uid table in the add-module skill lists eight of the nine in use. A module author picking
the next free value from it lands on OutlierQuantizer's, and a uid collision is read as the
wrong quantizer's state rather than rejected.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Put the three decompositions the contract skipped under it

PaSTRI, SPERRFused and the composable SPERR implement the decomposition interface and pass
the group contract unchanged — they were simply never registered. A contract only holds what
it is pointed at, so a module outside it can be broken by an unrelated change and nothing
says so.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Put the two bit-plane encoders under the contract as well

Both are general-purpose encoders that compose with any decomposition, and both pass the
group contract unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Deduce the bin type from a typedef, and hold callers to it

QuantizerInterface takes To as a template parameter but never published it, so a decomposition
wanting to forward its quantizer's bin type had to recover it from the return type of
quantize_and_overwrite. The interface now exposes it as bin_type, which every quantizer
inherits, and quantizer_bin_t goes away with its twenty lines of explanation.

The deduction is a default argument, so it only holds while the caller leaves To alone. Passing
a To the quantizer does not emit compiled silently and narrowed every bin on assignment --
5e9 from a FixedPointQuantizer arrived as 705032704. NoPrediction already asserted against that;
MultiLevel and Blockwise now do too.

module_bench builds with the tests since it moved there, which on MinGW means building the
SPERR and MGARD pipelines it exists to compare, and those are disabled on MinGW.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Name the bin type by the interface's own word, and clear the merge residue

SZGenericCompressor recovered the bin type from the return type of compress(), the same decltype
shape quantizer_bin_t used. compress() is a pure virtual override, so that type is always the To
the decomposition declared: DecompositionInterface publishes it as bin_type and the compressor
reads it, under the interfaces' own name To.

Five quantizers did not say override on size_est(). Four are caught by -Wsuggest-override;
LinearQuantizer's is non-const, so it hid the interface's virtual rather than overriding it, and
a call through a base reference would have reported an empty unpredictable list.

The rest is residue: doubled blank lines in four headers, a comment restating the line under it,
and a Runlength doc block left above the wrong function when its duplicate size_est() went.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Find Eigen's headers when CMake found it through its config

Eigen3_DIR names the directory holding Eigen3Config.cmake, which is never the directory holding
Eigen/Dense. The check guessed one sibling, eigen-src, which is right only for the FetchContent
build tree; against an Eigen installed under a prefix -- conda, spack, a non-default homebrew --
every header that reaches stdafx.hpp was reported as not self-contained. It now walks up to the
prefix that owns Eigen/Dense.

84 headers, 0 not self-contained, against an Eigen from a mamba environment.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>

This branch had an error being deployed

1 failed deployment
github-pages — 7fc6a09c Deployed Sep 15, 2026 by ayzk via deploy #28
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.

2 participants