Integer gradient boosting with histogram split finding
/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
Training of a gradient-boosted regression-tree ensemble with histogram split finding and level-wise (depth-wise) growth, entirely in integer arithmetic. The CPU source is the exact specification; in short:
- Data.
Nrows withFuint8 feature bins (0..255), a fixed-point targetY(1/256 units) and a weightWin1..4, all generated fromSEEDbygen_row(4 latent factors per row, correlated features, a nonlinear target with noise and 2% outliers). PredictionsPstart at 0. - Per tree
t(Ttrees):- gradients for every row:
e = P - Y,q = e >> 3(arithmetic),g = W * clamp(q, -63, 63),h = W * (|q| <= 63 ? 4 : 1); - row bagging: only rows with
in_bag(SEED, t, r)(about 75%) contribute to histograms and node totals; - level-wise growth to depth
D(nodes numbered heap-style: root 1, children2n,2n+1). For every open node at levelland every feature allowed at(t, l)byfeat_allowed(about 75%), the histogram of(sum g, sum h)per bin over the node's bagged rows is scanned: the candidate "bin <= bgoes left" forb = 0..254is valid if both sides have hessian sum>= MINW, and, for monotone features, if the implied leaf values are ordered (f % 16 == 3:GL*(HR+LAMBDA) >= GR*(HL+LAMBDA);f % 16 == 11:<=). Its score isS(GL,HL) + S(GR,HR)withS(G,H) = floor(G*G / (H + LAMBDA))(unsigned 64-bit). The best candidate (largest score; ties to the lowest feature, then the lowest bin) splits the node if its score is> S(G,H) + GAMMA; otherwise the node becomes a leaf. Nodes at depthDare leaves. - leaf value
v = -(G * ETA) / (H + LAMBDA)(64-bit, C division truncating toward zero); - every row (bagged or not) is routed through the tree (
bin > bgoes right) andP += v.
- gradients for every row:
Input format
One line: N F T D LAMBDA MINW GAMMA ETA SEED (integers, SEED unsigned 64-bit).
Output format
tree <t> bag=<bagged rows> splits=<internal nodes> leaves=<leaves> loss=<L_t> hash=<H_t> (t = 0..T-1)
final N=<N> F=<F> T=<T> D=<D> loss=<L> pred_hash=<PH>
feature_splits <c_0> <c_1> ... <c_{F-1}>
row <r> y=<Y[r]> pred=<P[r]> (r = 0, N/3, N-1, distinct, if they exist)
L_t/L:sum_r W[r] * |P[r] - Y[r]|after treet/ at the end (all rows).H_t: sum over the tree's nodes, modulo 2^64, ofmix64(key)withkey = (t << 32) | (node << 16) | (feature << 8) | binfor internal nodes andkey = 2^63 | (t << 43) | (node << 32) | (uint32)vfor leaves (mix64= SplitMix64 finaliser).PH = sum_r mix64((r << 32) | (uint32)P[r])modulo 2^64;c_f= number of splits on featuref.
Hidden inputs
0 <= N <= 4,194,304,1 <= F <= 64,0 <= T <= 128,1 <= D <= 10,1 <= LAMBDA <= 10^6,1 <= MINW <= 10^6,0 <= GAMMA <= 2^50,1 <= ETA <= 64, any 64-bitSEED.- Correctness inputs include
N = 0, a single row, a single feature with depth 10,T = 0,MINWorGAMMAso large that no split is ever made, depth 10 with many small nodes,LAMBDA = 1withETA = 64, and random small configurations (up to 100,000 rows). - The timing input has about 4.1 million rows,
F = 64,T = 100trees,D = 8,LAMBDA = 100,MINWin 3000..5000,GAMMA = 0andETA = 8; trees have roughly 50 to 200 internal nodes (of at most 255), so the deeper levels have tens of open nodes, each with its own 64 x 256 histogram. - All per-bin and per-node sums fit in 32-bit signed integers (
|g| <= 252,h <= 16),G*Gfits in 63 bits and the cross products of the monotone test fit in 64 bits.
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. - Grading runs on one H100 in a fresh container without network. 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: One input with about 4.1 million rows x 64 features, 100 trees of depth 8 (about 75% of the rows bagged per tree, 75% of the features allowed per level), LAMBDA = 100, MINW in 3000..5000, GAMMA = 0, ETA = 8. 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.