SPB Git

spb/wp40_uqo

Public MIT
5.9 KB · 47 lines latex
1\begin{appendices}2\section{Kernel pseudocode}3\label{app:kernels}4\begin{lstlisting}[basicstyle=\ttfamily\scriptsize]5df two_sum(float a, float b): s = a + b; bb = s - a; e = (a - (s - bb)) + (b - bb); return (s, e)6df df_add_f(df a, float v): (h, l) = two_sum(a.hi, v); l += a.lo; h2 = h + l; return (h2, l - (h2 - h))7kernel realized_fused(x, chunks, out):   // one threadgroup (256 threads) per (segment, chunk)8  c = chunks[gid]; s2 = adj = neg = pos = s4 = (0, 0)9  for i in c.begin + lid .. c.end step 256:10    v = x[i]; q = v*v; s2 += q; s4 += q*q; if v < 0: neg += q elif v > 0: pos += q11    if i > c.begin: adj += |v| * |x[i-1]|12  tree-reduce each df over the threadgroup in fixed order; thread 0 writes 5 float213host: for each chunk c of segment s: acc[s] += (double)hi + (double)lo (fixed order);14      adj[s] += |x[c.begin]| * |x[c.begin-1]| in FP64 when c.begin > segment begin15kernel garch_nll(r, seg, params[8], var0, jobs, out, model):   // one thread per (segment, parameter vector)16  (mu, omega, alpha, gamma, beta, nu, kconst, Eabs) = params[job]; s2 = var0[seg]17  validity checks -> +inf; nll = (0, 0); e_prev = r[b] - mu18  for i in 0..n-1: if i > 0: s2 = recursion(model); if !(s2 > 0): return +inf19    e = r[b+i] - mu; ll = kconst - 0.5 log s2 - (student ? 0.5 (nu+1) log(1 + e^2/((nu-2) s2)) : 0.5 e^2/s2)20    nll += -ll21  out[job] = nll.hi + nll.lo   // host adds n log(sd) for the per-series scaling22\end{lstlisting}2324\section{Optimiser details}25GARCH-family QML: parameters are transformed to an unconstrained space ($\omega = e^{u}$; persistence $p = \sigma(u_p)(1-10^{-9})$ and share $s = \sigma(u_s)$ so that $\alpha = sp$, $\beta = (1-s)p$ for GARCH; for GJR $\alpha+\gamma = e^{u_g}$ and $\beta = p - \alpha - \gamma/2 \ge 0$; for EGARCH $\omega$ free and $\beta = \tanh(u)$; $\nu = 2.05 + 497.95\,\sigma(u_\nu)$). BFGS with Armijo backtracking (factor 0.5, up to 60 halvings), central-difference gradients with step $10^{-5}\max(1,|u|)$, convergence when $\|g\| < 10^{-5}$, or when the relative change of the negative log-likelihood is below $10^{-8}$ (or the step below $10^{-9}$) with $\|g\| < 10^{-2}$ in the transformed space; at most 500 iterations; up to three starting variants (persistence 0.95, 0.80, 0.985; opposite EGARCH $\gamma$ sign). Covariance from the numerical Hessian (central differences, step $10^{-4}\max(1,|\theta|)$) and the OPG of per-observation scores. Returns are scaled to unit variance before optimisation and the estimates un-scaled (EGARCH: $\omega \to \omega + (1-\beta)\log s^{-2}$).2627\section{Finite-sample conventions}28Regular session = 09:30 to 16:00 ET inclusive of the 16:00 closing print (391 one-minute bars; 211 on 13:00 early closes); extended session 04:00--19:59 ET (17:00 on early closes). Intraday returns are close-to-close within the session ($M = $ bars $-1$). BPV factor $M/(M-1)$ on by default; TriPV factor $M/(M-2)$; RQ $= (M/3)\sum r^4$. HAR windows of 1, 5 and 22 trading days; targets averaged over $h$ sessions; HAC lags $\max(h-1, \lfloor 4(n/100)^{2/9}\rfloor)$. HARQ regressor $(\sqrt{\RQ_t} - \sqrt{\overline{\RQ}})\RV_t$ with $\overline{\RQ}$ over the estimation sample. GARCH $\sigma_0^2$ = sample variance of $\varepsilon$. Stationary bootstrap mean block $n^{1/3}$ unless stated.2930\section{Benchmark configuration}31Laptop: Apple M5 Max (6P+12E cores reported by \texttt{hw.perflevel}, 18 hardware threads), 40-core GPU, 48\,GB, macOS 27.0 (26A5425a), Xcode 27.2 (27B52), Apple clang 21.0.0 (clang-2100.4.1.1), Metal toolchain 32023.922, CMake 4.3.2, \texttt{-O3 -mcpu=native -ffp-model=precise}, Eigen 5.0.1 + Accelerate, Arrow 26.0.0. Metal: 256-thread threadgroups for reductions, 4\,096-element chunks, 64-thread threadgroups for GARCH jobs, shared storage mode, \texttt{fastMathEnabled = NO}. Repetitions: 5 (laptop), 3 (nodes); 2 warm-ups; shuffled order with seed 20261102; medians and 2\,000-draw bootstrap 95\,\% CIs. Cluster bundle: \texttt{-mcpu=apple-m1}, deployment target macOS 26.0, Arrow disabled, Metal enabled, prebuilt metallib plus embedded MSL.3233\section{Hardware inventory (E7)}34\begin{center}\scriptsize35\begin{tabular}{llrrrl}36\toprule Node & Chip & GPU cores & CPU threads & RAM (GB) & macOS \\ \midrule37m2m8a & Apple M2 & 10 & 8 & 8 & 26.5.1 \\ M2M32c & Apple M2 Max & 30 & 12 & 32 & 26.5.1 \\ M2U64 & Apple M2 Ultra & 60 & 24 & 64 & 26.5 \\ M3BA24 & Apple M3 & 10 & 8 & 24 & 26.5.1 \\ M3U96b & Apple M3 Ultra & 60 & 28 & 96 & 26.4 \\ m4md & Apple M4 & 10 & 10 & 16 & 26.6.2 \\ m4mm & Apple M4 Pro & 16 & 12 & 48 & 26.5.1 \\ M4M64c & Apple M4 Max & 40 & 16 & 64 & 26.4 \\ m5ma & Apple M5 Pro & 16 & 15 & 24 & 27.0 \\ M5M36 & Apple M5 Max & 32 & 18 & 36 & 27.0 \\ m6ma & Apple M6 & 12 & 12 & 24 & 27.0 \\ \bottomrule38\end{tabular}39\end{center}4041\section{API provenance}42FinData OS API \texttt{https://findata.spboucher.ai/api/v1} (OpenAPI 3.1 snapshot of 2026-11-02 in \texttt{docs/evidence/}); datasets \texttt{market\_bars.stock.1m.raw} (version 17\,375 at export time; 6.70 billion rows, 16\,195 symbols, 2000--2026) and \texttt{market\_bars.stock.1d.raw}; bars schema v1 (\texttt{timestamp\_utc} = bar open, UTC); exports as Parquet with the dataset version in the job record; request identifiers of every exchange are kept in the cache manifests; API key identified by a SHA-256 fingerprint only. Data © FirstRate Data, private-use licence, no redistribution.4344\section{Numerical tolerance tables}45See Table~\ref{tab:validation} for the reference tolerances. GPU/CPU tolerances by primitive: realized accumulators $10^{-6}$ relative ($\Sigma x^4$: $10^{-5}$); rolling sums $10^{-5}$; regression statistics $10^{-6}$ absolute on $\max(1,|\cdot|)$ and $10^{-5}$ on the solved coefficients; batched GARCH NLL $2\times10^{-5}$ relative (Student-$t$: $5\times10^{-5}$) on simulated series with $n = 2\,000$; on the E3 real-data grid the maximum relative difference is $2\times10^{-3}$ at boundary grid points and the argmin agrees for 888/888 series.46\end{appendices}47
Files · ae5a4e6ff6df81cef716eacbb5d51143a008d45b
Menu

Theme