ashen-navigator's picture
Ship the complete covcollab package (all covcollab-eve-* CLIs; portable pyproject)
690fde9 verified
|
Raw
History Blame Contribute Delete
11.5 kB

Training the Universal Eve warden

This dataset ships with the trainer that consumes it: Universal Eve, a multi-task warden that, from a single N_E × T block of Eve's received signal, jointly (a) detects whether a covert distributed virtual-MIMO collaboration is present (H0 vs H1) and (b) fingerprints its structure — waveform format, system size M, message shape (K, d), channel family, and the collaboration-policy arm. The script is src/covcollab/universaleve/multitask.py, exposed as the covcollab-eve-mtl command.

The scientific point of the model is the presence ≠ structure dichotomy: detection is recoverable (regime-flat AUC ≈ 0.88), waveform/channel partially recover and lift with more antennas/looks, but system size and policy identity stay at chance on the payload. Training it reproduces that map.

Prefer a runnable walkthrough? notebooks/train_universal_eve.ipynb does load → build → train → evaluate → plot the fingerprinting map end-to-end (Colab-ready).


What it trains on

The trainer reads the dataset splits directly (no re-generation):

split role
train fit the backbone + heads
val (validation) monitoring
test_iid in-distribution evaluation
test_ood held-out strong-Doppler shift

Two configs are available and interchangeable via --data:

  • defaultN_E = 4 receive antennas (the main config).
  • multi_neN_E ∈ {1,2,4,8} swept, zero-padded to N_E^max = 8 with a validity mask; use it to study the antenna-count frontier.

Each sample is a complex (N_E, T=320) block plus a 26-field metadata row (detection label, format, n_tx=M, n_msg_users=K, msg_dim=d, channel_family, policy_arm, per-sample Eve and Bob SNRs, a regime tag ∈ {covert, comparable, detectable}, and a cell_id for same-emitter multi-look grouping).

The model

One shared encoder feeds all tasks (≈ 2.1 × 10⁵ parameters):

per-antenna multi-scale Conv1d  →  state-space long-conv temporal block
      →  masked attention+mean antenna pool (variable N_E)
      →  concat a 7-dim spatial-covariance eigen-branch (non-sphericity, log-MME,
         log-energy, top eigenvalue ratios)                       ⇒  embedding e
a spectral/pilot branch (log-PSD + cyclic-autocorrelation)        ⇒  spec_emb
heads:  detection (BCE, off e, all samples)
        format / M / K / d / channel / policy-arm (CE, off [e, spec_emb], H1 only)
loss:   masked, uncertainty-weighted (homoscedastic Kendall–Gal) multi-task loss

Optimizer: AdamW (wd=1e-4) + warmup/cosine LR + grad clipping — the combination that keeps the deep-covert run from the weight-collapse failure mode of plain Adam with large L2.


Install

# from the dataset repo root
pip install -e ".[hf]"          # installs numpy, torch, pyarrow (parquet)

torch from PyPI is the CPU/Apple-MPS build. For NVIDIA GPUs install a CUDA build first (see the GPU section), then pip install -e ".[hf]" will keep it.

Quickstart

# joint detect+fingerprint (regime A) + a detection-representation probe (regime C),
# evaluated on test_iid and test_ood; auto-selects CUDA > MPS > CPU
covcollab-eve-mtl --data . --regime both --out runs/mtl

A fast end-to-end sanity run (tiny, ~1–2 min including the parquet load):

covcollab-eve-mtl --data . --smoke --regime A --out runs/mtl_smoke

Outputs land in --out: a per-regime A/ckpt.pt, C/ckpt.pt, … and a results.json with per-split detection AUC and per-attribute accuracy (each scored against its majority-class baseline — only lift above it is genuine recovery).

CLI

flag default meaning
--data huggingface/covcollab-eve-detection dataset dir (. from this repo), or a HF path
--regime both A joint · C detection-rep probe · B multi-look sweep · both (A+C)
--steps 4000 training steps (per regime)
--probe-steps 2500 regime-C probe steps
--width 96 backbone width
--batch 256 minibatch size
--look-sizes 1 2 4 8 regime-B: L values in the multi-look sweep
--n-looks 32 regime-B: looks pooled per step
--max-train all subsample the train split (fit smaller machines / faster)
--device auto auto (cuda>mps>cpu), or cuda / mps / cpu
--feat-device auto where feature extraction runs (see GPU section)
--eval-splits test_iid test_ood splits to evaluate
--out runs/mtl output dir
--smoke off tiny config for a quick end-to-end check

Regimes. A trains the joint multi-task model. C trains detection only, then fits MLP probes on the frozen detection embedding — the A-vs-C gap shows whether structure lives in the detector's representation (it does not) or only in the spectral branch. B sweeps temporal looks L to lift the fingerprint frontier (format rises ∝ √L; policy stays flat).


Training on NVIDIA GPUs (A100 and others)

Unlike the on-the-fly adversarial warden (which synthesizes signals every step and is data-generation-bound), this trainer reads pre-generated blocks, so a GPU accelerates the actual work with no synthesis overhead. Two device knobs matter.

1. Install a CUDA build of PyTorch

The single most common mistake is training on a CPU torch wheel. Install the CUDA build that matches your driver (CUDA 12.1 shown):

pip install torch --index-url https://download.pytorch.org/whl/cu121
python -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_name(0))"
pip install -e ".[hf]"          # add numpy + pyarrow without touching torch

2. Put the whole step on the GPU: --device cuda --feat-device auto

  • --device cuda runs the network (forward/backward) on the GPU.
  • --feat-device auto runs the feature extraction — the complex-valued FFT (spectral branch) and the spatial-covariance eigvalsh (eigen-branch) — on the GPU too, in complex64. This is CUDA-only: Apple MPS has no complex-tensor support, so on MPS/CPU features stay on CPU automatically (auto resolves to CPU there). Force it with --feat-device cuda / cpu if needed.

With both on CUDA, the only host-side cost is loading the parquet split into memory once.

covcollab-eve-mtl --data . --regime both \
    --device cuda --feat-device auto \
    --width 96 --batch 512 --steps 6000 --out runs/mtl_a100

Recommended settings by GPU

The backbone is small (~0.2 M params), so training is fast and fits comfortably on any modern NVIDIA card; larger GPUs mainly let you scale --width/--batch and run more steps.

GPU --batch --width notes
A100 40/80 GB, H100 512–1024 96–192 ample headroom; whole step on-GPU; --steps 6000+
L40S / A6000 (48 GB) 512 96–128 same profile as A100 at smaller width
RTX 4090 / 3090 (24 GB) 256–512 96 keep the default config
T4 / RTX 2080 (≤16 GB) 128–256 64–96 --max-train 40000 if host RAM is tight

The full train split is ~1 GB in host memory; feature tensors are built per-batch, so VRAM use is modest even at --width 192. If host RAM is the constraint, --max-train N subsamples the split.

Throughput and expectations

The network is tiny relative to an A100, so a run is dominated by the one-time data load, not compute: the default 4000-step regime-A fit completes in a few minutes on an A100, and the full --regime both in well under ~15 minutes. (For reference, the same run takes ~1–2 hours on an Apple-MPS laptop, most of it CPU feature extraction — which --feat-device auto removes on CUDA.) A single A100 is more than enough; there is no need for multi-GPU.

Using multiple GPUs

The trainer is single-GPU by design. To use several A100s productively, run independent jobs in parallel — one device each — rather than sharding one small model:

# regimes in parallel, one GPU each
CUDA_VISIBLE_DEVICES=0 covcollab-eve-mtl --data . --regime A --device cuda --out runs/A &
CUDA_VISIBLE_DEVICES=1 covcollab-eve-mtl --data . --regime C --device cuda --out runs/C &
CUDA_VISIBLE_DEVICES=2 covcollab-eve-mtl --data . --regime B --device cuda --out runs/B &
wait

or sweep seeds / --width / the multi_ne config across cards the same way.

Sanity gates before a long or metered run

  • Always dry-run --smoke on the target machine first; it exercises the full load → train → evaluate path in ~1–2 min.
  • The AdamW + LR-schedule recipe here is the one that avoids the deep-covert weight-collapse seen with plain Adam + large weight decay; if you change the optimizer, verify the training loss decreases and the detection AUC on val is non-degenerate (≠ 0.5) on a short run before committing GPU time.

On a shared HTCondor cluster (e.g. Syracuse OrangeGrid)

If your GPUs come from an HTCondor batch pool rather than an interactive card, this repo ships a ready-to-use submission kit under deploy/orangegrid/ (submit file, wrapper, one-time uv-based setup, and a parallel regime/hyperparameter sweep), tuned for Syracuse University's OrangeGrid (A100 / A40 / L40S; +request_gpus = 1, Requirements = (CUDADriverVersion >= 12.0) && (CUDACapability >= 8.0), shared-home filesystem so no file transfer). After downloading this dataset repo to your cluster home:

cd ~/covcollab-eve-detection
bash deploy/orangegrid/setup_orangegrid.sh      # build the .venv with covcollab-eve-mtl
condor_submit deploy/orangegrid/train.sub       # one GPU run;  condor_q <netid> to watch
condor_submit deploy/orangegrid/sweep.sub       # regimes A/C/B in parallel, one GPU each

See deploy/orangegrid/README.md for access, configuration, and troubleshooting. The same pattern (a wrapper that runs covcollab-eve-mtl … --device cuda --feat-device auto on a shared FS) adapts to any HTCondor pool.


The synthesis-based warden (optional, different tool)

If instead of training on this fixed dataset you want the on-the-fly, distributionally-robust warden that synthesizes fresh domains every step (randomizing policy/waveform/channel/SNR/N_E), that entry point now ships in this repo too (covcollab.universaleve.run.train_and_eval, with a Modal/Colab cloud path). It is generation-bound rather than compute-bound, so its GPU story centers on running the complex simulator on CUDA (sim_device="cuda"), not just the net. This dataset and covcollab-eve-mtl do not require it.

The same on-the-fly stack powers the adversary-envelope depth study (covcollab-eve-envelope, covcollab-eve-ladder) — see deploy/orangegrid/README.md for the batch fan-out.


Reproducing the fingerprinting map

covcollab-eve-mtl --data . --regime both --steps 4000 --width 96 --out runs/map

Read runs/map/results.json: detection AUC is high and regime-flat; format (+0.14) and channel (+0.11) clear their baselines in the joint model (A) but not from the frozen detection probe (C); M, K, d, and policy-arm sit at their class priors — the central null. Add --regime B to see format lift with looks while the policy-arm stays flat.