Commit Graph

4 Commits

Author SHA1 Message Date
ruv 7d26b15eef feat(train): MERIDIAN-MAE — csi_mae::model + pretrain loop + pretrain-mae bin (iter 2b, #68)
Real CSI masked-autoencoder behind feature `tch-backend` (ADR-027 §2.0):

  - CsiMae: dual-stream per-token amp+phase embed → fuse → residual-MLP encoder
    over the visible tokens → flatten-to-latent bottleneck → learned per-position
    query + broadcast latent → residual-MLP decoder → dec_amp_head / dec_ph_head
    → index_select the masked positions. (MLP-based v0; self-attention transformer
    blocks are iter 3.)
  - CsiMae::reconstruction_loss(pred_amp, pred_phase, tgt_amp, tgt_phase, phase_w)
    = MSE(amp) + phase_w * MSE(phase).
  - MaeBatch::from_windows — partition computed once from window 0 and reused
    across the batch (the bottleneck fixes n_tokens), ndarray → tch conversion.
  - pretrain_step(model, opt, batch) -> f64 — one Adam step, returns the loss.
  - src/bin/pretrain_mae.rs — synthetic-data pre-train driver (required-features
    = ["tch-backend"]); clap args for epochs/batch/samples/lr/mask-ratio/save.
  - #[cfg(feature="tch-backend")] smoke test: loss halves when overfitting one
    batch over 60 steps; also asserts model.n_visible/n_masked match
    mask_csi_window's clamping.

v0 limits (documented in the module): fixed n_tokens; batch-shared masking;
MSE on unwrapped phase (vs a circular loss). The dev box has no LibTorch, so the
tch path is CI-verified (`--features tch-backend`), not locally. The default
`cargo test -p wifi-densepose-train --no-default-features` stays green (121 lib
tests) — the model module and the bin are both feature-gated.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-11 13:05:27 -04:00
ruv 48c7d03250 feat(train): MERIDIAN-MAE — information-guided masking (iter 2a, #68)
csi_mae::mask_csi_window now dispatches on MaskStrategy:
  - Random:      uniform Fisher–Yates (as before).
  - InfoGuided:  CIG-MAE-style — preferentially mask high-information tokens.
                 A token's "information" = variance of its amplitude values +
                 variance of its phase values (token_information()); near-constant
                 tokens are trivially in-painted so masking them teaches less.
                 Selection is weighted-without-replacement (Efraimidis–Spirakis:
                 key_i = u_i^(1/w_i), ranked by ln(u_i)/w_i) — exact, and
                 deterministic given `seed` (the u_i come from SplitMix64).

Replaces the iteration-1 "InfoGuided falls back to Random with a warning" stub.
+3 unit tests (info-guided skews ≥7.5/10 toward high-info tokens; deterministic
in seed; token_information ≈ 0 for constant tokens). `cargo test -p
wifi-densepose-train --no-default-features` → 121 lib tests pass.

Still to do (iter 2b, next loop tick): the real csi_mae::model (tch encoder/
decoder + reconstruction_loss + pretrain_step), bin/pretrain_mae.rs, a gated
"loss decreases" smoke test.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-11 12:57:42 -04:00
ruv 603ad585b6 feat(train): MERIDIAN-MAE — CSI masked-autoencoder masking pipeline (iter 1, #68)
New `wifi-densepose-train::csi_mae` module (ADR-027 §2.0):

  - MaeConfig (+ validate), MaskStrategy {Random, InfoGuided}
  - TokenLayout — flattens a [T,tx,rx,sub] CSI window to [N=T*tx*rx, sub] tokens
    (the same layout model.rs::ModalityTranslator consumes)
  - mask_csi_window — deterministic visible/masked token partition + amplitude &
    phase reconstruction targets; reproducible via a tiny inline SplitMix64 PRNG
    (no extra dependency); clamps so both partitions are non-empty
  - reassemble_tokens — round-trips encoder-visible + decoder-predicted tokens
    back to a full [N, sub] grid (for reconstruction eval/viz)
  - model submodule (gated behind `tch-backend`): v0 skeleton — the
    encoder/decoder networks, reconstruction loss, and pretrain_step land in
    iteration 2 (transformer blocks, per-sample masking, info-guided masking,
    a `pretrain-mae` bin)

8 new unit tests; builds and tests green under
`cargo test -p wifi-densepose-train --no-default-features` (118 lib tests pass).
The tch-gated `model` submodule is not exercised by the default workspace test
job — compile-checking it needs a LibTorch toolchain.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-11 12:45:11 -04:00
rUv f49c722764 chore(repo): rename rust-port/wifi-densepose-rs → v2/ (flatten to one level) (#427)
The Rust port lived two directories deep (rust-port/wifi-densepose-rs/)
without any sibling under rust-port/ that warranted the extra level.
Move the whole workspace up to v2/ to match v1/ (Python) at the same
depth and shorten every cd / build command across the repo.

git mv preserves history for all tracked files. 60 files updated for
path references (CI workflows, ADRs, docs, scripts, READMEs, internal
.claude-flow state). Two manual fixes for relative-cd paths in
CLAUDE.md and ADR-043 that became wrong after the depth change
(cd ../.. → cd ..).

Validated:
- cargo check --workspace --no-default-features → clean (after target/
  nuke; the gitignored target/ was carried by the OS rename and had
  hard-coded old paths in build scripts)
- cargo test --workspace --no-default-features → 1,539 passed, 0 failed,
  8 ignored (same totals as pre-rename)
- ESP32-S3 on COM7 → still streaming live CSI (cb #40300, RSSI -64 dBm)

After-merge follow-up: contributors should `rm -rf v2/target` once and
let cargo regenerate from the new path.
2026-04-25 21:28:13 -04:00