Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/openaccel-lab/blob/main/workloads/layernorm/workload.json # openaccel-lab aien-dev/openaccel-lab Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `openaccel-lab / workloads / layernorm / workload.json` 123 lines ยท 3247 bytes Raw Blame History 1 { 2 "name": "layernorm", 3 "family": "row-normalization", 4 "summary": "per row r of x[R][D]: mu = mean(x), var = mean((x-mu)^2) (biased), y = (x-mu) / sqrt(var + eps) * gamma + beta, eps = 1e-5 written as an f32 constant", 5 "provenance": "authored for OpenAccel Lab (Apache-2.0)", 6 "params": { 7 "R": 24, 8 "D": 200 9 }, 10 "cases": [ 11 {}, 12 { 13 "R": 1, 14 "D": 1 15 }, 16 { 17 "R": 5, 18 "D": 777 19 } 20 ], 21 "shrink": { 22 "R": { 23 "min": 1 24 }, 25 "D": { 26 "min": 1 27 } 28 }, 29 "inputs": [ 30 { 31 "name": "x", 32 "dtype": "f32", 33 "shape": [ 34 "R", 35 "D" 36 ], 37 "gen": { 38 "kind": "normal4", 39 "mean": 2.0, 40 "std": 1.5 41 } 42 }, 43 { 44 "name": "gamma", 45 "dtype": "f32", 46 "shape": [ 47 "D" 48 ], 49 "gen": { 50 "kind": "uniform", 51 "lo": 0.5, 52 "hi": 1.5 53 } 54 }, 55 { 56 "name": "beta", 57 "dtype": "f32", 58 "shape": [ 59 "D" 60 ], 61 "gen": { 62 "kind": "uniform", 63 "lo": -1.0, 64 "hi": 1.0 65 } 66 } 67 ], 68 "outputs": [ 69 { 70 "name": "y", 71 "dtype": "f32", 72 "shape": [ 73 "R", 74 "D" 75 ] 76 } 77 ], 78 "tolerance": { 79 "y": { 80 "kind": "bound", 81 "rtol": 1.0, 82 "atol": 0.0, 83 "why": "reference.py returns an absolute per-element bound B as the scale (rtol 1), evaluated in float64 from the exact inputs, with eps = f32(1e-5), A = sum|x|/D, c = x - mu, v = var + eps, s = v^-1/2, g(n) = gamma(n). (1) mean: a sum in any order plus a divide, or a multiply by f32(1/D), gives |mu^ - mu| <= Em = g(D+1) A. (2) c^ = fl(x - mu^) = (c + e)(1+d), |e| <= Em, so |c^ - c| <= Dc = Em + u(|c| + Em). (3) Sum c^2 in any order, FMA or not, within g(D) (Higham Thm 3.1/3.5); the squares' (1+d)^2 cost g(2); the 1/D step g(2); the + eps one rounding with both terms positive; and since sum(c)=0 the shift e adds exactly D e^2, so v^ = v (1 + e^2/v)(1 + theta), |theta| <= g(D+5): rho = (1 + Em^2/v)(1 + g(D+5)) - 1. (4) |(1+rho)^(-1/2) - 1| <= (2 sqrt2 - 2)|rho| <= |rho| for rho >= -1/2 (WolframLanguageEvaluator: MaxValue[{Abs[(1+r)^(-1/2)-1]/Abs[r], -1/2<=r<=10, r!=0}, r] -> 0.`8284271247` = 2(Sqrt[2]-1)); rsqrt is budgeted 2 ulp (OpenCL C 3.0 s7.4 rsqrt <= 2 ulp; CUDA rsqrtf 2 ulp) = 4u relative (WolframLanguageEvaluator: 2*2^-23/2^-24 -> 4), which also covers 1/sqrt (correctly rounded sqrt then divide, WolframLanguageEvaluator: ((1+u)/(1-u)-1)/u -> 2.`0000001`); so r^ = s(1+phi), phi = (1+rho)(1+4u) - 1. (5) P = c^ r^ gamma: |P - c s gamma| <= |gamma| s (Dc (1+phi) + |c| phi). (6) the two products and the + beta, any order or fused, add at most g(3)(|P| + |beta|) with |P| <= |gamma| s (|c| + Dc)(1+phi). B = (5) + (6). For D=200 the dominant term is about g(205) relative (WolframLanguageEvaluator: 209u/(1-209u) -> 1.2458e-5 for the g(D+9)-sized total), so a dropped term (1/D = 5e-3), unbiased variance (1/(2D)) or a missing beta fails." 84 } 85 }, 86 "timing": { 87 "warmup": 1, 88 "repeats": 5 89 }, 90 "backends": { 91 "omega": { 92 "src": "omega.om" 93 }, 94 "opencl": { 95 "src": "kernel.cl", 96 "launches": [ 97 { 98 "kernel": "layernorm", 99 "global": [ 100 "R*64" 101 ], 102 "local": [ 103 "64" 104 ], 105 "args": [ 106 "x", 107 "gamma", 108 "beta", 109 "y", 110 "D", 111 "local:f32:64" 112 ] 113 } 114 ] 115 }, 116 "triton": { 117 "src": "triton_kernel.py" 118 }, 119 "cuda": { 120 "src": "kernel.cu" 121 } 122 } 123 }