Code, run data and analysis for the paper of that title, at the Computer Vision for Earth
Observation (CV4EO) workshop at WACV 2027. Checkpoints:
ERISLab/Benchmark-QuantizedHSIC on
Hugging Face.
The paper quantizes the weights of five hyperspectral image classification (HSIC) models after training, at 1 to 8 bits, with two calibration-free backends: Half-Quadratic Quantization (HQQ) and optimum-quanto (Quanto). Weights at 4 bits and below are also run with 8- and 4-bit activations. The models are SpectralFormer, SpectralFormer-CT, MViT, MassFormer and Spectral-Spatial Mamba (SS-Mamba). The datasets are three Earth scenes (Indian Pines, Pavia University, Houston 2013) and three Mars scenes from CRISM (Utopia Planitia, Nili Fossae, Holden Crater).
conda create -y -n qhsic python=3.12.13 && conda activate qhsic
pip install -r requirements.txt
# SS-Mamba (--model ssm) only, from the prebuilt wheels that match the pinned torch, Python and C++ ABI:
pip install causal-conv1d==1.7.0 mamba-ssm==2.3.2.post1requirements.txt is the pip freeze of the environment the runs used (Python 3.12.13, CUDA 12.8,
one RTX 3090). Everything runs as modules from the repository root.
Datasets download on first use into dataset/ under the working directory, about 1.6 GB in all.
Houston 2013 comes from Kaggle and needs no credentials. The URLs in
qhsic/data_utils/download_dataset.py for Pavia University and Indian Pines return 403, so place
these four files in dataset/ by hand, from any mirror of the standard scenes:
PaviaU.mat, PaviaU_gt.mat, indian_pines_corrected.mat and indian_pines_gt.mat.
hf download ERISLab/Benchmark-QuantizedHSIC --local-dir .This places results/<dataset>_<model>_<serial>_seed<s>/ckpt.pt, 1,230 full-precision checkpoints:
the main grid (serial 60000, 150), the label budgets (60101–60104, 600), the width ladder
(60201–60203, 360) and the token ladder (60301–60304, 120). Each ckpt.pt holds state_dict and
config, the training arguments, with the W&B entity and project the run was launched under.
config may record an earlier serial and, for SpectralFormer-CT, the model key sf; the directory
name gives the serial in docs/SERIALS.md and the model key. The run CSV records each
checkpoint's SHA-1 in ckpt_sha1.
bash analysis/plotter.shNo GPU and no W&B account are needed. analysis/data/runs_Hyperspectral_QHSIC.csv holds all
12,386 runs, so the download step at the top of the script is skipped; delete the CSV and add
--entity <entity> to that download step in analysis/plotter.sh (or rely on your default W&B
entity) to rebuild it from a W&B project of your own. summarize_class_size reads the ground
truth, so dataset/ must hold the six scenes (see Data). Outputs go to results_paper/, the
supplementary tables as LaTeX to results_paper/supp_tables/.
analysis/verify/verify_paper_numbers.py re-derives 411 values of the main-grid tables by a second
route and fails on any difference above 1e-6.
| Paper | Output in results_paper/ |
Built from |
|---|---|---|
| Table 1, datasets (split sizes) | table_class_splits.csv |
ground truth in dataset/ |
| Table 2, full-precision OA | table_baselines.csv |
run CSV, 60010, 60020 |
| Table 3, group size | table_group_size.csv; BPW from table_effective_bits.csv |
run CSV, 60010; model_geometry.csv |
| Table 4, activations | table_act.csv |
run CSV, 60010, 60030 |
| Table 5, ΔOA at 1 and 2 bits | table_fp_by_model.csv, table_delta_by_bits.csv |
run CSV, 60010, 60020 |
| Table 6, smallest and largest models | table_capacity_curve.csv |
run CSV, 6021x, 6031x |
| Table 7, SS-Mamba attribution | table_ssm_attribution.csv |
run CSV, 6031x–6036x |
| Table 8, effective rank | table_rank_grid.csv |
probe_rank_grid.csv; run CSV, 60010 |
| Table 9, effective rank per size | table_rank_ladders.csv |
probe_rank_width.csv, probe_rank_tokens.csv; run CSV, 6021x, 6031x |
| Table 10, label budgets | table_scarcity_curve.csv |
run CSV, 6011x |
| Table 11, HQQ minus Quanto | table_backends.csv |
run CSV, 60010, 60021 |
| Table 12, Quanto convolution cost | table_quanto_formats.csv (conv_cost_*) |
run CSV, 60020, 60021 |
| Table 13, size and latency | table_effective_bits.csv, table_speed.csv |
model_geometry.csv; run CSV, 60050 |
| Figure 1, ΔOA at 2 to 8 bits | fig_delta_vs_bits_zoom.png |
run CSV, 60010 |
| Figure 2, ΔOA at 1 bit by dataset | fig_one_bit_loss.png |
run CSV, 60010 |
| Figure 3, OA against bit width per model size | fig_capacity_scaling.png |
run CSV, 6021x, 6031x |
| Figure 4, Earth against Mars | fig_earth_vs_mars.png |
run CSV, 60010 |
| Table S1, labeled pixels per class | supp_tables/datasets.tex ← table_class_splits.csv |
ground truth in dataset/ |
| Table S2, effective bits per weight | supp_tables/effective_bits.tex ← table_effective_bits.csv |
model_geometry.csv |
| Table S3, HQQ by bit width and group size | supp_tables/delta_hqq.tex ← table_delta_by_group.csv |
run CSV, 60010 |
| Table S4, OA per dataset | supp_tables/delta_by_dataset.tex ← table_delta_by_model_dataset.csv, table_baselines.csv |
run CSV, 60010, 60020, 60021 |
| Table S5, activations per model | supp_tables/act_by_model.tex ← table_act_by_model.csv |
run CSV, 60010, 60030 |
| Table S6, every model size | supp_tables/capacity.tex ← table_capacity_curve.csv |
run CSV, 6021x, 6031x |
| Table S7, label budgets per model | supp_tables/scarcity_abs_rel.tex ← table_scarcity_abs_rel.csv |
run CSV, 6011x |
| Table S8, Quanto on linear layers | supp_tables/delta_quanto.tex ← table_quanto_formats.csv |
run CSV, 60010, 60021 |
| Table S9, Quanto with convolutions | supp_tables/quanto_conv.tex ← table_quanto_formats.csv |
run CSV, 60020, 60021 |
| Table S10, stored model size | supp_tables/footprint.tex ← table_effective_bits.csv |
model_geometry.csv |
| Table S11, latency | supp_tables/speed.tex ← table_speed.csv |
run CSV, 60050 |
| Figure S1, Quanto ΔOA against bit width | fig_quanto_delta_vs_bits.png |
run CSV, 60021 |
| Figure S2, Quanto ΔOA at 2 bits by dataset | fig_quanto_two_bit_loss.png |
run CSV, 60021 |
Full-precision OA is the OA each evaluation records before it quantizes. The evaluation count in
the abstract, 12,330, is in table_run_counts.csv. The CSVs are written at six decimal places; the
paper rounds them. x in a serial stands for every setting digit of that
family, as in docs/SERIALS.md.
bash analysis/probes.shThis needs a GPU, the checkpoints in results/ and the datasets. It rewrites
analysis/data/probe_rank_grid.csv, probe_rank_width.csv and probe_rank_tokens.csv, which
Tables 8 and 9 read.
docs/SERIALS.md is the serial register: which batch of runs each serial is,
how many runs it holds, and its naming scheme. Each launcher resumes from its log in results/,
and --dry_run as its first argument writes the planned runs instead of launching them.
| Serials | Runs | Command |
|---|---|---|
| 60000 | training, main grid | python -m tools.train --model <m> --dataset <d> --seed <s> --deterministic --serial 60000 |
| 60010 | HQQ weight-only | bash script/sweep.sh |
| 60020 | Quanto with convolutions | LINEAR_ONLY=0 bash script/sweep_quanto.sh |
| 60021 | Quanto on linear layers | bash script/sweep_quanto.sh |
| 60030 | HQQ weights and activations | bash script/sweep_act.sh |
| 60050 | latency and memory | bash script/speed_test.sh |
| 60101–60104, 60111–60114 | label budgets: training, HQQ | bash script/sweep_scarcity.sh |
| 60201–60203, 60211–60213 | width ladder: training, HQQ | bash script/sweep_capacity.sh |
| 60301–60304, 60311–60314 | token ladder: training, HQQ | bash script/sweep_capacity.sh |
| 60321–60364 | SS-Mamba attribution | bash script/attrib_ssm.sh, after sweep_capacity.sh |
The training launchers skip a checkpoint already in results/, so with the downloaded checkpoints
they only evaluate. sweep_act.sh skips runs already in the run CSV; set RERUN=1 to run them
again. Runs log to the W&B project Hyperspectral_QHSIC under your default entity;
set PROJECT or WANDB_ENTITY to change either. MViT and MassFormer train bit-reproducibly from
the seed; SpectralFormer-CT needs --deterministic, which every launcher passes. Latency depends
on the GPU.
A single run:
python -m tools.train --model mvit --dataset Indian --seed 0 --deterministic --serial 60000
python -m tools.eval --model mvit --dataset Indian --seed 0 --cfg configs/quant/hqq_b4_g64.yaml \
--train_serial 60000 --serial 60010 --wandb_mode disabledModel keys: sf SpectralFormer, sfct SpectralFormer-CT, mvit MViT, mf MassFormer, ssm
SS-Mamba. Dataset keys: Indian, Pavia, Houston, UP (Utopia Planitia), NF (Nili Fossae),
HC (Holden Crater). --cfg takes yaml files from configs/, merged left to right; the command
line beats them. An evaluation loads results/<dataset>_<model>_<train_serial>_seed<s>/ckpt.pt,
or --ckpt_path, and records the checkpoint's SHA-1.
| Path | Contents |
|---|---|
tools/ |
entry points: train, eval, speed_test, and plan_runs for the launchers' dry run |
qhsic/ |
data loading, models, quantization wrappers, training loop, arguments |
hqq/ |
HQQ, vendored from the arkel23/hqq fork (hqq/README.md, Apache-2.0); every HQQ run imports it |
configs/ |
example yaml fragments for --cfg |
script/ |
the launchers, one per sweep |
analysis/ |
summaries, plots, supplementary tables, checks and probes; analysis/data/ holds the run CSV, the model geometry and the probe CSVs |
docs/SERIALS.md |
the serial register |
tests/ |
unit tests |
python -m pytest -q testsTests that build models need a GPU, because build_model calls .cuda(), and skip without one.
Tests that load checkpoints skip without results/. The parity test against the arkel23/hqq fork
looks for a checkout at ../hqq, or at HQQ_FORK (a clone of github.com/arkel23/hqq), and skips
without one.
Apache-2.0 (see LICENSE), the license of the vendored HQQ library in hqq/.
@InProceedings{Sarker_2027_WACV,
author = {Sarker, Pronay and Rios, Edwin Arkel and Lai, Bo-Cheng and Hu, Min-Chun},
title = {Benchmarking Post-Training Quantization for Transformer and Mamba Hyperspectral Classifiers},
booktitle = {Proceedings of the Winter Conference on Applications of Computer Vision (WACV) Workshops},
year = {2027}
}