You need to agree to share your Hugging Face information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

RowHammer Analysis Pipeline

GPU-accelerated spatial-statistical analysis of DRAM RowHammer bitflip data, producing cached results in a SQLite database for downstream paper analysis and figure generation.

See CHANGELOG.md for a full record of what changed relative to the original, pre-audit version of this repository, including three confirmed statistical fixes (see Known Limitations) and known open issues.


Setup

Prerequisites

  • Python 3.10+
  • PyTorch (first tries CUDA/ROCm, falls back to CPU)
  • numpy, scipy, matplotlib (3.9 or later), tqdm, pandas, scikit-learn, seaborn, statsmodels
  • xgboost β€” only needed for ets/ets_xgboost*.py and ets/ets_intra_xgboost_*.py

Hardware this pipeline has actually been run and measured on: a single NVIDIA RTX 2070 (8 GB, CUDA) β€” see Hardware Notes below and python/testbench.py for checking your own machine's actual capability before a real run. Two AMD RX 7900 XTX (ROCm) was an earlier target; the code still auto-detects ROCm and should work there, but current memory budgeting/--batch-size guidance below was measured on the RTX 2070, not re-verified on ROCm hardware.

Installation β€” Linux

# PyTorch: pick ONE of the following two lines
pip install torch torchvision                                                           # NVIDIA (CUDA) or CPU-only
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.4.3   # AMD (ROCm)
# see https://pytorch.org/get-started/locally/ if neither matches your setup

pip install numpy scipy matplotlib tqdm pandas scikit-learn seaborn statsmodels
pip install xgboost   # only if running the ETS xgboost scripts

Installation β€” Windows

PyTorch's CUDA builds install the same way on Windows via pip; ROCm has no native Windows build β€” an AMD GPU on Windows falls back to CPU-only unless you use WSL2 (see below).

# In PowerShell or Command Prompt, with Python 3.10+ already installed
# (from python.org or the Microsoft Store) and on PATH:
python -m venv venv
venv\Scripts\activate

# NVIDIA (CUDA) -- most common case on Windows:
pip install torch torchvision
# AMD on Windows: no ROCm build exists; this installs CPU-only PyTorch.
# For GPU acceleration on an AMD card, use WSL2 instead (below).

pip install numpy scipy matplotlib tqdm pandas scikit-learn seaborn statsmodels
pip install xgboost   # only if running the ETS xgboost scripts

Recommended for AMD GPUs on Windows, or for closer parity with how this pipeline was actually developed and measured (Linux): install WSL2 (wsl --install from an administrator PowerShell), then follow the Linux installation steps above inside the WSL2 Ubuntu shell. WSL2 has working GPU passthrough for both NVIDIA and AMD on recent Windows versions.

Hardware Notes

  • The pipeline is designed for GPU acceleration. CPU fallback is supported but significantly slower for Moran's I, LISA, and ACF computations.
  • Full FP32 precision is used by default. Pass --fp16 to opt into FP16 mixed precision (FP32 accumulators with arithmetic performed in FP16) if you need to reduce GPU memory usage.
  • FP16 changes the computed value only for Global Moran's I (see Numerical precision for the measured differences); leave it off (the default) unless GPU memory requires it.
  • Before a real multi-hour run on new hardware, run python3 python/testbench.py --quick (smoke test) and python3 python/testbench.py --full (memory ceilings, precision re-check, and a rough time projection for your machine) β€” see TestBench below.

GPU-Only Processing (Linux)

If your GPU also drives your desktop (a single-GPU laptop or workstation, not a dedicated headless compute box), the desktop compositor and any open GUI applications compete with batch_analyze.py for the same VRAM β€” measured on this project's own machine, an idle desktop session (GNOME Shell, a browser, a terminal, etc.) held ~700-900 MB that would otherwise be available for analysis, which was directly responsible for out-of-memory failures on large banks. Freeing it is the single highest-value thing you can do before a long run on constrained hardware.

Option A β€” close GUI applications, keep the desktop running. Close your browser, IDE, and anything else with a GPU-rendered window; leave the desktop shell itself running. Reclaims most, not all, of the overhead.

Option B β€” fully stop the graphical session (frees everything, including the desktop compositor itself).

Check which display manager you're running first β€” it varies by distribution/desktop environment:

systemctl status display-manager   # shows e.g. gdm.service (GNOME), sddm.service (KDE), lightdm.service, etc.

Then, for the current session only (reverts automatically on next reboot):

# WARNING: this immediately closes every GUI application and your desktop
# session β€” save your work first. Switch to a plain text console
# (Ctrl+Alt+F3 or similar) or SSH in from another device before running this,
# since it will also close the terminal window you ran it from if that
# terminal is itself a GUI application.
sudo systemctl isolate multi-user.target

# ... run your analysis job here, e.g.:
python3 python/batch_analyze.py -o results.db /path/to/data/*.bin

# When done, restore the graphical session:
sudo systemctl isolate graphical.target

multi-user.target stops the display manager (gdm/sddm/lightdm/etc.) and every graphical session it was running; graphical.target restarts it. Equivalently, you can stop/start just the display manager service directly (e.g. sudo systemctl stop gdm / sudo systemctl start gdm for GNOME) if you'd rather not change the whole target.

To make headless the permanent default (boots straight to a text console; run sudo systemctl start gdm β€” or your DM's equivalent β€” any time you want the desktop back that session):

sudo systemctl set-default multi-user.target
# to revert permanently:
sudo systemctl set-default graphical.target

TestBench

python/testbench.py probes what your specific machine can actually handle before you commit to a real, multi-hour run. It uses only synthetic data β€” no project files required β€” so it works on a fresh checkout immediately.

# Quick smoke test (~seconds): does every statistic run at all on this hardware?
python3 python/testbench.py

# Full capability report (~1-2 minutes): memory ceilings per function/dtype,
# an FP16-vs-FP32 precision re-check, and a rough per-file time projection.
python3 python/testbench.py --full --output my_machine_report

--full writes my_machine_report.json if --output is given. Read the console summary for: the largest bank size (row count) each statistic handles at FP16 and FP32 on your GPU, and an estimated hours-to-process figure for a batch the size of --projection-files (defaults to 3564, this project's own dataset scale β€” pass your own count for a more relevant estimate). The time projection is explicitly a rough guide (isolated, per-function synthetic measurements, not a real multi-stage run) β€” treat it as order-of-magnitude, not a schedule.

If your report shows a lower memory ceiling than you expected, see GPU-Only Processing above before assuming the pipeline itself is at fault β€” on this project's own development machine, an idle desktop session accounted for the difference between "just barely OOMs" and "comfortably fits."

There is a private, machine-specific companion script for testing against your own real .bin data files, not included in this repository (each collaborator's copy is local and gitignored, since raw data isn't shared via git) β€” ask a project maintainer if you want the pattern to set one up for your own dataset.


Test Suite

tests/ holds correctness tests for the statistical functions β€” separate from TestBench above, which checks hardware capability (memory, timing), not correctness. Every statistical fix described in Known Limitations below has a regression test here that fails if the bug is reintroduced β€” verified directly by temporarily reverting each fix and confirming the corresponding test catches it before this suite was adopted, not just assumed.

pip install pytest esda libpysal   # test-only deps; not needed to run the pipeline itself
# statsmodels is already a pipeline dependency (see Setup above) and is
# reused here for ACF cross-validation.

python3 -m pytest tests/           # runs the CPU-only correctness suite; no GPU required
python3 -m pytest tests/ -m gpu    # GPU-specific tests only (dtype invariance, etc.) -- skipped automatically if no GPU is present

Each test file mirrors a python/ module (test_moran_torch.py covers Global Moran's I, LISA, and the correlogram's sampling logic; test_correlation_torch.py covers ACF; test_batch_analyze.py covers the correlogram's separate database-write path; test_provenance.py covers build provenance β€” the parameter fingerprint, the database guards, and the build records; test_dramsec_original_method.py and test_ets_original_method.py check that dramsec_cnn/ and the ETS loaders keep the published sample construction; test_db_access_columns.py checks that db_access.py returns the original columns). When adding a new statistical function or fixing a bug in an existing one, add a test alongside it in the same style β€” this is meant to be the standing practice going forward, not a one-time effort: a known-answer or hand-derived check, a regression test if fixing a real bug, and where a suitable independent reference implementation exists (PySAL/esda for spatial statistics, statsmodels/scipy for time-series), a cross-validation test against it.


Data Collection

Raw RowHammer bitflip data is collected as binary CSR (Compressed Sparse Row) files paired with JSON metadata files. Each .bin file contains column indices of bitflips per row, and the corresponding .json file contains run-level metadata (DIMM identifier, bank, aggressor/victim patterns, timing parameters, temperature, voltage, etc.).

These files are produced by the hardware test harness (outside this repository) and should be placed in a single directory before running the processing pipeline.


Datasets and DIMMs

Raw data is not versioned. This section records what each capture directory contains, so that a database built from it can be checked for completeness. Counts are taken from the .json metadata of every capture.

DIMM inventory

Module details are those recorded in populate_db.py (dimms table). "Tagged for" lists the paper tags populate_db.py writes to paper_dimms.

DIMM IDs Vendor Module Capacity / ranks Date code Tagged for
hynix01-hynix06 Kingston (SK hynix dies) KVR21R15S4/8 8 GB, 1Rx4 1611 tches, vts, host, ets
samsung01-samsung06 Samsung M393A1G40EB1-CPB0Q 8 GB, 1Rx4 1720 tches, vts, host, ets
micron11-micron14 Micron MTA18ASF2G72PZ-2G3B1RI 16 GB, 1Rx4 1903 tches, vts, host, ets
micron02-micron04 Crucial MTA36ASF2G72PZ-2G1A2II 16 GB, 2Rx4 1503 ets
micron06, micron10 Crucial MTA36ASF2G72PZ-2G1B1QG 16 GB, 2Rx4 1722 ets
micron21 Micron MTA18ASF1G72PZ-2G6F1RI 8 GB, 1Rx4 2017 (2020, week 17) none

populate_db.py also defines hynix07-10, samsung07-10, micron01, micron05, micron07-09 and micron22-28; no captures of these exist in the data directories below.

dramsec_cnn/ has no paper tag. It uses every DIMM that has LISA rows in results.db, holding out hynix06, samsung06, micron02 and micron14 as validation DIMMs (VAL_DIMMS in train_models.py). With the current results.db that is 21 DIMMs: micron06 and micron10 have no adjacent bitflips and therefore no LISA rows.

Datasets used in each publication

These are the datasets reported in each publication. A database built from a capture directory can contain more DIMMs or captures than a given publication used. Check the selection each script applies (below) before regenerating a figure.

Work Directory Dataset reported
DRAMSec (CNN) dramsec_cnn/ 19 RDIMMs: hynix01-hynix06, micron02-micron04, micron11-micron14, samsung01-samsung06. Two training protocols: 15 training / 4 validation DIMMs (hynix06, samsung06, micron02, micron14), and leave-one-DIMM-out.
HOST (PUF) host/ Baseline: 16 RDIMMs (samsung01-samsung06, hynix01-hynix06, micron11-micron14), 768 bank-level measurements (16 DIMMs Γ— 16 banks Γ— 3 patterns). Intra-device: hynix01, samsung01, micron11 at ambient, 30, 50 and 70 Β°C, 4096-row depth, 10 runs with 5 minutes between runs: 180 ambient measurements (3 DIMMs Γ— banks 1-2 Γ— 3 patterns Γ— 10 runs) and 1350 heated measurements (3 DIMMs Γ— 3 temperatures Γ— banks 1-5 Γ— 3 patterns Γ— 10 runs).
VTS vts/ 16 RDIMMs: samsung01-samsung06, micron11-micron14, hynix01-hynix06.
Spatial characterization (TCHES submission) tches/ 14 RDIMMs: hynix01-hynix05, samsung01-samsung05, micron11-micron14. ACF up to lag 2048 (row-wise and column-wise), FFT power spectra, Global Moran's I, HH/HL LISA heatmaps. tches/tches_plot.py implements these analyses.
ETS ets/ Not yet recorded here. The scripts use the 21 DIMMs tagged ets in populate_db.py.

How the scripts select data, and where that differs from the publication:

  • dramsec_cnn/ reads every DIMM with LISA rows in results.db. A database built from the 21 DIMMs of the original dataset (the 19 above plus micron06 and micron10) gives exactly the 19: micron06 and micron10 have no adjacent bitflips and therefore no LISA rows, with either LISA implementation. A database built from all of data/old_data/acf/ gives 21, because it also contains micron21 and micron21_60c.
  • host/ selects the baseline by the host paper tag (the 16 DIMMs above) and the intra-device DIMMs by name. data/old_data/puf/ also holds captures the publication did not use (hynix02, hynix03, micron21_70c, and samsung01 banks 3-5 at ambient). See the Samsung naming note below.
  • vts/ selects by the vts paper tag (the 16 DIMMs above).
  • tches/ reads results_tches.db. Its ACF/FFT figures plot every DIMM in that database, so the database must hold only the 14 DIMMs above and be built with --acf-lags of at least 2048. The tches paper tag in populate_db.py also includes hynix06 and samsung06.

Capture directories

All captures use hammer count 680000 unless stated. The patterns are 0xFF/0x00, 0xAA/0x55 and 0xCC/0x33 (victim/aggressor, low byte). The JSON temperature field is 25.0 in every file; for heated captures the temperature is only in the DIMM ID (_30c, _50c, _60c, _70c).

data/old_data/acf/ β†’ results.db (1104 captures, one run each)

  • 22 DIMMs from the inventory above, plus micron21_60c (micron21 at 60 Β°C).
  • Banks 1-16, all three patterns.
  • Banks 1-2 of hynix01, hynix02, micron11, micron12, micron21, samsung01 and samsung02 are captured at the full 65536 rows. Every other bank is 16384 rows.

data/old_data/puf/ β†’ results_puf.db (2460 captures, runs 1-10, 4096 rows)

DIMM ID in the database Banks Temperature
hynix01, micron11 1-2 room
hynix02, samsung01 1-5 room
hynix01_{30,50,70}c, hynix03_{30,50,70}c, micron11_{30,50,70}c 1-5 30/50/70 Β°C
hynix02_{30,50,70}c 1 30/50/70 Β°C
samsung11_{30,50,70}c 1-5 30/50/70 Β°C
micron21_70c 1-5 70 Β°C

The heated Samsung captures are of the same physical module as samsung01 (only one Samsung revision was tested). Their files are named samsung01_<T>c_*, but their JSON dimm field, and therefore their DIMM ID in the database, is samsung11_<T>c. Account for this when joining room-temperature and heated Samsung results.

data/rp_v_rh/ β†’ results_rp_v_rh.db (200 captures, bank 1, 4096 rows, patterns 0xAA/0x55 and 0xCC/0x33). RowPress vs. RowHammer on hynix01, micron21 and samsung01: aggressor-on times (tAggOn) of 256 ns, 7800 ns and 70200 ns, at hammer counts 115580, 4080 and 450 respectively. Also includes a 10-run RowHammer reference for micron21. No paper script reads this database yet.

Not processed: data/new_puf_data/ (3570 captures; must be separated by auto-refresh setting before processing, since no JSON records it), and the legacy data/old_data/old_acf/, tches/ and threshold/.

Keep each capture directory in its own database. Keys do not identify the source directory: acf/ files have no _runN suffix (run defaults to 1) and would collide with puf/ run-1 keys. batch_analyze.py refuses such a mix before processing.


Paper Directories and Methodology Preservation

ets/, vts/, host/ and dramsec_cnn/ regenerate published results. They are kept faithful to the method each paper used, so historic figures can be regenerated and checked against the published numbers, including when a defect is later found in that method.

  • Baseline. The original implementation is commit 8817b0c. Compare any paper directory against it with git diff 8817b0c -- <dir>.
  • Allowed changes in a paper directory are compatibility changes that leave its outputs unchanged: imports and paths, schema/SQL access, API signatures, and crash fixes that do not alter results.
  • Method changes go into a new directory. A corrected or extended method (for example, limiting windows to measured rows) is implemented next to the original, not in place of it, and documented here.
  • Defects found in a published method are recorded under Known Limitations with their measured effect, and the original code is left as is.
  • Current status: dramsec_cnn/ and vts/ are identical to 8817b0c. The ETS loaders and the shared cell-level datasets are restored to the original method; the remaining ets/ differences are an import-path line in each script. host/host_analysis.py is the 8817b0c version plus two compatibility edits for current pandas and matplotlib. db_access.py returns the same columns and rows as the original for every call the paper scripts make. All differences are listed in CHANGELOG.md.

Processing Pipeline

The processing pipeline is a single command that loads all .bin files, computes spatial-statistical features on GPU, and writes results to a SQLite database:

python3 python/batch_analyze.py -o results.db /path/to/data/files/*.bin

Key Parameters

Flag Default Description
-o, --output (required) Output SQLite database path
--acf-lags 200 Maximum autocorrelation lags. Also sets the FFT spectrum's resolution, so FFT results from different values are not comparable β€” use one value for every database you intend to compare
--correlogram-max-dist 50 Moran correlogram maximum distance
--correlogram-bins 50 Number of correlogram distance bins
--correlogram-sample 10000 Sample size for correlogram computation
--seed 0 Seed for the correlogram's random sampling (each file is seeded from this value and its own key)
--max-moran-rows (none) Skip Global Moran's I truncation sizes above N rows (e.g. 16384 avoids the full-bank 65536-row computation, which exceeds 8 GB of GPU memory at FP32)
--max-lisa-rows (none) Compute LISA on the first N rows of each bank only
--lisa-extra-z (none) Additional fixed |z| cutoff for LISA (repeat the flag for several, e.g. --lisa-extra-z 1.96 for p < 0.05 per cell). HH and HL at that cutoff are stored in lisa_clusters_cutoff; lisa_clusters always holds the Bonferroni result and is unchanged
--batch-size 4 Number of files processed in parallel per GPU
--fp16 off Opt into FP16 mixed precision to reduce GPU memory use (default is full FP32)
--gpu-config (none) Multi-GPU config, e.g. 0:8,1:4 (gpu_id:batch_size,...)
--num-workers (auto) CPU workers for parallel file loading
--label (none) Free-text description recorded with the build (see Build Provenance)
--allow-mixed-config off Allow appending to a database built with different result-affecting parameters (recorded)
--allow-key-collisions off Allow input files that would overwrite each other's rows (recorded)

--batch-size in more detail. Files are loaded in groups of --batch-size. Global Moran's I and the ACF are computed for the group at once (grouped by bank height and split into memory-safe sub-batches); LISA, the correlogram and the database writes run one file at a time. If a group runs out of GPU memory, its files are retried one at a time; a file that still fails is removed from the database and listed in <output>.failed_files.txt, and the run still exits 0, so check the log and that file. Batch size changes stored values only at floating-point level: --batch-size 1 vs 4 on the same 8 captures gave identical Global Moran's I and LISA, and ACF/FFT differences up to 1.6Γ—10⁻⁴ / 2.3Γ—10⁻³ relative (the batched and single-file ACF use different FFT batch shapes). In the original pipeline, batch size changed the ACF itself: its batched path (any --batch-size above 1) shifted every lag by one; the published ACF/FFT values come from that batched path. raising it past small single digits buys memory-usage safety margin, not speed β€” measured throughput plateaus at --batch-size 2-3 and stays flat through at least 32; the code auto-limits actual GPU memory usage to a computed-safe sub-batch size regardless of how high you set it (confirmed: memory itself plateaus by --batch-size 8 and does not keep growing). Safe to leave at a generous value; there's no speed reason to tune it down, only a reason to not expect tuning it up to make things faster.

Multi-GPU Execution

The --gpu-config flag enables distributed processing across multiple GPUs. Each GPU receives a proportional share of the file list and runs as a subprocess. The orchestrator (parent process) collects progress reports and runs Jaccard similarity computation after all workers finish.

Example using two GPUs at once (GPU 0 and GPU 1, whatever cards they are on your machine), batch sizes of 8 and 4 respectively β€” this project's own development hardware is single-GPU, so this path is implemented and reviewed but not verified on real multi-GPU hardware (see Known Limitations):

python3 python/batch_analyze.py -o results.db --gpu-config 0:8,1:4 /path/to/data/*.bin

Build Provenance and Reproducibility

Every run of batch_analyze.py is recorded inside the output database as a build, so any number taken from a database can be traced to the exact parameters, code, and environment that produced it β€” and to when it was produced. Use this when drafting a manuscript: cite the database together with the build(s) and analysis config it came from.

What is recorded

Table One row per Contents
build_runs invocation UTC start/finish timestamps, status, label, git commit and whether the working tree had uncommitted changes, full command line, working directory, every CLI option, hostname, platform, Python/PyTorch versions, device, file counts
build_files input file per build path, size, the database key it maps to, status (ok / failed / not_processed), worker and batch number, UTC timestamp, error message
analysis_configs distinct parameter set the result-affecting parameters and their fingerprint (config_id)
run_metadata.build_id result row which build wrote this file's results

The analysis config contains every parameter that changes a stored value: --acf-lags, the correlogram options, --seed, --max-moran-rows, --max-lisa-rows, --lisa-extra-z (only when given, so databases built without it keep their config_id), precision (--fp16), and the hardcoded truncation sizes, LISA significance level, and correlogram sampling threshold. Operational options (--batch-size, --gpu-config, --num-workers, device) are recorded per build but excluded from the fingerprint, because they do not change the results beyond floating-point level (see --batch-size above). The same parameters always give the same config_id, on any machine.

At the end of every build a JSON manifest is also written next to the database, <database>.builds/build_<id>_<UTC start time>.json, containing the build record, its analysis config, and the status of every input file.

Guards (checked before any GPU work)

  • One analysis config per database. Appending a build with different result-affecting parameters (e.g. --acf-lags 200 onto a --acf-lags 2000 database) is refused, because INSERT OR REPLACE would otherwise leave rows from both parameter sets mixed in the same tables. Build a separate database per parameter set, or pass --allow-mixed-config if mixing is intentional.
  • No key collisions. Each file's results are keyed on (DIMM, bank, run, data patterns, disturbance type, tAggOn). Files without a _runN filename suffix are run 1, so e.g. hynix01_dp1_bank1.bin and hynix01_dp1_bank1_run1.bin share a key and would overwrite each other. Collisions within the input list, or with files recorded in an earlier build of the same database, are refused (override: --allow-key-collisions). Datasets captured separately (e.g. different experiment directories) belong in separate databases.
  • Schema version. New databases are stamped with PRAGMA user_version. A database that already contains results but predates build provenance (version 0) is refused rather than appended to β€” there is no record of how its existing rows were produced. Existing unversioned databases remain readable by db_access.py and the paper scripts.

A file that fails (e.g. out of GPU memory after the per-file retry) has all of its rows removed, so it is absent from the database rather than partially written, and is listed as failed in build_files and the manifest. A build interrupted with Ctrl-C is marked aborted; one still marked running after the process has exited was killed without cleanup.

Inspecting builds

python3 db_manage.py describe results.db        # schema version, configs, builds, row counts
python3 db_manage.py builds results.db          # every build with timestamps and parameters
python3 db_manage.py builds results.db -v       # ... including operational options
python3 db_manage.py build-manifest results.db --build-id 1 -o build1.json

Reproducibility limits

The correlogram samples cells at random. Each file is seeded from --seed and its own key, so on a given device type the same cells are sampled regardless of batch composition or worker assignment, and CPU runs reproduce exactly. On GPU, CUDA's non-deterministic accumulation order can still change the last digits of the correlogram values (observed ≀ 5Γ—10⁻⁷ absolute between two runs of the same files). Global Moran's I and LISA are bit-identical across batch sizes; ACF and FFT differ at floating-point level between --batch-size 1 and larger batch sizes (see --batch-size above).

CPU and GPU sample different cells. PyTorch's CPU and CUDA random-number generators produce different streams from the same seed, so a file processed on CPU (e.g. via python/run_cpu.py, to recover a file that exceeds GPU memory) gets a different β€” equally valid β€” correlogram sample than it would on GPU. Measured on one full-bank file: correlogram values differed by up to 1.3 (absolute) between CPU and GPU, while Global Moran's I (≀ 1.4Γ—10⁻⁢ relative), ACF (≀ 7.5Γ—10⁻⁴ relative), FFT (≀ 6.6Γ—10⁻³ relative), bitflip counts (identical), and LISA clusters (identical) agreed to floating-point precision. A CPU build appended to a GPU-built database is allowed (the device is not part of the analysis config) and each file's device is recorded through its build (build_files.build_id β†’ build_runs.device); report the device when citing correlogram values from such a database.


Folder and Script Descriptions

python/ β€” Core Analysis Library

All scripts in this directory form the shared analysis library used by paper-specific scripts in other directories.

File Purpose
batch_analyze.py Entry point for the full processing pipeline. Orchestrates GPU-accelerated batch analysis of CSR bin files, writes results to SQLite, and computes Jaccard similarity between data patterns.
data_loader.py Loads .bin + .json file pairs. Parses CSR binary headers into RowMap objects and extracts RunMetadata (DIMM, bank, aggressor/victim, timing, temperature, voltage). Supports parallel loading via multiprocessing.Pool.
csr_loader.py Torch-free parsing of a .bin/.json pair into RunMetadata and raw CSR arrays (used by the loader's worker processes). load_run_metadata() reads metadata only.
provenance.py Build provenance: schema version, analysis-config fingerprint, per-build and per-file records, pre-flight guards, JSON manifests (see Build Provenance).
testbench.py Hardware capability probe on synthetic data (see TestBench).
run_cpu.py Runs batch_analyze.py on the CPU (e.g. for full 65536-row banks that exceed GPU memory). Run from the repo root.
rowhammer_torch.py Core RowMap class β€” a sparse GPU-accelerated representation of bitflip locations. Supports CSR and LIL storage modes, slicing for truncated analysis, and conversion to dense/COO tensors. Also configures the compute device (ROCm/CUDA) and FP16 mode.
moran_torch.py GPU-accelerated Moran's I computations: global Moran's I with z-score/p-value, Local Moran's I (LISA) with cluster classification (HH, LL, HL, LH), and Moran correlograms. Includes batched variants for processing multiple files simultaneously.
correlation_torch.py Autocorrelation Function (ACF) calculations via FFT (Wiener-Khinchin theorem) and direct methods. Computes row and column ACFs, power spectra via FFT of ACF, and batched ACF across multiple files.
statistical_tests.py Non-parametric statistical tests (Kruskal-Wallis H-test) on row and column bitflip distributions across multiple runs.
celllevel_dataset.py PyTorch Dataset implementations for cell-level vulnerability prediction. CellLevelPatchDataset extracts random 2D patches from banks with sparse probing simulation and data augmentation. FullBankDataset loads whole banks at their measured height (65536 rows for a full capture, 16384 for most). Both stop at each bank's measured rows. Includes superpixel aggregation utilities.
celllevel_models.py Neural network models for cell-level prediction: CellLevelUNet (encoder-decoder segmentation), SuperpixelUNet (truncated decoder for superpixel outputs), PixelMLP (per-pixel MLP baseline), and loss functions (CombinedLoss, FocalLoss, TverskyLoss, DiceLoss, MultiLoss).
celllevel_metrics.py Evaluation metrics for binary cell-level predictions: precision, recall, F1, IoU, Dice, accuracy, PR curve points, vulnerability density, and row-level aggregation.
window_filtered_dataset.py Two-stage dataset: runs a trained RowCNN model to pre-filter vulnerable 2048-row windows (within each bank's measured rows), then extracts cell-level patches only from those windows.
publication_style.py Matplotlib utilities for IEEE two-column paper figures. Configures serif fonts, colorblind palettes (Okabe-Ito), figure dimensions, subplot labels, and export functions for PDF/PNG at 300 DPI. Includes helpers for confusion matrices and performance comparison bar charts.
intra_dimm_utils.py Shared utilities for intra-DIMM train/validation splits. Filters coordinates by row range, computes row-based split configurations, and prints split summaries. Used by training scripts to test cross-region generalization within the same DIMM.

Each paper directory reads one or more databases built by batch_analyze.py. Scripts differ in where they expect to find them: run each from the directory shown below.

ets/ β€” ETS Paper (European Testing Symposium)

Cell-level vulnerability prediction: 1-D CNN, U-Net, PixelMLP, superpixel and XGBoost models, with training, validation and figure scripts. Reads results.db (built from data/old_data/acf/), paper tag ets. Run from the repo root. The XGBoost FFT features require a database built with --acf-lags of at least 1024.

vts/ β€” VTS Paper (VLSI Test Symposium)

ANOVA (one-way and mixed-effects) analyses, vendor comparison plots, sampling fidelity plots, and coverage loss figures. Reads ../results.db, paper tag vts. Run from vts/. Needs full-bank (65536-row) Global Moran's I and LISA for banks 1-2 of the full-capture DIMMs, so build results.db without --max-moran-rows/--max-lisa-rows.

host/ β€” HOST Paper (RowHammer PUF)

PUF analysis. Reads ../results.db (inter-device features), results_puf.db and results_temp.db (multi-run and heated captures from data/old_data/puf/). Run from host/, with results_puf.db and results_temp.db placed (or symlinked) in host/.

dramsec_cnn/ β€” DRAMSec CNN Baseline

1-D CNN models on per-row LISA density in 2048-row windows: inter-DIMM next-window prediction, leave-one-DIMM-out (LODO), intra-DIMM, masked-probing and ablation experiments, baselines, zero-shot experiments, and result figures. Reads ../results.db, which must be built from data/old_data/acf/ alone (the loaders combine every LISA row per bank/pattern, so a database mixing several captures of the same bank would be summed). Run train_models.py, validate_models.py, generate_results.py and run_baselines.py from dramsec_cnn/; diagnostics.py expects results.db in the current directory. The code is the original DRAMSec implementation (identical to 8817b0c): every bank is sized at a fixed row count (65536 for inter-DIMM/LODO, 16384 for masked/ablation tasks) and zero-filled beyond its measured rows (see Known Limitations).

tches/ β€” Spatial characterization (TCHES submission)

tches_plot.py: row-wise and column-wise ACF (lag ≀ 2048), FFT power spectra, Global Moran's I, and HH/HL LISA cluster heatmaps. Reads results_tches.db, which is not built yet (see Datasets used in each publication).

satc/ β€” legacy

satc_analysis.py is a hardware-experiment driver (it invokes SoftMC_RowHammer), not an analysis of processed data. Not maintained.


Full Pipeline Walkthrough

This section describes the complete data flow from raw binary files to paper figures.

Step 1: Raw Data β€” CSR Binary Files

The hardware test harness produces .bin files, one per RowHammer run. Each file is a CSR-encoded sparse matrix:

  • Header: 2 Γ— 32-bit integers β€” number of rows and number of non-zero elements (bitflips).
  • Data: indptr array (row pointers) followed by indices array (column offsets of each bitflip).

A companion .json file contains run metadata: DIMM ID, bank number, rank, hammer count, DRAM address mapping, victim/aggressor page patterns, timing parameters (tRAS, tRP, tRCD), temperature, and voltage.

Step 2: Batch Analysis β€” batch_analyze.py

The batch_analyze.py script is the primary entry point. It performs the following:

  1. Initialization β€” Creates the SQLite database and schema. The schema includes tables for DIMM metadata, paper metadata, global Moran's I statistics, LISA clusters, ACF data, FFT power spectra, Moran correlograms, bitflip counts, and Jaccard similarity results.

  2. File Loading β€” Loads all .bin + .json file pairs in parallel using multiprocessing.Pool. Each file is parsed into a RowMap (sparse GPU tensor) and RunMetadata object.

  3. Global Moran's I β€” For each file, computes global Moran's I at multiple truncation sizes (65536, 16384, 8192, ..., 64 rows). This produces a multi-scale view of spatial autocorrelation. Always dense (there is no sparse code path for this computation). Results include z-scores and p-values.

  4. Autocorrelation Function (ACF) β€” Computes row and column ACFs using FFT-based methods (Wiener-Khinchin theorem). Stores autocorrelation values for lags 1 through --acf-lags (default 200).

  5. FFT Power Spectrum β€” Computes the power spectrum of each ACF via FFT, producing period vs. power data that reveals dominant spatial frequencies in the bitflip patterns.

  6. Local Moran's I (LISA) β€” Computes LISA for every cell in the bitflip map, classifying each as HH (high-high cluster), LL (low-low cluster), HL (high-low outlier), or LH (low-high outlier). Only HH (cluster_type 1) and HL (cluster_type 3) cells are stored. Coordinates are packed into a compressed binary blob and stored in the lisa_clusters table (Bonferroni cutoff, Ξ± = 0.05 / number of cells). With --lisa-extra-z, HH and HL at each additional fixed cutoff are classified from the same z-map in the same pass and stored in lisa_clusters_cutoff (column z_cutoff).

  7. Moran Correlogram β€” Computes Moran's I as a function of inter-bitflip distance, binned into --correlogram-bins (default 50) bins up to --correlogram-max-dist (default 50). Uses random sampling (--correlogram-sample, default 10000) to limit computation on dense maps.

  8. Bitflip Counts β€” Records total up/down bitflip counts per run.

  9. Jaccard Similarity β€” After all files are processed, computes pairwise Jaccard similarity between data patterns (victim/aggressor combinations) for each DIMM, measuring how much the LISA cluster locations overlap across different patterns.

All computations are GPU-accelerated via PyTorch with ROCm/CUDA support. Full FP32 precision is used by default (pass --fp16 to opt into FP16 mixed precision for reduced GPU memory use). Results are written asynchronously to the SQLite database via a background worker thread.

Step 3: SQLite Database β€” Cached Results

The output database (e.g., results.db) contains pre-computed spatial-statistical features. This is the central artifact β€” all expensive computations (Moran's I, LISA, ACF, correlograms) are cached here so that paper-specific analysis scripts can read from the database directly without re-running GPU computations.

Key tables:

  • dimms β€” DIMM identifiers and vendor information (Samsung, Hynix, Micron).
  • global_moran β€” Global Moran's I, z-score, and p-value at each truncation size.
  • lisa_clusters β€” Compressed binary blobs of HH and HL cell coordinates (Bonferroni cutoff).
  • lisa_clusters_cutoff β€” The same, at the additional fixed cutoffs given with --lisa-extra-z (one row per run key, z_cutoff and cluster type); empty unless the option is used. Paper scripts do not read it.
  • acf_data β€” Row and column autocorrelation values per lag.
  • fft_data β€” Power spectrum values per frequency bin.
  • correlogram β€” Moran's I values at each distance bin.
  • bitflip_counts β€” Up and down bitflip counts.
  • jaccard_results β€” Pairwise Jaccard similarity between data patterns.
  • run_metadata β€” Per-file run metadata (timings, temperature, voltage, row count) and the build that wrote it.
  • build_runs, build_files, analysis_configs β€” Build provenance; see Build Provenance and Reproducibility.

Every per-run table is keyed on (DIMM, bank, run, victim/aggressor pattern, disturbance_type, taggon_time). The disturbance_type/taggon_time columns were added for RowPress ('rp', with taggon_time the aggressor-on time) during the rework of this pipeline; RowPress was not part of the original pipeline's scope. Input files whose JSON metadata contains tAggOn are tagged 'rp' automatically; all others are 'rh' (RowHammer). db_access.py query methods default to disturbance_type='rh'.

Step 4: Paper Analysis Scripts β€” Figures and Analysis

Individual paper directories (ets/, vts/, host/, dramsec_cnn/) contain scripts that:

  1. Query results.db (or other databases) for the relevant DIMMs, patterns, and computed features.
  2. Perform additional analysis on the cached data β€” statistical tests, comparisons across vendors or patterns, visualization of spatial distributions.
  3. Generate figures using python/publication_style.py for IEEE two-column paper formatting (PDF and PNG at 300 DPI).
  4. Write findings to markdown or JSON files for inclusion in the paper.

For cell-level prediction work, the celllevel_dataset.py and celllevel_models.py modules read LISA cluster coordinates from the database to construct training patches, simulate sparse probing, and train segmentation models (UNet, PixelMLP) for vulnerability prediction.

Fixed β€” ets/'s scripts (and tches/tches_plot.py) previously failed immediately with ModuleNotFoundError: No module named 'python' when run the natural way (python3 ets/some_script.py from the repo root), because their from python.X import Y-style imports need the repo root on sys.path, and running a script that way puts its own directory there instead. Each affected file now inserts the repo root onto sys.path itself at the top of the file, so no special invocation is needed anymore β€” python3 ets/some_script.py from the repo root works as documented.

Data Flow Summary

flowchart TD
    A[".bin + .json files"] --> B["batch_analyze.py<br/>(GPU-accelerated)"]
    B --> C["Global Moran's I<br/>(multi-scale)"]
    B --> D["ACF<br/>(row + column)"]
    B --> E["FFT Power Spectrum"]
    B --> F["LISA Clusters<br/>(HH, HL)"]
    B --> G["Moran Correlogram"]
    B --> H["Bitflip Counts"]
    B --> I["Jaccard Similarity"]
    C --> J["results.db<br/>(SQLite)"]
    D --> J
    E --> J
    F --> J
    G --> J
    H --> J
    I --> J
    J --> K["ets/ scripts --> ETS paper figures"]
    J --> L["vts/ scripts --> VTS paper figures"]
    J --> M["host/ scripts --> HOST paper figures"]
    J --> O["dramsec_cnn/ scripts --> DRAMSec CNN results"]
    J --> N["celllevel_dataset.py + celllevel_models.py --> CNN/UNet training (ets/)"]

Known Limitations

Statistical correctness β€” three confirmed fixes, independently verified

  • Global Moran's I / LISA: LISA's standardization previously used a dimensionally-incorrect ad hoc variance term; now uses the closed-form Anselin (1995)/Sokal (1998) randomization-null moments for row-standardized weights, verified by independently re-deriving the formula from the underlying Bernoulli central moments (not just trusting the code comment).
  • ACF: the batched-file code path (the one --batch-size > 1 actually uses) previously included the trivial lag-0 self-correlation as "lag 1," shifting every later lag down one position. Fixed; the single-file path was never affected.
  • Correlogram: two fixes confirmed present in python/moran_torch.py and python/batch_analyze.py β€” a sampling redesign that avoids a degenerate case where every sampled point carried identical value 1, and a bin-write fix (int(bin_center) truncation instead of round(), which otherwise collides adjacent bins via round-half-to-even and silently drops every odd-numbered distance via INSERT OR REPLACE). Both confirmed present in the current code by reading _worker_process_correlogram directly, function name and all.

Numerical precision

FP16 changes the computed value only for Global Moran's I, and only on GPU (on CPU every statistic is computed in FP32). Measured relative differences, FP16 vs FP32: 0.22%-2.99% on 4096-row RowPress captures (data/rp_v_rh/, single-file path); median 0.034%, maximum 0.13% on 48 16384-row captures of data/old_data/acf/ (default batched path). LISA, ACF, FFT, bitflip counts and the correlogram are unaffected. The original pipeline (8817b0c) produced byte-identical results at FP16 and FP32 on 16384-row captures, so the published values for those banks do not depend on its precision setting. The pipeline defaults to FP32.

Statistical significance in global_moran

Reported p-values are effectively uninformative at this dataset's scale (~33.5 million cells per bank): the theoretical variance of Moran's I under these conditions is small enough that almost any nonzero value produces pβ‰ˆ0. Effect sizes (the Moran's I value itself, compared across conditions) carry the actual argument; the stored p-values shouldn't be cited as evidence of anything on their own.

Bank depth in the model-training loaders

Most banks in data/old_data/acf/ were captured at 16384 rows; only banks 1-2 of seven DIMMs have the full 65536 (see Datasets and DIMMs). A loader that sizes every bank at 65536 rows and zero-fills the rest turns rows that were never measured into rows with zero bitflips. For windowed tasks, these become "Safe" samples.

dramsec_cnn/ keeps this behaviour because it is the published DRAMSec method. Measured on the four validation DIMMs (hynix06, samsung06, micron02, micron14) with the current results.db, the inter-DIMM validation set has 5952 samples, 77.6% of them Safe; 4608 of those samples have targets beyond the measured rows. Restricted to measured rows, the set would be 1344 samples, 0.7% Safe. Treat DRAMSec inter-DIMM/LODO accuracy and class-balance figures with this in mind. tests/test_dramsec_original_method.py pins this construction.

The ETS loaders and the shared cell-level datasets keep it too (ets/ets_cnn_train.py, python/celllevel_dataset.py, python/window_filtered_dataset.py, ets/ets_unet_validate.py, ets/ets_twostage_inference.py, ets/ets_check_class_balance.py). On the current results.db, ets_cnn_train.load_data builds 32256 windows (1008 bank/pattern maps Γ— 32); the validation DIMMs contribute 6144, 75.2% of them Safe. Of 3072 validation patches (1024 Γ— 1024, 16 per bank, CellLevelPatchDataset, seed 42), 74.9% lie entirely in unmeasured rows. tests/test_ets_original_method.py pins this construction.

HOST analysis: earlier versions of this repository used an older script

Until this release, host/host_analysis.py was the original repository's 2026-06-06 version (47048c6) instead of 8817b0c, so it lacked adb3b05 (Mahalanobis inter-device distance, parallel intra-device baseline) and c402786 (baseline inter-DIMM statistics fix). HOST results produced with those versions do not follow the final original method. The 8817b0c version is restored.

Samsung naming in the HOST temperature data

The heated captures of samsung01 (the only Samsung revision tested) are named samsung01_<T>c_*, but their capture JSON names the DIMM samsung11_<T>c, and batch_analyze.py takes the DIMM ID from the JSON. host/host_analysis.py queries samsung01_<T>c, so in a freshly built results_puf.db the Samsung temperature groups of run_puf_entropy_suitability_analysis() are empty. Relabel the database once after building it:

python3 - <<'EOF'
import sqlite3
conn = sqlite3.connect("host/results_puf.db")
tables = [r[0] for r in conn.execute("SELECT name FROM sqlite_master WHERE type='table'")]
for t in tables:
    if "dimm_id" in [c[1] for c in conn.execute(f"PRAGMA table_info({t})")]:
        conn.execute(f"UPDATE {t} SET dimm_id = replace(dimm_id, 'samsung11_', 'samsung01_') "
                     "WHERE dimm_id LIKE 'samsung11%'")
conn.commit()
EOF

The file-based HOST analyses (.bin paths on the command line) read the file names and are not affected.

Known issues in paper scripts (not fixed)

  • ets/ets_twostage_inference.py stage 2 crashes (tensor size mismatch in _predict_patch: the positional encoding is square, the 2048Γ—8192 window is not), and patch sizes below 2048 raise NotImplementedError.
  • ETS XGBoost feature fft_row_640 is always 0: no stored FFT period falls in 635-645 for any --acf-lags below 16384 (see FFT spectrum binning below).
  • vts/vts_comprehensive_test_efficiency.py does not map stored patterns (0xFF/0x00, …) to their names (RowStripe, Checkered, ColumnStripe).
  • ets/ets_test_celllevel_speed.py and ets/ets_check_class_balance.py run at import time (no if __name__ == "__main__" guard).
  • RowhammerDB and the raw-sqlite3 loaders create an empty database file when given a path that does not exist, so a wrong working directory gives empty results rather than an error.

Databases built before build provenance

Databases created before build provenance existed carry no record of the parameters they were built with (schema version 0). They remain readable, but batch_analyze.py refuses to append to them, and their parameters can only be inferred (for example, the ACF lag setting from the highest stored lag).

Automated test suite and CI

See Test Suite above: tests/ (58 tests) covers all four core statistics β€” Global Moran's I, LISA, ACF, and the correlogram (including its separate DB-write bin-collision path) β€” with known-answer, regression, and (where a suitable library exists) cross-validation tests. Every regression test is verified to actually catch its target bug: each historical fix was temporarily reverted and the corresponding test confirmed to fail, not just written and assumed correct. .github/workflows/tests.yml runs this suite automatically (CPU-only) on every push and pull request to main/master. Extending coverage as new functions are added is the intended ongoing practice, not a one-time effort. test_provenance.py covers the build-provenance guards and records (including an end-to-end run of batch_analyze.py on CPU with synthetic inputs). test_dramsec_original_method.py and test_ets_original_method.py check that dramsec_cnn/ and the ETS loaders keep the published sample construction; test_db_access_columns.py checks that db_access.py returns the columns the original returned.

FFT spectrum binning

fft_data stores each spectrum bin under period = int(round(1/f)), keyed with INSERT OR REPLACE. Several bins round to the same integer period and only the last one written is kept: with --acf-lags 200 (256-point FFT) 30 of 128 bins survive; with --acf-lags 1024-2047 (2048-point FFT) 89 of 1024 do. At 2048 points, the row stored as period 32 holds the bin whose true period is 31.51, not 32.00. Not yet fixed β€” it needs a schema change to store the exact bin. Until then, compare FFT features only between databases built with the same --acf-lags, and treat individual period values as approximate.

batch_analyze.py multi-GPU orchestration

--gpu-config spawns one subprocess per GPU. This path (including CLI/argparse handling, the streaming file loader, and per-GPU CUDA_VISIBLE_DEVICES assignment) has been reviewed and one real regression was found and fixed: a worker's CUDA_VISIBLE_DEVICES assignment had been silently disabled, which would have caused every --gpu-config worker to run on the same GPU regardless of its assigned ID on genuinely multi-GPU hardware. This project's own hardware is single-GPU, so re-verify the fix on real multi-GPU hardware before relying on it for a production run.

Downloads last month
3