Fixed-point profile-HMM Forward over batched reads
/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
The program reads B, n, L, seed. All log-probabilities are integer fixed-point
values round(log_prob * SCALE) with SCALE = 4096. The log-sum-exp of two fixed-point values
is exact:
lse(a,b) = max(a,b) + LSE_TABLE[|a-b|] (0 if |a-b| >= 16*SCALE)
LSE_TABLE[d] = round(SCALE * log(1 + exp(-d/SCALE)))
LSE_TABLE is built once on the host (the only floating point in the program); the lattice is
pure integer so the output is bit-exact.
Profile. From seed a plan7-style profile of L match columns is built (mix64 is the
SplitMix64 finaliser in the source). Each column j has integer transition scores
tMM,tIM,tDM,tMI,tII,tMD,tDD in [-3*SCALE, -1] and emission scores eM[j][s], eI[j][s]
in [-2*SCALE, -1] for symbols s in {0,1,2,3}; end scores tME,tIE,tDE are in [-SCALE,-1].
Read. Read d has n symbols x_i = (mix64(base + i*0x9E37..) >> 15) & 3 with
base = mix64(seed ^ d*0xD1B54A32D192ED03).
Forward lattice. With match/insert/delete states and lse3(a,b,c)=lse(lse(a,b),c):
M[i][j] = eM[j][x_i] + lse3(M[i-1][j-1]+tMM[j], I[i-1][j-1]+tIM[j], D[i-1][j-1]+tDM[j])
I[i][j] = eI[j][x_i] + lse2(M[i-1][j]+tMI[j], I[i-1][j]+tII[j])
D[i][j] = lse2(M[i][j-1]+tMD[j], D[i][j-1]+tDD[j]) (within-row delete chain)
with begin M[0][0]=0, all other row-0 M/I and column-0 cells -inf, and the row-0 delete
chain seeded from the begin. The per-read log-likelihood is
F = lse3(M[n][L]+tME, I[n][L]+tIE, D[n][L]+tDE) (an integer). Over all reads the program
reports:
SUMF= sum ofF(mod 2^64, printed unsigned),HASH= sum ofmix64(F ^ d*0xC2B2AE3D27D4EB4F)(mod 2^64),MINF,MAXF= the smallest and largestFover the reads (0and0ifB=0).
Input format
B n L seed
Output format
One line:
B n L SUMF HASH MINF MAXF
Hidden inputs
0 <= B <= 400000, 0 <= n <= 4096, 1 <= L <= 511, seed any 64-bit value. Correctness
inputs (13 files) include B=0, a single read, n=0 (all-delete path), n=1, L=1, L=511,
a long read (n=4096), and random mixes. The timing input uses B = 400000, n = 200,
L = 200. The output is integer and compared exactly.
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 be identical to the CPU program's output (trailing whitespace ignored). 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 scores B = 400000 reads of length n = 200 against a profile of L = 200 match columns, each a full M/I/D fixed-point Forward lattice.
/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.