Phase 0 · pilot · Colab Tesla T4 · done 2026-10-04

Scanning every window of a market time series on a GPU

In the same minute the GPU ran 53× more trials, so its interval was 6.7× narrower: precision is bought with re-runs, which reframed the project around evaluation under a time budget.

00.10.20.30.4estimated hit rate, 95% intervaltrials run10 sCPU18GPU1,03230 sCPU60GPU3,19560 sCPU119GPU6,31200.10.20.30.4estimated hit rate, 95% intervaltrials run10 sCPU18GPU1,03230 sCPU60GPU3,19560 sCPU119GPU6,312
Each side re-ran the full detector on fresh injected copies of the 1-minute quarter until the budget ran out. The CPU side used two cores, so 53× holds for this setup only.

Numba CPU baselineCUDA kernels via CuPyBTCUSDT 2024Write-up (opens in a new tab)Notebook and code (opens in a new tab)Raw results (opens in a new tab)

01How a window is scored

Every (start, length) window of BTCUSDT bars — a 2024 quarter at 1 minute, one week at 1 second — is scored for how unusual its price range and volume are for its length. The GPU runs one thread per window; the fair CPU baseline is an optimized O(N·K) scan.

Fig. 1 · From a window to a reported episode

  1. 1

    Take every window

    Each (start, length) pair, 15 lengths from 2 to 256 bars.

  2. 2

    Measure two features

    Price range (max − min) / min and traded volume.

  3. 3

    Rank within its length

    Only against windows of the same length; keep the less extreme rank.

  4. 4

    Score its rarity

    S = −log10(rank / count). S = 3 means top 0.1% on both features.

  5. 5

    Report the top 20

    Local peaks with S ≥ 2, merged into episodes when close.

02Correct first: a gate that catches broken kernels

  • GPU features (two thread layouts) and both CPU scans matchpass
  • GPU rarity ranks and candidate flags, exactpass
  • Top 20 identical on the CPU and all three GPU pathspass
  • Broken kernel: boundary off by onecaught
  • Broken kernel: wrong window lengthcaught

A gate that passes everything proves little. Catching two deliberately broken kernels shows it can tell a correct kernel from a subtly wrong one, and it ran before every timing.

03Does the map find anything real?

The fake SEC post draws one cone at 1-minute resolution and three at 1-second. Against news events fixed in advance (every CPI and FOMC release) the hits are 1 of 5 (p = 0.086): the map finds large moves, not their cause.

Fig. 2 · 1-minute bars, 2024 Q1

Price, USDT (high–low per bar)46,00048,000vol.2832128256window (min)19:0020:0021:0022:0023:0000:00fake SEC post, 21:11 UTCRarity, for its lengthalltop 10%1%0.1%0.01%0.001%Price, USDT46k48kvol.2832128256len (min)19:0021:0023:00fake SEC post, 21:11 UTCRarity: top share of windows of that lengthall10%1%0.1%0.01%0.001%
One cone opens at 21:11; ranks over the whole quarter.

Fig. 3 · 1-second bars, one week

Price, USDT (high–low per bar)46,00048,000vol.2832128256window (s)20:5521:0021:0521:1021:1521:2021:2521:30fake SEC post, 21:11 UTCRarity, for its lengthalltop 10%1%0.1%0.01%0.001%Price, USDT46k48kvol.2832128256len (s)20:5521:0521:1521:25fake SEC post, 21:11 UTCRarity: top share of windows of that lengthall10%1%0.1%0.01%0.001%
Three cones: the jump at 21:12, the pullback at 21:17, the drop at 21:25.

Fig. 4 · Injected pump-and-dump events that reach the top 20

L = 6 min00.250.50.7512481632L = 30 min2481632L = 120 min2481632hit ratestrength q (× typical range, log)top-20 hit rate, 20 trials per pointL = 6 min00.250.50.7512481632L = 30 min00.250.50.7512481632L = 120 min00.250.50.7512481632hit ratestrength q (× typical range, log)top-20 hit rate, 20 trials per point
20 trials per point. Weak events never make the top 20 because the quarter has larger real shocks.Phase 0, section 2 · injection_summary.csv (opens in a new tab)

04Where the time goes: not the kernel

The kernel is 59× faster than the optimized CPU, but end to end only 5.4×: sending features for nine million windows back costs more than computing them. Keeping ranking and selection on the GPU removes that cost.

Fig. 5 · One full scan of 604,800 bars × 15 lengths (median, log scale)

3 ms10 ms30 ms100 ms300 ms1 sCPU direct scan1 thread726.5 msCPU direct scan2 threads975 msCPU optimized1 thread, the baseline200.5 msGPU end to endupload, kernel, download37.4 msGPU kernel only3.4 ms3 ms10 ms30 ms100 ms300 ms1 sCPU direct scan 1 thread726.5 msCPU direct scan 2 threads975 msCPU optimized 1 thread, the baseline200.5 msGPU end to end upload, kernel, download37.4 msGPU kernel only3.4 ms
A cost model predicted the GPU/CPU crossover at a mean window length of 4.0; it was 2.85.Phase 0, section 3 (opens in a new tab)

Fig. 6 · End-to-end time per pipeline (log scale)

30 ms100 ms300 ms1 s3 sCPU onlydirect scan, 2 threads3,480 ms(1) GPU featuresCPU ranks and selects2,547 ms(2) GPU also ranksCPU selects candidates82.7 ms(3) GPU does everythingreturns only candidates38.5 ms30 ms100 ms300 ms1 s3 sCPU only direct scan, 2 threads3,480 ms(1) GPU features CPU ranks and selects2,547 ms(2) GPU also ranks CPU selects candidates82.7 ms(3) GPU does everything returns only candidates38.5 ms
All four return the same top 20. Returning only candidates is 66× faster than returning features; the per-length sort is then 72% of what remains. On the same 40 trials the GPU path took 10.6 ms per trial against 493 ms on the optimized CPU, with identical decisions.Phase 0, sections 4–5 · e2e_breakdown.csv (opens in a new tab)

05Seven hypotheses, written before the run

Every one was fixed with a numerical criterion before measuring, and all held.

HypothesisCriterion → resultVerdict
H1A cost model predicts the GPU/CPU crossover4.00 criterion, result 2.85supported
H2Download dominates when all features return82% of GPU timesupported
H3Candidates-only output beats features output≥ 2× criterion, result 66×supported
H4Mixed window lengths in a warp slow the kernel4.4× criterion, result 3.6×supported
H5The map reads an event's length⅓–1 × L criterion, result 0.34–0.58supported
H6A minimum detectable strength exists50% at 8–32×supported
H7Same budget: more trials, interval narrows as 1/√n7.3× criterion, result 6.7×supported

06What this changed

  1. After moving to the GPU, sorting and data movement dominate, not the kernel.Optimise the whole pipeline and what is sent back.
  2. The optimized CPU is 3.6× the direct scan, and still ranks single-threaded.Phase 1 rebuilds the CPU baseline in C++ with parallel sorting.
  3. Two broken kernels were caught.The correctness gate runs before every timing.
  4. Precision is bounded by re-runs per unit time.The project's question: evaluation under a time budget.

Corrections (2026-10-07)

  • The 3,480 ms CPU-only pipeline uses the direct scan; an end-to-end comparison with the optimized CPU was not measured.
  • 53× is a ratio for this setup: two cores and a full re-run per trial, which Phase 1 shows is not the CPU's floor.

One Colab session; synthetic events without market reaction; nothing judges whether any trading was manipulative. Details: docs/phase0.md (opens in a new tab).