Framework brief for the article. This document is meant to be handed to a collaborator (human or agent) as a self-contained description of what the project does, why, and where the code lives.
Instead of computing a neural network's linear transformation in the digital
domain (a trained weight matrix W_lin) and then transmitting the result over a
channel, we offload that computation into the wireless propagation itself: a
Reconfigurable Intelligent Surface (RIS) is configured so that the physical
channel is the linear layer. Computation happens "for free" during
propagation, over the air (OTA).
A standard learned / semantic communication (or split-inference) pipeline is:
image / input --[ heavy encoder NN ]--> s --[ linear layer W_lin ]--> y --[ heavy decoder NN ]--> logits
The middle stage W_lin is a plain matrix multiply. In a wireless deployment
the transmit vector s already has to pass through a physical channel H. Our
question:
Can the physical channel — shaped by a passive RIS whose phase shifts we control — replace the trained matrix
W_lin, so the linear part of the network is executed by nature rather than by a digital multiplier?
If yes, we push as much of the model as possible out of digital hardware and into the analog/wireless domain (lower energy, no explicit matmul, computation co-located with transmission).
The transmitter (N_t antennas) reaches the receiver (N_r antennas) through
a RIS with N_m passive elements:
Tx --H_1--> RIS (diag(phi), N_m elements) --H_2--> Rx
The end-to-end linear map realized over the air is:
H_1 ∈ C^{N_m × N_t}: Tx → RIS channelH_2 ∈ C^{N_r × N_m}: RIS → Rx channelphi ∈ C^{N_m},phi = exp(j·theta): unit-modulus RIS phase shifts (the only thing we control)n: AWGN at a target SNR
The effective matrix H_eq = H_2 diag(phi) H_1 is a function of the RIS
configuration phi. By choosing phi we sculpt H_eq to approximate the
target linear layer W_lin.
We solve for phi so the physical output matches the target the network wants:
- target
y_learned = W_lin(s)(what the trained linear layer would have output) - optimize
thetaby gradient descent (Adam) to maximize cosine similarity betweeny_risandy_learned(loss =1 - cos_sim), i.e. match direction. - implemented in
_optimize_phi_gd(...)(checkerboard file vendors a copy; original inteacher_experiments.py).
At inference the received vector y_ris (after optional norm matching) is fed to
the decoder in place of W_lin(s).
A subtle but central point: the linear layer we offload is strictly linear and bias-free, sitting between two ReLU stages:
encoder ends in ReLU -> a = ReLU(enc(x)) (a >= 0)
intermediate -> h = W_lin(a) (the layer under test)
decoder starts w/ ReLU -> logits = Lin(ReLU(h))
Because the encoder output a is already nonnegative, bypassing W_lin turns
the decoder's leading ReLU into a no-op, collapsing two nonlinear stages into a
single hidden layer. On depth-sensitive tasks a depth-1 network needs far more
width than a depth-2 one. Fixing the width in between makes the bypass model
underfit while the with-W_lin model succeeds. That accuracy gap is the
evidence that W_lin is genuinely necessary — and therefore worth realizing
physically via the RIS, rather than something a decoder could absorb for free.
This matters for the article because it justifies that the RIS is doing real computational work, not a redundant multiply.
Main script: checkboard/wlin_necessity_checkerboard.py
- Task: classify points in
[0,1]^2byNxNcheckerboard parity. This is the canonical depth-separation task: a 1-hidden-layer net needsO(N^2)units, a 2-hidden-layer net needs onlyO(N). - Model
CheckerboardNet:Linear(2, hidden)+ReLU→Linear(hidden, hidden, bias=False)(=W_lin) →ReLU + Linear(hidden, 2). AWGN added at the decoder input. - Three routing modes compared and plotted as decision boundaries:
- with
W_lin(depth-2): ~95–100% acc - bypass (depth-1): underfits toward chance / ~60%
- wireless RIS:
W_linreplaced byH_2 diag(phi) H_1,phifrom GD
- with
- Wireless sweeps built in: SNR, Ricean K-factor (
kappa), number of RIS elementsN_m, andphi_iters. - Channels come from
channels.generate_channel_tensors_by_type(sionna-free, geometric Ricean/Rayleigh).
Run examples:
# toy demo with the wireless RIS panel
python checkboard/wlin_necessity_checkerboard.py --mode demo --wireless true
# sweep RIS element count and SNR
python checkboard/wlin_necessity_checkerboard.py --wireless true \
--n_m_sweep 16,64,100,256 --snr_sweep 0,10,20,60Note: the current
wireless_forward/make_ris_channel_poolsin this file contain in-progress#TODOwiring (e.g.hidden = 2hardcode, routingxinstead of the encoder activationa). Treat the checkerboard wireless panel as the experimental surface being actively iterated.
Main script: teacher.py
MyTeacher:HeavyEncoder(CNN, image → complex transmit vectors ∈ C^{N_t}) →linear(2N_t → 2N_r, bias-free, the offloadableW_lin) →HeavyRxDecoder(complexy→ class logits). Trained on MNIST / CIFAR-10.ThinTeacher: the minimal counterpart of the checkerboard model on real images (ThinEncoder = Linear+ReLU, linear intermediate,ThinDecoder = ReLU+Linear). Used to reproduce the W_lin-necessity ablation on real data (phase = "train_thin").- Physical evaluation
test_demo.test_physical(...): run the trained encoder, computey_learned = linear(s), optimizephito reproduce it throughH_2 diag(phi) H_1, then decodey_ris. Compares physical vs. digital accuracy across SNR. - Learned channel surrogate (GAN):
ChannelGenerator/ChannelDiscriminator(+forward_gan,test_demo.test_physical_channel_gan) learn a differentiable model of the channel as an alternative to the analytic physical path. - Physical stacked-RIS simulator:
CODE_EXAMPLE/simnet.py(SimNet,RisLayer) models a multi-layer diffractive RIS;_build_teacher_sim_netwires it to the teacher for a physics-grounded "sim" target.
Entry points inside teacher.py are selected by the phase variable:
"train" (train MyTeacher.linear), "train_thin" (W_lin ablation),
"test" (physical-vs-synthetic accuracy vs SNR).
channels.generate_channel_tensors_by_type(...) returns (H_d_all, H_1_all, H_2_all) pools of channels to sample per batch/sample.
channel_type:geometric_ricean,geometric_rayleigh, orsynthetic_{ricean,rayleigh}.- Geometry: 28 GHz carrier, ULA steering vectors, path loss exponent, configurable Tx/RIS/Rx positions.
- K-factors control LoS vs. NLoS dominance for the direct (
H_d), Tx-RIS (H_1), and RIS-Rx (H_2) links. noise(y, snr_db): AWGN matched to signal power (real or complex).
The RIS can only mimic a full-rank W_lin if the cascaded channel is full rank.
- High K-factor (LoS-dominated) →
H_1,H_2become near rank-1 outer products →H_eq = H_2 diag(phi) H_1collapses to a rank-1 map → the received vector is locked to a single direction (the Rx steering vector) regardless ofsorphi. The decoder then outputs a constant class → uniform ("all blue") decision boundary. - Fix: rich scattering (Rayleigh, or suppressed LoS via very negative
K-factors) restores
rank(H_1) = rank(H_2) = N_r, giving theN_mRIS elements enough spatial degrees of freedom to reproduceW_lin.
This is a core practical message of the article: OTA linear computation via RIS requires enough channel rank / multipath richness; LoS-dominated links cannot carry a full-rank transformation.
| Path | Role |
|---|---|
checkboard/wlin_necessity_checkerboard.py |
Main toy experiment: W_lin-necessity + wireless RIS panel & sweeps |
teacher.py |
Main image experiment: MyTeacher, ThinTeacher, GAN channel, sim-net wiring |
test_demo.py |
Physical (test_physical) and GAN (test_physical_channel_gan) evaluation of the trained teacher |
teacher_train.py |
Training loops (train_teacher_linear, train_thin_teacher) |
teacher_experiments.py |
Original _optimize_phi_gd and related RIS experiments |
channels.py |
Channel generation (generate_channel_tensors_by_type, geometric Ricean/Rayleigh) |
CODE_EXAMPLE/simnet.py |
Physical multi-layer RIS diffraction simulator (SimNet, RisLayer) |
gan/gan.py |
GAN channel-surrogate utilities, noise, distribution plots |
students.py, distilallation/ |
Student models / knowledge-distillation side experiments |
rank.md |
Analysis of rank-1 collapse and the multipath fix |
| Symbol | Meaning |
|---|---|
s |
complex transmit vector (encoder output), length N_t |
W_lin / linear |
strictly-linear bias-free layer being offloaded |
y_learned |
target = W_lin(s) |
H_1, H_2, H_d |
Tx→RIS, RIS→Rx, direct channels |
phi = exp(j·theta) |
unit-modulus RIS phase shifts (the control variable) |
y_ris |
received vector after the RIS channel + noise |
N_t, N_r, N_m |
# Tx antennas, # Rx antennas, # RIS elements |
K-factor (kappa) |
Ricean LoS/NLoS ratio (controls channel rank) |
- Checkerboard
wireless_forwardis mid-refactor (#TODOs):hiddenhardcoded to 2 inmake_ris_channel_pools, and the RIS path currently routes the raw inputxrather than the encoder activationa = ReLU(enc(x)). - Whether increasing
N_mreliably improves accuracy (noted#TODOinteacher.py) — tied to the rank discussion above. - Norm/gain matching between
y_risandy_learned(cosine loss vs. Frobenius) is still being tuned.