Batched ADMM total-variation restoration of multichannel recordings
/app/cpu/main.cpp is the source of a multicore CPU program (C++17, OpenMP).
The program takes one input-file path (PROGRAM INPUT_FILE) and writes its result to stdout.
What the program computes
A batch restoration job for S multichannel sensor recordings (C channels, T samples
each). Everything is generated from the seed and the recording index with the
SplitMix64-based hashes hh/u01 of the CPU source (restore):
- Data generation. A piecewise-constant ground truth
x*_{t,c}(private jumps per channel and common jumps across all channels), time-varying channel gainsg_{t,c}, a fixed crosstalk/lag matrixA1(C x C) and two vectorsu, v. The observation isy_t = A0_t x*_t + A1 x*_{t-1} + noise_twithA0_t = diag(g_t) + (0.3/C) u v^T(x*_{-1} = 0), noise uniform in[-0.05, 0.05], channel weightsw_cin[0.5, 1.5). - Normal equations.
K = A^T A + rho D^T Dwithrho = 0.8andDthe first difference in time per channel.Kis block tridiagonal withC x CblocksK_tt = A0_t^T A0_t + [t < T-1] A1^T A1 + rho deg_t IandK_{t,t-1} = A0_t^T A1 - rho I. The CPU computes its block Cholesky factor (B_t = K_{t,t-1} L_{t-1}^{-T},L_t = chol(K_tt - B_t B_t^T)) once per recording. - ADMM,
itersiterations fromx = z = u = 0, formin 1/2 ||A x - y||^2 + lambda sum_c w_c sum_t |x_{t+1,c} - x_{t,c}|,lambda = 0.15:x = K^{-1} (A^T y + rho D^T (z - u))(block forward / back substitution),z = soft(D x + u, lambda w_c / rho),u = u + D x - z. - Report per recording: the objective
Fat the end, the primal residualrp = ||D x - z||and the dual residualsd = rho ||D^T (z - z_prev)||of the last iteration (both 0 wheniters = 0),rmseagainst the ground truth, the total variationtv = sum |x_{t+1,c} - x_{t,c}|and the energyx2 = sum x^2; also the objectiveFhalfafter iterationiters/2(integer division; atx = 0wheniters < 2).
All arithmetic is IEEE double precision.
Input format
One line: S C T iters SEED with 1 <= S <= 4096, 1 <= C <= 16, 1 <= T <= 8192,
0 <= iters <= 5000, S * T * C * C <= 1.2*10^8; SEED is an unsigned 64-bit integer.
Output format
For every recording r with r % max(1, S/24) == 0:
rec r F <F> rp <rp> sd <sd> rmse <rmse> tv <tv> x2 <x2>
then total S <S> C <C> T <T> iters <iters> F <sum F> Fhalf <sum Fhalf> rmse <sum rmse> tv <sum tv> x2 <sum x2> rp <sum rp> sd <sum sd> (sums over all recordings, on one line).
Reals are printed with %.12e and compared with a relative tolerance of 1e-8 (absolute
1e-11): any summation order or factorisation that is exact in double precision passes,
reduced precision does not.
Hidden inputs
Correctness inputs (13 files) include T = 1 and T = 2, C = 1 and C = 16,
iters = 0 and iters = 1, seeds 0 and 2^64-1, and random sizes with
S <= 50, T <= 2000. The timing input has T = 1024, iters = 400,
C chosen from {10, 12, 14, 16} and S about 114000 / C^2 (about 1150 recordings
for C = 10, 450 for C = 16).
Your task
Port this program to CUDA in /app/gpu/main.cu: same command line (PROGRAM INPUT_FILE),
same output on stdout. Then make it as fast as you can on the GPU while keeping the output correct.
The main computation must execute on the GPU. Renaming CPU code to .cu, running a
CPU fallback, or launching a dummy kernel while computing the answer on the CPU does not satisfy this task.
The CPU source is the specification: when this text and the code disagree, the code wins.
This sandbox is for writing the source only: it has g++ and the CPU program, but no CUDA
compiler and no GPU. Compilation, execution and verification happen later on an H100 in a
separate verifier, and a port that does not compile is rejected, so check your logic against
the CPU program before you finish (for example by emulating your kernels on the host).
How your port is verified
- Only
/app/gpu/main.cuis collected. It is compiled withnvcc -O3 -arch=sm_90 -std=c++17 -o port /app/gpu/main.cu; no extra libraries are linked. The CUDA runtime and the header-only libraries that ship with the CUDA toolkit (CUB, Thrust, libcu++) are allowed. - Your source must not contain any of:
system(,popen(,fork(,exec*,dlopen(,getenv(,#include <filesystem>,/tests/,/proc/. The program may read only the input file it is given. - Verification runs on one H100 in a fresh container without network. Hidden inputs are generated with a fresh random seed at verification time.
- Correctness: every hidden input (small edge cases plus a large timing input) must pass.
Your output must have the same tokens as the CPU program's output. Numeric tokens may differ by at most
atol + rtol*|expected|with rtol = 1e-08 and atol = 1e-11; every other token must be identical. Any mismatch, crash or timeout is rejected. - GPU execution is checked: a port that computes its answer on the CPU is rejected even when its output is correct.
- Speed: The timing input restores several hundred recordings (about 114000 / C^2 for C in {10, 12, 14, 16}) of 1024 samples each with 400 ADMM iterations.
/app/inputs/timing_example.inhas the shape and size of the hidden timing input. Your port is timed against a reference GPU port on it; the faster your port, the higher its score. /app/inputs/holds public input examples for understanding the input format.