Fixed-point profile-HMM Forward over batched reads
/app/cpu/main.cpp is a multicore CPU program (C++17, OpenMP). It is built as
/app/bin/cpu_baseline with g++ -O3 -march=native -fopenmp -std=c++17 and run as
cpu_baseline INPUT_FILE
It reads one 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 CPU source is the specification: when this text and the code disagree, the code wins.
How you are scored
- 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. - This sandbox has no GPU.
nvccworks here for compiling. To run on the GPU, use/app/bin/gpu_run [--repeat N] [--quiet] SOURCE.cu INPUT_FILE...: it compiles the file with the flags above on a remote H100 worker, runs it on each input, and prints stdout, exit code and wall-clock time. Grading also runs your code on an H100 worker, one job per GPU at a time. Inputs are generated with a new random seed at grading time, so they cannot be known in advance. - Correctness: every hidden input (small edge cases plus the timing input) must pass. Your output must be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout gives reward 0.
- 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. Your port and our GPU reference are each run on it
once to warm up and then 5 times, interleaved; the time is the wall clock of the whole process
(including CUDA initialisation, input parsing and output). When correct,
reward = min(2, t_reference / t_yours)using the medians. /app/inputs/holds a few public inputs./app/bin/run_public.shcompiles your port with the flags above and compares it against the CPU baseline on each of them.