Open-window peptide-spectrum matching with a sliced fragment index
/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
An end-to-end open-window proteomics database search on generated data. All masses are integers in milli-Dalton (mDa), all scores are integers; the CPU source is the exact specification.
- Proteome.
NPROTtarget proteins in families of homologues (family starts, lengths 120..619 and per-residue mutations at 2.5 % come from SplitMix64 hashes of the seed; residue 0 is always Met). Decoy proteinNPROT + pis targetpreversed. - Digest. Invented cleavage rule: cut after K/R unless the next residue is P, and after D when the next residue is G. Up to 2 missed cleavages, peptide length 7..40. Every peptide yields an unmodified form, a Met-oxidised form (first M) if it contains M, and an N-acetylated form if it starts the protein.
- Deduplication. Peptide identity is the 64-bit key `mass << 40 | (sequence/modification hash
24)`. Unique peptides are numbered in ascending key order (so peptide ids are sorted by mass); the representative is the first form in generation order (protein, start, missed cleavages, form). A peptide is a target if any target protein produces it; its distinct target proteins are kept for protein inference.
- Fragment index. Singly charged b and y ions with 200000 <= m/z < 2000000 are binned at 100 mDa; each peptide's distinct bins go into an inverted index (posting list per bin, peptide ids ascending).
- Spectra.
NSPECspectra are generated from hashed source peptides (15 % pure noise, 30 % with a precursor mass shift from a fixed table applied at one residue), with 62 % fragment survival, m/z jitter and 40..120 noise peaks. Preprocessing merges equal bins (max intensity) and keeps the top 50 bins by (intensity desc, bin asc) with weight50 - rank. - Search. For each spectrum the candidate window is all peptides with mass in
[prec - TOL, prec + TOL](a contiguous id range). Each kept peak bin's posting list is sliced to that id range and every posting is a vote; peptides with >= 3 votes are rescored:score = I * (1 + nb) * (1 + ny) + 64 * run^2(I= summed weights of matched b and y ions,nb/nymatched counts,run= longest consecutive matched b or y series). The top 5 PSMs are kept by (score desc, peptide id asc). - q-values. Top-1 PSMs of spectra with candidates are sorted by (score desc, spectrum asc);
FDR =
floor(1e6 * decoys / max(targets, 1)), q-value = suffix minimum. Target PSMs at q <= 0.1 %, 1 %, 5 % are counted. - Mass shifts. For accepted target PSMs (q <= 1 %) the precursor-minus-peptide mass is binned to the nearest Dalton; the 8 most frequent bins are reported.
- Protein groups. Greedy parsimony over the accepted peptides: repeatedly take the protein with the most uncovered peptides (ties: lowest id), absorb as members the not-yet-assigned proteins whose accepted-peptide set is a subset of the lead's, mark the lead's peptides covered.
Input format
One line: NPROT NSPEC TOL SEED (TOL in mDa, SEED a 63-bit integer).
Output format
PEPTIDES forms=.. unique=.. target=.. index=.. bins=.. maxwin=..
SEARCH spectra=.. votes=.. candidates=.. with_cand=.. tophash=<16 hex>
SPEC s prec=.. peaks=.. cand=.. top=pid:score second=pid:score (first 4 spectra)
FDR psms=.. acc0.1=.. acc1=.. acc5=.. decoys1=..
SHIFTS distinct=.. bin:count ... (up to 8)
GROUP g lead=.. peptides=.. new=.. members=.. (first 10 groups)
PROTEINS accepted_peptides=.. with_peptides=.. groups=.. members=.. grouphash=<16 hex>
votes is the total number of posting entries visited, candidates the total number of
(spectrum, peptide) pairs with >= 3 votes, maxwin the largest number of peptides inside any
2*TOL mass interval starting at a peptide, tophash the wrapping sum over all kept top-5 entries
as defined in the source. Output must match exactly.
Hidden inputs
Correctness inputs: NPROT in [0, 400] (including 0 and 1), NSPEC in [0, 300] (including 0),
TOL from 10 to 500000 mDa. The timing input has NPROT = 20000 (about 4.8M peptide forms,
3.7M unique peptides, 1e8 index postings), NSPEC about 240000 and TOL in [250000, 350000]
(an open search: each window holds roughly 600000 peptides and each spectrum visits about 80000
postings). Memory needed on the GPU stays below 4 GB.
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 source generation only. Write /app/gpu/main.cu; compilation,
execution and verification are performed later in a separate verifier environment.
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. - GPU verification uses the backend selected for this run: an H100 attached to the separate verifier, or a remote H100 worker. Hidden inputs use a fresh random seed.
- 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.
- GPU execution: a separate, untimed CUPTI check must observe completed GPU kernel activity on the hidden timing input. A CPU-only submission receives reward 0 even if its output is correct.
- Speed: The timing input searches about 240000 generated spectra against 20000 target proteins plus decoys (about 3.7M unique peptides, 1e8 index postings) with a precursor window of +-250..350 Da; the search visits about 2e10 postings. 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 public input examples for understanding the input format.