mirror of
https://github.com/ruvnet/RuView
synced 2026-07-22 17:23:19 +00:00
189ac9dfb0
Bind the ADR-027 MERIDIAN cross-environment domain-generalization surface
into the wheel behind a gated [meridian] extra / Cargo `meridian` feature.
Inference/adaptation path only (tch-free), per ADR-185 section 3.3.
Surface (bound against the REAL code at HEAD, not the ADR wishlist):
- HardwareType / HardwareNormalizer / CanonicalCsiFrame (from
wifi-densepose-signal::hardware_norm)
- MeridianGeometryConfig / GeometryEncoder (64-dim, permutation-invariant)
- RapidAdaptation / AdaptationResult (push_frame + adapt, LoRA deltas)
- CrossDomainEvaluator + mpjpe (from wifi-densepose-train, NO tch-backend)
All compute paths GIL-released (py.allow_threads).
Honest deviations from ADR section 3.3 (documented in the module header):
- ADR's RapidAdaptation.calibrate(windows) and AdaptationResult.converged
DO NOT EXIST. Real API is push_frame + adapt(); result carries
{lora_weights, final_loss, frames_used, adaptation_epochs}. Bound as-is.
- ADR's HardwareType.detect exposed as a staticmethod delegating to the
real HardwareNormalizer::detect_hardware.
- ADR's normalize(frame: CsiFrame, hw) is really normalize(amplitude,
phase, hw) over f64 vectors returning Result; bound faithfully.
- CanonicalCsiFrame fields are singular amplitude/phase (ADR said plural).
Training-time types (DomainFactorizer, GradientReversalLayer,
VirtualDomainAugmentor) are out of P6 scope (need the libtorch tier).
Parity (section 4.1, release-blocking): committed fixture
meridian_input.json -> native Rust reference (tests/meridian_parity.rs,
calls hardware_norm + geometry + rapid_adapt directly) locks
tests/golden/meridian_output.sha256 over the concatenated f32 outputs
(esp32+intel canonical frames, 64-dim geometry vector, rapid-adapt LoRA
weights); pytest (tests/test_meridian.py) runs the same fixture through
the binding and asserts the identical SHA-256. Both pass.
Verified:
cargo test --features meridian --test meridian_parity -> 2/2 pass
maturin develop --features meridian + pytest tests/test_meridian.py
-> 13/13 pass
default cargo build clean, 0 train/signal/sensing-server refs in the
default dep graph (gate keeps the base wheel lean).
WHEEL-SIZE FINDING (ADR-185 section 9 / section 1.2): the libtorch risk
the ADR feared is AVOIDED -- wifi-densepose-train's `tch` dep is properly
optional (feature tch-backend, OFF), so no libtorch links. BUT train
still carries NON-optional deps: tokio (rt subset), the five ruvector-*
crates, and wifi-densepose-nn (which itself pulls `ort` / ONNX Runtime +
reqwest/hyper). So a [meridian] wheel exceeds the ADR-117 section 5.4
<=5 MB budget (though lighter than AETHER's axum/tokio server tree). The
clean fix is the same leaf-crate hoist: move the pure inference modules
(geometry, rapid_adapt, eval, hardware_norm) into a tch/tokio/ort-free
leaf crate. A required pre-release follow-up, not a functional blocker;
P2 binds real code and proves parity today.
106 lines
2.9 KiB
Python
106 lines
2.9 KiB
Python
"""Type stubs for the MERIDIAN bindings (ADR-185 P2).
|
|
|
|
Present only when the wheel is built with the ``[meridian]`` extra.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import enum
|
|
|
|
class HardwareType(enum.Enum):
|
|
Esp32S3 = 0
|
|
Intel5300 = 1
|
|
Atheros = 2
|
|
Generic = 3
|
|
@staticmethod
|
|
def detect(subcarrier_count: int) -> HardwareType: ...
|
|
@property
|
|
def subcarrier_count(self) -> int: ...
|
|
@property
|
|
def mimo_streams(self) -> int: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
class CanonicalCsiFrame:
|
|
@property
|
|
def amplitude(self) -> list[float]: ...
|
|
@property
|
|
def phase(self) -> list[float]: ...
|
|
@property
|
|
def hardware_type(self) -> HardwareType: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
class HardwareNormalizer:
|
|
def __init__(self, canonical_subcarriers: int = ...) -> None: ...
|
|
@staticmethod
|
|
def detect_hardware(subcarrier_count: int) -> HardwareType: ...
|
|
@property
|
|
def canonical_subcarriers(self) -> int: ...
|
|
def normalize(
|
|
self, amplitude: list[float], phase: list[float], hardware: HardwareType
|
|
) -> CanonicalCsiFrame: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
class MeridianGeometryConfig:
|
|
def __init__(
|
|
self,
|
|
n_frequencies: int = ...,
|
|
scale: float = ...,
|
|
geometry_dim: int = ...,
|
|
seed: int = ...,
|
|
) -> None: ...
|
|
@property
|
|
def n_frequencies(self) -> int: ...
|
|
@property
|
|
def scale(self) -> float: ...
|
|
@property
|
|
def geometry_dim(self) -> int: ...
|
|
@property
|
|
def seed(self) -> int: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
class GeometryEncoder:
|
|
def __init__(self, config: MeridianGeometryConfig | None = ...) -> None: ...
|
|
def encode(self, ap_positions: list[list[float]]) -> list[float]: ...
|
|
@property
|
|
def geometry_dim(self) -> int: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
class AdaptationResult:
|
|
@property
|
|
def lora_weights(self) -> list[float]: ...
|
|
@property
|
|
def final_loss(self) -> float: ...
|
|
@property
|
|
def frames_used(self) -> int: ...
|
|
@property
|
|
def adaptation_epochs(self) -> int: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
class RapidAdaptation:
|
|
def __init__(
|
|
self,
|
|
min_calibration_frames: int,
|
|
lora_rank: int,
|
|
loss_kind: str = ...,
|
|
epochs: int = ...,
|
|
lr: float = ...,
|
|
lambda_ent: float = ...,
|
|
) -> None: ...
|
|
def push_frame(self, frame: list[float]) -> None: ...
|
|
def is_ready(self) -> bool: ...
|
|
@property
|
|
def buffer_len(self) -> int: ...
|
|
def adapt(self) -> AdaptationResult: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
class CrossDomainEvaluator:
|
|
def __init__(self, n_joints: int) -> None: ...
|
|
def evaluate(
|
|
self,
|
|
predictions: list[tuple[list[float], list[float]]],
|
|
domain_labels: list[int],
|
|
) -> dict[str, float]: ...
|
|
def __repr__(self) -> str: ...
|
|
|
|
def mpjpe(pred: list[float], gt: list[float], n_joints: int) -> float: ...
|