wifi-densepose/v2/crates/wifi-densepose-train
ruv c9fde3cba5 feat(train): AetherTemporalAggregator — wire wifi-densepose-temporal into the tch graph (#513)
ADR-096 train integration. Additive — does NOT modify model.rs. The
existing WiFiDensePoseModel forward stays bit-equivalent for back-compat.
New code lives in temporal_aether.rs behind the `aether-sparse-temporal`
feature flag (which itself requires `tch-backend`).

Architecture:

    tch::Tensor [T, in_dim]   ──── tch nn::Linear (q/k/v projections)
                                    ↓
                              [T, q_heads*head_dim] etc
                                    ↓
                             tch_to_tensor3 (CPU, f32, 1× copy)
                                    ↓
                              ruvllm_sparse_attention::Tensor3
                                    ↓
                            AetherTemporalHead::forward()
                                    ↓
                              Tensor3 [T, q_heads, head_dim]
                                    ↓
                             tensor3_to_tch (1× copy)
                                    ↓
                              tch::Tensor [T, q_heads*head_dim]
                                    ↓
                              tch nn::Linear (output projection)
                                    ↓
                              tch::Tensor [T, in_dim]

Why additive rather than swapping `apply_antenna_attention` /
`apply_spatial_attention` in model.rs: those are over antenna and
spatial axes, not temporal — ADR-096 §8.1 was right that AETHER
doesn't currently HAVE a temporal-axis attention. This commit adds
that path without disturbing the others, so the §5 validation gate
can A/B the two options before flipping the production default.

Scope notes:
- B=1 prefill only this version. Multi-batch lands when §5 turns
  green and we need to take perf seriously. The forward expects
  `[T, in_dim]` not `[B, T, in_dim]`; documented in the file.
- Streaming step() bridge deferred — KvCache lifecycle ties to
  PoseTrack per ADR-096 §8.5, which is signal-side not train-side.
- Two CPU memory copies per call (in + out). For training-rate
  forwards (~100/sec at batch 16) this is negligible vs the actual
  attention work; for inference-rate streaming it'd be the
  bottleneck and a zero-copy path is the natural follow-up.

Build verification:
- Source compiles cleanly with cargo check on the host crate
  (`-p wifi-densepose-temporal`, 21/21 tests still passing).
- The train crate's tch-backend build is environmentally blocked
  on this Windows machine — torch-sys fails to link against the
  system PyTorch 2.11 + MSVC 14.50 toolchain. This predates this
  commit and affects all tch-bound code paths in the workspace.
  CI runners with working libtorch will verify the new module
  builds; the source follows the same nn::Linear / Module patterns
  the existing model.rs uses.

Feature gating ensures default builds are byte-equivalent. Off by
default; enable with `--features aether-sparse-temporal`.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-08 12:42:41 -04:00
..
benches chore(repo): rename rust-port/wifi-densepose-rs → v2/ (flatten to one level) (#427) 2026-04-25 21:28:13 -04:00
src feat(train): AetherTemporalAggregator — wire wifi-densepose-temporal into the tch graph (#513) 2026-05-08 12:42:41 -04:00
tests chore(repo): rename rust-port/wifi-densepose-rs → v2/ (flatten to one level) (#427) 2026-04-25 21:28:13 -04:00
Cargo.toml feat(train): AetherTemporalAggregator — wire wifi-densepose-temporal into the tch graph (#513) 2026-05-08 12:42:41 -04:00
README.md chore(repo): rename rust-port/wifi-densepose-rs → v2/ (flatten to one level) (#427) 2026-04-25 21:28:13 -04:00

README.md

wifi-densepose-train

Crates.io Documentation License

Complete training pipeline for WiFi-DensePose, integrated with all five ruvector crates.

Overview

wifi-densepose-train provides everything needed to train the WiFi-to-DensePose model: dataset loading, subcarrier interpolation, loss functions, evaluation metrics, and the training loop orchestrator. It supports both the MM-Fi dataset (NeurIPS 2023) and deterministic synthetic data for reproducible experiments.

Without the tch-backend feature the crate still provides the dataset, configuration, and subcarrier interpolation APIs needed for data preprocessing and proof verification.

Features

  • MM-Fi dataset loader -- Reads the MM-Fi multimodal dataset (NeurIPS 2023) from disk with memory-mapped .npy files.
  • Synthetic dataset -- Deterministic, fixed-seed CSI generation for unit tests and proofs.
  • Subcarrier interpolation -- 114 -> 56 subcarrier compression via ruvector-solver sparse interpolation with variance-based selection.
  • Loss functions (tch-backend) -- Pose estimation losses including MSE, OKS, and combined multi-task loss.
  • Metrics (tch-backend) -- PCKh, OKS-AP, and per-keypoint evaluation with ruvector-mincut-based person matching.
  • Training orchestrator (tch-backend) -- Full training loop with learning rate scheduling, gradient clipping, checkpointing, and reproducible proofs.
  • All 5 ruvector crates -- ruvector-mincut, ruvector-attn-mincut, ruvector-temporal-tensor, ruvector-solver, and ruvector-attention integrated across dataset loading, metrics, and model attention.

Feature flags

Flag Default Description
tch-backend no Enable PyTorch training via tch-rs
cuda no CUDA GPU acceleration (implies tch)

Binaries

Binary Description
train Main training entry point
verify-training Proof verification (requires tch-backend)

Quick Start

use wifi_densepose_train::config::TrainingConfig;
use wifi_densepose_train::dataset::{SyntheticCsiDataset, SyntheticConfig, CsiDataset};

// Build and validate config
let config = TrainingConfig::default();
config.validate().expect("config is valid");

// Create a synthetic dataset (deterministic, fixed-seed)
let syn_cfg = SyntheticConfig::default();
let dataset = SyntheticCsiDataset::new(200, syn_cfg);

// Load one sample
let sample = dataset.get(0).unwrap();
println!("amplitude shape: {:?}", sample.amplitude.shape());

Architecture

wifi-densepose-train/src/
  lib.rs            -- Re-exports, VERSION
  config.rs         -- TrainingConfig, hyperparameters, validation
  dataset.rs        -- CsiDataset trait, MmFiDataset, SyntheticCsiDataset, DataLoader
  error.rs          -- TrainError, ConfigError, DatasetError, SubcarrierError
  subcarrier.rs     -- interpolate_subcarriers (114->56), variance-based selection
  losses.rs         -- (tch) MSE, OKS, multi-task loss        [feature-gated]
  metrics.rs        -- (tch) PCKh, OKS-AP, person matching     [feature-gated]
  model.rs          -- (tch) Model definition with attention    [feature-gated]
  proof.rs          -- (tch) Deterministic training proofs      [feature-gated]
  trainer.rs        -- (tch) Training loop orchestrator         [feature-gated]
Crate Role
wifi-densepose-signal Signal preprocessing consumed by dataset loaders
wifi-densepose-nn Inference engine that loads trained models
ruvector-mincut Person matching in metrics
ruvector-attn-mincut Attention-weighted graph cuts
ruvector-temporal-tensor Compressed CSI buffering in datasets
ruvector-solver Sparse subcarrier interpolation
ruvector-attention Spatial attention in model

License

MIT OR Apache-2.0