|
FZGPUModules 2.0
GPU-accelerated modular compression pipelines
|
Header: modules/fused/ginterp/ginterp_stage.h Class: fz::GInterpStage<TInput, TCode> Category: Fused predictor + quantizer (lossy)
Common instantiation:
Multi-level spline-interpolation predictor with error-bounded quantization, ported from the cuSZ-Hi compressor.
G-Interp typically yields a higher compression ratio than LorenzoQuantStage on smooth scientific data (climate fields, simulation snapshots, etc.) at the same error bound. It is the prediction stage used in the cuSZ-Hi compressor.
LorenzoStage ships in two flavours — the lossless plain predictor and the fused LorenzoQuantStage — because the Lorenzo prediction at each cell reads only the original input values of its neighbours. The quantizer is a clean post-processing step that can be applied (or not) independently.
G-Interp does not work that way. The forward pass is an interpolation pyramid: coarsest-level anchors are exact, then each finer level is predicted from quantized-and-reconstructed coarser-level samples. Each finer level depends on the lossy reconstruction of every coarser level — exactly the reconstruction the decoder will see — because that's the only way the encoder can guarantee its error bound matches what the decoder produces. The decoder mirrors this: it must walk the same tree using the same quantizer to recover each level before moving to the next.
If you removed the quantizer, there'd be no value to feed into the next level's prediction, so the kernel can't run. Splitting into a "pure G-Interp predictor" + "separate quantizer" stage would either (a) require the predictor to re-implement the quantizer internally just to feed itself, making the split cosmetic, or (b) reduce the algorithm to a single-level predictor, which throws away the multi-level CR gain that motivates using G-Interp in the first place.
So unlike Lorenzo, the prediction-quantization coupling here is intrinsic to the algorithm — G-Interp ships only as the fused stage.
| Parameter | Constraint |
|---|---|
| TInput | float or double. Both run the same dynamic-shared-memory kernels — there is no separate float/double code path. The 3-D double path needs a Volta-or-newer GPU (opt-in dynamic shared memory ≥ ~77 KB); 2-D native64 needs opt-in shared memory for double too (≥ 67,600 B). See "Precision and shared memory" below. |
| TCode | uint8_t, uint16_t, or uint32_t |
Only these types are compiled and linked:
Both precisions are supported by the same c_spline_infprecis_data / x_spline_infprecis_data kernel templates. Those kernels stage two working tiles (data + ectrl) in dynamic shared memory (extern __shared__, sized by the launcher), unconditionally — this is not a double-only branch:
| Setting | Type | Default | Purpose |
|---|---|---|---|
| setErrorBound(eb) | float | 1e-3 | Target absolute bound (see "Error bound" below) |
| setErrorBoundMode(mode) | ErrorBoundMode | ABS | ABS, NOA, or PREL. REL warns and maps to PREL — like LorenzoQuantStage, this stage has no exact per-element relative bound |
| setQuantRadius(r) | int | 0 (auto) | Quantization radius — see "Radius auto-tune" below |
| setOutlierCapacity(c) | float | 0.10 | Fraction of N reserved for outliers (0.10 ⇒ 10%) |
| setValueBase(v) | float | 0 | Pre-computed value_range (NOA) or max(abs(data)) (PREL); skips the range scan |
| setAutoTuning(mode) | uint8_t | 0 | Enable INTERPOLATION_PARAMS auto-tuning — see "Auto-tuning" below |
| setManualAlphaBeta(α, β) | double, double | 0, 0 | Mode 5 only. Either value 0 falls back to the cuSZ-Hi piecewise-linear α schedule / β = 4.0 default. Both > 0 skips the rel_eb scan. |
| set2DGeometry(g) / geometry_2d | GInterp2DGeometry / string | fine16 | 2-D kernel geometry: fine16 (default) or native64 (native cuSZ-Hi compatibility); ignored for 3-D. |
fine16 is the default and keeps the established FZGM 2-D configuration: LEVEL=4 with one 16×16 tile per grid block. Select native64 only when a 2-D native cuSZ-Hi-aligned comparison needs it; it instantiates the active native geometry, LEVEL=6 with one 64×64 tile per grid block.
The native layout retains the upstream sparse anchor convention: its anchor buffer is allocated and zeroed at N / 16 elements, while only the native 64×64 anchor positions are written. This is deliberately not interchangeable with the dense-looking fine16 anchor layout. Geometry is carried in the stage configuration/header, so an archive is decoded with the geometry it was written with.
For TOML, omit geometry_2d (or write "fine16") for the default; opt in explicitly for a native-aligned 2-D run:
setQuantRadius(0) (the default) means auto-tune. On first execute(), the stage scans min/max of the input and picks the smallest radius such that every residual fits in [-radius, radius) at the worst-case multi-level error. The result is clamped to the TCode bit-width's maximum (127 for uint8_t, 32767 for uint16_t / uint32_t).
If the upstream mode is REL or NOA, the same scan that already happens for the error-bound conversion is reused — auto-tune adds no extra D2H.
Set the radius explicitly to any positive value to skip the scan:
The manual path is useful for:
The auto-tuned radius is cached in the serialized header on first compress, so the decompressor never needs to know which mode was used.
cuSZ-Hi's compression ratio depends heavily on the per-level interpolation choices encoded by INTERPOLATION_PARAMS (alpha, beta, and the three use_md / use_natural / reverse boolean arrays). By default the stage runs the deterministic baseline (alpha=1.75, beta=4.0, use_md={true,true,false,false,false,false}, use_natural/reverse all false), which is the safe choice when the data distribution is unknown.
Enable auto-tuning to pick those flags per-dataset:
| Mode | Probe kernel | What it sets | Dim | Host sync |
|---|---|---|---|---|
| 0 | none | (off; baseline) | 2-D + 3-D | no |
| 1 | c_spline_profiling_data (2 errors, ~1 ms) | reverse[0..3] only (one global bool replicated) | 3-D only | yes |
| 2 | c_spline_profiling_data_2 (6 errors, ~1 ms) | single use_natural × reverse replicated across all levels; clears use_md | 2-D + 3-D | yes |
| 3 | pa_spline_infprecis_data workflow=true (18 errors 3-D / 27 errors 2-D, ~5–15 ms) | use_md / use_natural / reverse per level (cuSZ-Hi paper mode) | 2-D + 3-D | yes |
| 4 | mode 3 + pa_spline_infprecis_data workflow=false (+11 errors, ~10–20 ms total) | mode-3 flags plus sweeps 11 (alpha, beta) combos and picks the lowest-error | 2-D + 3-D | yes |
| 5 | none (manual override) | resolved alpha / beta (user-supplied or piecewise-linear default); structural flags stay at baseline | 2-D + 3-D | no |
Mode 2 — alternate cheap probe. Runs c_spline_profiling_data_2, which writes 6 errors covering forward/reverse × {cubic, natural} on a tiny shared-mem sample. Picks one global use_natural (sum-based vote) and one global reverse (margin-based vote: 3× in 3-D, 2× in 2-D) and replicates both across all levels, clearing use_md. Cheaper than mode 3 by ~10× and works on both 2-D and 3-D inputs (unlike mode 1). Good middle ground when mode 1's single decision feels too coarse but mode 3's cost is too high.
Mode 4 — alpha/beta sweep. Adds a second pass on top of mode 3 that probes 11 (α, β) combinations enumerated by cuSZ-Hi pre_compute_att (SPLINE3_AB_ATT): α ∈ {1.0, 1.25, 1.5, 1.75, 2.0}, β ∈ {2.0, 3.0, 4.0} (full grid for α ≥ 1.5; β=2.0 only for the lower α values). The combo with the lowest error becomes the resolved α/β. Use mode 4 for offline workflows where the extra ~10 ms is worth the CR improvement vs mode 3 (typically 2–5%).
Mode 5 — manual alpha/beta override. No profiling kernel runs, so the path has no profiling sync and works on both 2-D and 3-D inputs. Set via setManualAlphaBeta(alpha, beta). Passing 0 for either field falls back to the cuSZ-Hi piecewise-linear alpha schedule (keyed on rel_eb) or beta = 4.0. The structural flags (use_md / use_natural / reverse) stay at baseline.
Common patterns:
Profiling modes (1/2/3/4) synchronize the host. Each probe ends with a D2H of the error array and a cudaStreamSynchronize. Modes 0 and 5 avoid every in-execute() sync when combined with a manual setQuantRadius(...) and either ABS mode or a setValueBase(...) (REL/NOA); for mode 5, also setManualAlphaBeta(α>0, β>0) to skip the rel_eb-based α picker.
The resolved INTERPOLATION_PARAMS are embedded in the FZM stage header at compress time, so the decompressor reuses them verbatim — there is no re-tuning on the inverse path.
The error bound eb is a target, not a hard guarantee. The multi-level interpolation tree predicts finer-level values from already-lossy coarser-level reconstructions, so prediction errors can accumulate across levels. In practice the maximum element-wise error is:
Other limitations:
| Index | Port | Type | Size |
|---|---|---|---|
| 0 | codes | TCode | N |
| 1 | anchor | TInput | ~N / 4096 |
| 2 | outlier_vals | TInput | up to outlier_capacity * N |
| 3 | outlier_idxs | uint32_t | up to outlier_capacity * N |
The outlier count is not a DAG output port. It lives in a stage-private 4-byte device scratch (allocated in onFinalize() via pool->allocatePersistentDevice), is D2H'd in postStreamSync(), and is serialized into the FZM stage header. The inverse path receives it as a uint32_t kernel-launch argument — read from the deserialized header — so the scatter kernel never has to dereference a device pointer to know its loop bound. The count is also retrievable post-compress via getActualOutputSizesByName().at("outlier_idxs") / sizeof(uint32_t), since postStreamSync() trims the indices size to the real count.
Connect downstream stages to the codes port:
Four inputs (in the order above) → one output (reconstructed TInput[N]).
GInterpConfig (~96 bytes) — fits comfortably in FZM_STAGE_CONFIG_SIZE (128 B). Stores error_bound (a double, so the resolved absolute bound survives the round-trip at full precision for double inputs), quant_radius (the resolved value, never 0 by the time it lands here), dim_x/y/z, anchor extents, eb_mode, input_type / code_type, the user-specified user_eb, and the resolved value_base for NOA/REL. Note: widening error_bound from float to double shifted the on-disk layout, so .fzm files written before double-input support will not deserialize against this version.
GInterpStage ports the spline interpolation kernels from the cuSZ-Hi compressor (Indiana University, Argonne National Laboratory), BSD-3-Clause. The host-side wrapper, memory-pool integration, outlier-fusion contract, and radius auto-tune are FZGPUModules code. See THIRD_PARTY.md for the full license text.
Shixun Wu, Jinwen Pan, Jinyang Liu, Jiannan Tian, Ziwei Qiu, Jiajun Huang, Kai Zhao, Xin Liang, Sheng Di, Zizhong Chen, Franck Cappello. Boosting Scientific Error-Bounded Lossy Compression through Optimized Synergistic Lossy-Lossless Orchestration (cuSZ-Hi). SC '25. https://doi.org/10.1145/3712285.3759798