Robust sparse Schur bundle adjustment
/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 deterministic rig of cameras observes synthetic 3D points. Each point has a variable length track through neighboring cameras. Measurements contain pixel noise and planted outliers. The program starts from perturbed poses and points, performs two damped robust bundle-adjustment steps, eliminates every 3D point through its 3×3 normal block, explicitly assembles sparse 9×9 camera-pair Schur blocks, solves the coupled camera system by PCG, and back-substitutes point updates. It accepts a step only when its robust objective falls. The final diagnostics are the true RMS reprojection error and a digest of rounded camera poses.
Input format
One line: C P I seed. 1 <= C <= 2000 cameras, 1 <= P <= 800000 points, and 1 <= I <= 16 LM attempts. For the full case, each point has 8–12 observations; a smaller camera rig clips track length to C. The input file is only parameters; cameras, points, tracks, noise, and outliers are generated inside the program from seed.
Output format
One line has two numeric tokens, RMS robust_objective, followed by exact labeled tokens digest=<unsigned integer> accepted=<integer> observations=<integer>. Continuous values use FP64 and are compared with relative tolerance 1e-7. The labeled values must match exactly. /app/cpu/main.cpp defines the projection, robust weight, damping, Schur reduction order, PCG iteration count, and rounding.
Hidden inputs
Correctness cases include a single camera, one point, short tracks, and small irregular rigs. The timing case has 2000 cameras and 500000 points at scale 1.0, approximately five million observations, and 16 LM attempts. Point count continues to grow above scale 1.0 until the 800000-point memory limit.
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-07 and atol = 1e-09; 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: At scale 1.0 the input has 2000 cameras, 500000 3D points, and about 5 million noisy observations (8 to 12 per point), with 16 robust LM trust-region attempts and a coupled sparse camera solve in each attempt. Scale multiplies the point count without a cap at 1.0.
/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.