Event-driven spiking network with delayed plastic synapses
/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
An event-driven simulation of a spiking network of N integer leaky integrate-and-fire neurons
with adaptive thresholds, refractory periods, delayed synapses and a simple plasticity rule. The
CPU source is the exact specification; in short (mix64 = SplitMix64 finaliser, all arithmetic
on integers):
- Neurons. Neuron
iis inhibitory ifi % 5 == 4and excitatory otherwise. Each neuron has a membrane valuev, a threshold offsettheta, a refractory counter, the time of its last spike and a trace; all start at zero (last spike at-10^6). - Synapses (CSR by source). Neuron
ihas fan-outf_i = S/2 + (h_i mod S)(0 whenS = 0) withh_i = mix64(SEED ^ (0x9E3779B97F4A7C15 * (i+1))), multiplied by 4 for hubs ((h_i >> 32) mod 100 == 0, about 1% of the neurons). Synapses are numbered contiguously in neuron order; synapsesof neuroniusesh = mix64(SEED ^ (0xD1B54A32D192ED03 * (s+1)) ^ 0x5851F42D4C957F2D): if(h & 1023) < 717it is local, with target(i + ((h >> 10) mod 8193) - 4096) mod Nand delay1 + ((h >> 24) mod min(D, 4)); otherwise its target is(h >> 10) mod Nand its delay1 + ((h >> 40) mod D). The initial weight is8 + ((h >> 50) mod 40)for an excitatory source and-16 - ((h >> 50) mod 64)for an inhibitory one. - Step
t(t = 0 .. T-1), phase 1 for every neuron: takeinfrom the input ring slott mod Dand clear it. If the refractory counter is positive, decrement it and setv = -100; otherwisev = clamp(v - (v >> 4) + in + ext, -2000, 4000)whereext = AEXTif the low 16 bits ofmix64(SEED ^ (0xA0761D6478BD642F * (t+1)) ^ (0xE7037ED1A0B428DB * (i+1)))are belowPEXT, else 0. Thentheta -= theta >> 6. If the counter is zero andv >= 1000 + thetathe neuron spikes:v = -100, the counter becomes 3 (excitatory) or 1 (inhibitory),thetagrows by 200 or 50, the spike time and the neuron's spike count are updated. Finally the trace is 2 if the neuron spiked within the last 4 steps (t - last < 4), else 1 ifv > 500, else 0. - Phase 2: every neuron that spiked at step
tdelivers along all its synapses: slot(t + delay) mod Dof the target receivesweight * 1(excitatory source) orweight * 4(inhibitory source). After delivering, an excitatory synapse is updated from its target's trace: weightmax(1, w - 2)if the trace is 2,min(63, w + 1)if it is 1. Phase 1 of a step completes before its phase 2, so the result does not depend on the order of deliveries.
Input format
One line: N S D T PEXT AEXT SEED.
Output format
snn N=<N> excitatory=<number of excitatory neurons> synapses=<total synapses> D=<D> T=<T>
step <t> spikes=<spikes at step t> (t = floor(T*k/20) for k = 0..19 and t = T-1, distinct, in order)
spikes exc=<total excitatory spikes> inh=<total inhibitory spikes> events=<synaptic deliveries>
rate_permille exc=<exc spikes * 1000 / (exc neurons * T)> inh=<likewise> (0 when undefined)
count_hash <sum_i mix64((i << 24) | count_i)>
step_hash <sum_t mix64((t << 32) | spikes_t)>
state_hash <sum_i mix64((i << 32) ^ (uint32)v_i ^ ((uint32)theta_i << 40))>
weight_sum <sum of final weights> weight_hash <sum_s mix64((s << 8) | (uint8)w_s)>
All hashes are sums modulo 2^64.
Hidden inputs
1 <= N <= 2,000,000,0 <= S <= 600,1 <= D <= 32,0 <= T <= 100,000,0 <= PEXT <= 65536,0 <= AEXT <= 5000, any 64-bitSEED.- Correctness inputs include a single neuron without synapses, a single neuron with self-synapses,
five neurons with dense multi-edges and
D = 32,T = 0, no external drive (a silent network), saturating drive,D = 1,N = 2,000,000with a very sparse network, the largest fan-out withD = 32, a short run of the timing shape, and random small configurations. - The timing input has about 500,000 neurons,
S = 300(about 1.5e8 synapses),D = 16,PEXT = 6000,AEXT = 500and about 4,500 steps; after a short transient under 1% of the neurons spike in a step, so each step delivers about a million synaptic events.
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 500,000 neurons, S = 300 (about 1.5e8 synapses), D = 16, PEXT = 6000, AEXT = 500 and about 4500 steps. 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.