File size: 17,157 Bytes
3dd0ec6 4b7b338 3dd0ec6 4b7b338 3dd0ec6 e1d9556 3dd0ec6 e1d9556 3dd0ec6 e1d9556 3dd0ec6 e1d9556 3dd0ec6 e1d9556 3dd0ec6 9dd0561 3dd0ec6 9dd0561 3dd0ec6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | # GyroSplat GKW compression benchmark: details
## Layout
```
snapshots/
index.csv snapshot, trajectory, timestep, regime, q, s_hat, R/L_T, R/L_n, sha256
<trajectory>_ifft_realpotens/
data/timestep_<step>.bin one snapshot, float32, shape (2, 32, 8, 16, 85, 32)
metadata.npz, metadata.json geometry and physics parameters of the trajectory
codes/
comparison/<method>/<budget>x[/seed<k>]/<snapshot>.pt equal-byte comparison at 302x and 142x
rate_distortion/<method>/<budget>x[/seed<k>]/<snapshot>.pt the sweep over eight budgets, 1000x to 100x
single_fits/<method>/<budget>x/<snapshot>.pt one archived fit per method and budget
latent_refinement/<model>/adam<steps>_<stage>/<snapshot>.pt AE, VAE, VQ-VAE latents refined through the decoders (stage adam, gauss_newton, levenberg_marquardt)
ablation/<variant>/<budget>x/<snapshot>.pt the fitting-procedure ablation of GyroSplat
heldout_modes/<even|odd>_modes/302x/<snapshot>.pt GyroSplat with the flux fitted on half of the modes
decoders/<autoencoder|vae|vqvae>/
weights.pt, weights.json, config.yaml decoder weights and the model configuration
results/ the paper's rows, as in the code repository
index/codes.csv every code file with its method, budget, seed, snapshot, bytes, sha256, origin
index/own_rows.csv the own rows of the codes that carry one, with the paper rows beside them
index/missing.csv every paper row whose code is not in the dataset
tools/gkw_codes.py load, decode and score
```
## Snapshots
The snapshots come from nonlinear simulations of the gyrokinetic code GKW in the cyclone base case family, with one kinetic ion species and adiabatic electrons. The 39 snapshots belong to 27 trajectories with different safety factor q, magnetic shear s_hat and gradients R/L_T and R/L_n (see `snapshots/index.csv`). They cover three regimes: 12 streamer, 12 mixed and 15 strong zonal snapshots.
Each file is a little-endian float32 array of shape (2, 32, 8, 16, 85, 32), 89,128,960 bytes. The first axis is the real and imaginary part. The other axes are the parallel velocity (32), the magnetic moment (8), the field-line coordinate s (16) and the radial and binormal axes (85 and 32). The layout is the preprocessed layout of the neural-field paper (`<trajectory>_ifft_realpotens/data/timestep_<step>.bin`). The scoring backend transforms the last axis into the binormal modes k_y = 0 to 31. The arrays are stored at full precision. Lossless compression would save little (zstd at level 19 keeps 93 percent of the bytes).
`metadata.npz` holds every array of the trajectory metadata that the readout needs: the geometry (grids, integration weights, metric terms), the physics parameters and the time series of the run (times, heat flux, k_y spectra). `metadata.json` holds the grid resolution, the parallel spacing and the scalars. Neither file uses pickle. `python tools/gkw_codes.py metadata-pickles` writes the `metadata_light.pkl` files that the loader of the GyroSplat package reads.
Four of the snapshots are also part of the public test set of the neural-field paper (PINC) on Hugging Face, [gerkone/pinc_gkw](https://huggingface.co/datasets/gerkone/pinc_gkw), with identical files. They are iteration_100 at t100, t150 and t200, and iteration_235 at t100.
## Codes
Every code is a `torch.save` file that loads with `torch.load(path, weights_only=True)`, so no file runs code when it is opened. The numbers inside are the stored ones, in their stored precision. The budget in a path is the nominal compression ratio. The payload behind each ratio is listed in `results/experiments/storage.json` and in the paper's byte table. A compression ratio is the snapshot's 89,128,960 bytes divided by the payload bytes.
| format | what the file holds |
|---|---|
| GyroSplat and splats | `banks` (centres, Cholesky factors, amplitudes, binormal wavenumbers, envelope groups), `stats` (normalization), `config` (the fitting recipe), as written by the package's `save_model` |
| neural field | `state_dict` of the MLP, `cfg` (width, depth, embedding), `grid_size`, and the per-snapshot `scale` and `shift` of the field |
| AE, VAE, VQ-VAE | the latent (or the codebook indices of the VQ-VAE), `scale`, `shift`, the decoder condition, and the path of the decoder in `decoders/` |
| Fourier top-K, also with refinement | kept Fourier coefficients (complex64) and their positions (int32), the transformed axes and the coefficient shape |
| PCA | the mean, scores and components per channel, in float64 |
| wavelet | kept coefficient values (float64) and their positions (int32), the wavelet, the level and the coefficient slices |
| ZFP, SZ3 | the compressed bit stream (uint8) and its error bound and shape |
- The folder `comparison/` holds the equal-byte comparison of the main table at 302x and 142x. GyroSplat and the neural field with the physics stage have seeds 0 to 4. The field-only neural field has seeds 0 to 2. PCA, ZFP and SZ3 have one run, and the AE, VAE and VQ-VAE one latent at 302x. The Fourier top-K code and the Haar, bior4.4 and db4 wavelets have one code each at equal bytes (the rows of `results/experiments/byte_matched.jsonl`), and so have the Fourier and Haar codes with refinement (`fourier_objective`, `wavelet_haar_objective`, stored in the Fourier and wavelet formats).
- The folder `rate_distortion/` holds the sweep at 1000x, 800x, 600x, 450x, 302x, 200x, 142x and 100x. GyroSplat has seeds 0 to 2 at every budget (at 302x and 142x these are the comparison files of seeds 0 to 2). The neural field with the physics stage is the five-layer network of the sweep, widened to each budget, with seeds 0 to 2. The Fourier top-K code with and without refinement, the Haar and bior4.4 wavelets, PCA, ZFP and SZ3 have one code at each budget. At 302x and 142x the Haar and bior4.4 wavelets hold the same number of stored values as GyroSplat, and the Fourier codes, PCA, ZFP and SZ3 of the sweep are the comparison files. Most SZ3 codes of the sweep come with their own rows (see Regenerated codes). The sweep also holds the plain splats and the field-only neural field with seeds 0 to 2 at every budget (at 302x and 142x the plain splats are the comparison files), and 18 other regenerated codes with their own rows (see Regenerated codes).
- The folder `single_fits/` holds one fit per method and budget. These are the reconstructions behind the diagnostics outside the objective and the final-fit checks of GyroSplat (one fitting seed).
- The folder `latent_refinement/` holds the AE, VAE and VQ-VAE latents after 400 (or 2,000) Adam steps and a final Gauss-Newton or Levenberg-Marquardt refinement through the frozen decoders, and the latents after the Adam steps alone (`adam400_adam`, `adam2000_adam`, computed again). The initial latents are the comparison files.
- The folder `ablation/` holds every row of the ablation of the fitting procedure at 302x, and the joint fit before the Gauss-Newton refinement at both budgets (`deployed_before_gauss_newton`). The row `s7_pack` also has the float16 parameter file that the row measures (`<snapshot>.fp16.pt`).
- The folder `heldout_modes/` holds GyroSplat at 302x with the flux fitted on the even or the odd modes only (nine snapshots).
`index/codes.csv` lists every file with its group, method, budget, seed, snapshot, bytes, sha256, format, the row files that report it (in `results/`, or `index/own_rows.csv` for a file with its own row), and its origin (archived, archived with its own row, regenerated, or regenerated with its own row).
### Regenerated codes
Most codes of the deterministic baselines were not kept by the runs of the paper. They were computed again from the snapshots on an arm64 CPU, with the baseline code of the paper's runs and the configuration of the run that wrote each row. ZFP and SZ3 used zfpy 1.0.1 and pysz 1.0.3, the versions of those runs. A regenerated code is included only when it reproduces its row. It must hold the number of stored values of the run that wrote its row. Its field PSNR must agree within 1e-6 dB, its potential PSNR within 5e-4 dB, its flux error within 8e-7 and its cancellation ratio within 3e-7 relative. Where the net flux is near zero, the cancellation ratio amplifies round-off, so there the tolerance is 3e-7 times kappa_rel (for kappa_rel above one). 1,477 codes passed: 312 Fourier top-K, 310 Haar, 312 bior4.4, 78 db4, 233 PCA, 219 ZFP and 13 SZ3 codes. Each holds `regenerated: True` in its payload. Of the 239 codes that did not pass, 221 SZ3 codes are included with their own rows (next paragraph). The other 18 are not included.
The 221 SZ3 codes of the sweep that did not reproduce the paper's rows are included with their own rows. These files are CPU regenerations, not the files of the paper's run, whose streams were not saved. SZ3 reacts to round-off of its input, so their stream sizes differ from those of the paper's run by -94 to +80 stored values (165 of the 221 within 2), and their metrics differ slightly from the paper's rows (by a median of 1.5e-6 dB in field PSNR and at most 2.2e-2 dB in potential PSNR). Each file reproduces its own row when it is decoded as `tools/gkw_codes.py` decodes it. The own row is given in `index/own_rows.csv` with the paper row beside it. The paper's rows stay the reference for the paper's numbers. In `index/own_rows.csv` the column stored_values_in_paper_row repeats the count of the paper row, the value budget of the comparison. The columns stored_values_paper_run and stored_values_this_file count the streams of the paper's run and of the file. These files hold `own_row: True` in their payload, and `index/codes.csv` gives them the origin "regenerated, own row".
The same holds for 18 other codes of the sweep (15 ZFP, 2 Haar and 1 PCA code). Their CPU regenerations miss the tolerances above by a small margin: at most 1.7e-4 dB in field PSNR, 4e-3 dB in potential PSNR and 3e-5 in the flux error against the paper's rows, and 1.5 percent in the cancellation ratio for one ZFP stream. They are included with their own rows.
The Fourier and Haar codes with refinement and the latents after the Adam steps were computed again on the type of GPU of the paper's later runs (NVIDIA B300), with the paper's run scripts, configurations and seeds, and every file was decoded with `tools/gkw_codes.py` in float32 before it was included. Of the 390 Fourier and Haar codes with refinement, 289 reproduce their rows within the tolerances above, all Fourier codes at 302x and 142x among them. The other 101 carry their own row beside the paper row: the 78 Haar codes and 23 Fourier codes of the sweep, whose paper rows were computed on a CPU. They differ from the paper rows by at most 4.2e-5 dB in field PSNR, 1.1e-3 dB in potential PSNR, 2.1e-7 in the flux error and 1.9e-5 relative in kappa. Of the 144 latents after the Adam steps, 12 reproduce their rows and 132 carry their own row. The Adam steps through the decoders are not bit-reproducible on the GPU, so these latents differ from the paper rows by a median of 3.5e-5 dB in field PSNR and 1.0e-4 dB in potential PSNR, and by at most 1.1e-2 dB and 8.7e-2 dB.
The plain Gaussian splats (the comparison at 302x and 142x with seeds 0 to 2, and the sweep with seeds 0 to 2) were not saved by the paper's runs. All 936 were fitted again on the same type of GPU with the paper's scripts, configurations and seeds. Every one reproduces its paper rows within the tolerances above.
The field-only neural fields of the sweep (eight budgets, seeds 0 to 2, 936 networks) were not saved either. They were fitted again in the same way, but this fit is not repeatable draw for draw, so all 936 are new fits and carry their own rows. Against the paper's rows they agree within 0.06 dB in field PSNR, 0.015 in the flux error and 0.9 percent in kappa. The potential is not part of this fit's objective, and its PSNR differs per fit by -8.8 to +13.9 dB (median absolute difference 1.0 dB). Per budget, the median over the snapshots averaged over the seeds differs from the paper's by at most 0.85 dB (at 1000x), and by 0.5 dB or less at the other budgets. The field-only neural fields of the main comparison at 302x and 142x are the archived networks of the paper.
## What is missing
Nothing. Every row of the paper's result files has a code in the dataset, and `index/missing.csv` is empty. The codes that carry their own row are listed in `index/own_rows.csv`.
## Decoding and scoring
```
python tools/gkw_codes.py score codes/comparison/gyrosplat/302x/seed0/iteration_13_t100.pt
python tools/gkw_codes.py truth iteration_13_t100
```
`score` decodes a file, computes the potential and the heat flux of the reconstruction and of the snapshot with the solver's own field solve and flux integrand, and prints the paper's metrics.
- `psnr_f` is the PSNR of the distribution function with the largest modulus of the snapshot as peak.
- `psnr_phi` is the PSNR of the electrostatic potential, in the same convention.
- `flux_rel_l1` is the relative L1 error of the heat-flux spectrum over the binormal modes 1 to 31.
- `kappa_rel` is the ratio of the gross-to-net cancellation ratio of the flux integrand to that of the snapshot (one is ideal).
- `f_rel_l2` and `phi_rel_l2` are the relative L2 errors of the distribution and the potential.
The tool needs torch and numpy. GyroSplat files and all scoring also need the GyroSplat package, either `neugk.gyrosplat` of the public code repository (github.com/ml-jku/neural-gyrokinetics) or the standalone `gyrosplat` package. Wavelet codes need PyWavelets, ZFP codes zfpy and SZ3 codes pysz. All ZFP and SZ3 codes were written with zfpy 1.0.1 and pysz 1.0.3. The neural fields decode with torch alone. The AE, VAE and VQ-VAE latents need the files in `decoders/` and the autoencoder code of the neural-field paper (`neugk.pinc.autoencoders`) in the version the models were trained with, on Python 3.10 or newer and torch 2.4 or newer. That code imports cupy, so these three kinds of code need a machine with CUDA; all other codes decode on a CPU.
Decoding on a CPU reproduces the stored rows closely. The numbers below are from the machines the rows were checked on; another CPU, GPU or library version moves the last digits (in a test on a second machine with newer libraries, by about 1e-6 dB in field PSNR and 1e-5 dB in potential PSNR for a Haar code with refinement). In a check of files of every kind except ZFP and SZ3, the field PSNRs agreed with the rows within 1e-6 dB and the potential PSNRs within 5e-4 dB. The cancellation ratios agreed to 3e-7 relative, the relative L2 errors to 6e-5 relative, and the flux errors within 8e-7 in absolute terms. The 156 archived ZFP and SZ3 codes, decoded on an arm64 CPU, differed from their rows by at most 1.31e-6 dB in field PSNR, 1.9e-4 dB in potential PSNR and 3.6e-7 in the flux error. Their cancellation ratios passed the same check as those of the regenerated codes. For the regenerated codes, kappa is compared with a tolerance scaled by kappa_rel where the net flux is near zero (3e-7 times kappa_rel when kappa_rel is above one). In a spot check, 21 regenerated codes, three of each kind including ZFP and SZ3, were decoded as `tools/gkw_codes.py` decodes them. All 21 agreed with their rows within these tolerances. Flux errors near 1e-7, as GyroSplat reaches them after its refinement, are float32 round-off of the readout, so on another device they reproduce only as values of that size. The predicted heat-flux spectrum agreed with the stored one to better than 1e-6 of the snapshot's spectrum. The heat-flux spectra of all 39 snapshots, computed from the stored snapshots and metadata, agreed with the paper's rows to 3e-7 relative.
One group of rows needs care. For the nine snapshots of the first pilot runs, the rows of the neural field with the physics stage were scored after a decode with TF32 matrix products on the GPU. These are the comparison rows of seeds 0 to 4 and the sweep rows of seed 0 for extra_iteration_0_t150, extra_iteration_15_t150, iteration_100_t150, iteration_13_t100, iteration_204_t32, iteration_50_t32, iteration_5_t20, iteration_877_t20 and iteration_893_t32 (153 rows). Decoded again on the same type of GPU, the files give these rows exactly with TF32 and slightly different scores in float32. In float32 the field PSNR stays within 0.001 dB of the row, the potential PSNR moves by a median of -0.01 dB (from -1.36 to +0.83 dB) and the flux error by at most 0.4 percent of its value. Each of these 153 files therefore carries its float32 row as its own row in `index/own_rows.csv`, with the paper row beside it, and `index/codes.csv` gives it the origin "archived, own row". The public tool reproduces these float32 rows. The rows of the sweep's field-only neural field were also decoded with TF32, and their networks are not in this dataset. All other neural-field rows were decoded in float32.
|