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/controls/attention_nomax/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 / controls / attention_nomax / workload.json` 145 lines ยท 3673 bytes Raw Blame History 1 { 2 "name": "attention_nomax", 3 "expect": "fail", 4 "reference_from": "attention", 5 "family": "attention", 6 "summary": "CONTROL: workloads/attention with the row max subtraction omitted in every entrant (e_j = exp(s_j)); Q and K have mean 3.5, so scores near 98 exceed ln(f32 max) = 88.72 and exp overflows, giving NaN rows; the T = 1 case is left out because one score may fall below 88.72", 7 "provenance": "authored for OpenAccel Lab (Apache-2.0)", 8 "params": { 9 "T": 48, 10 "Dh": 64 11 }, 12 "cases": [ 13 {}, 14 { 15 "T": 17 16 } 17 ], 18 "shrink": { 19 "T": { 20 "min": 1 21 }, 22 "Dh": { 23 "min": 64, 24 "multiple_of": 64 25 } 26 }, 27 "inputs": [ 28 { 29 "name": "q", 30 "dtype": "f32", 31 "shape": [ 32 "T", 33 "Dh" 34 ], 35 "gen": { 36 "kind": "normal4", 37 "mean": 3.5, 38 "std": 1.0 39 } 40 }, 41 { 42 "name": "k", 43 "dtype": "f32", 44 "shape": [ 45 "T", 46 "Dh" 47 ], 48 "gen": { 49 "kind": "normal4", 50 "mean": 3.5, 51 "std": 1.0 52 } 53 }, 54 { 55 "name": "v", 56 "dtype": "f32", 57 "shape": [ 58 "T", 59 "Dh" 60 ], 61 "gen": { 62 "kind": "normal4", 63 "mean": 0.0, 64 "std": 1.0 65 } 66 } 67 ], 68 "outputs": [ 69 { 70 "name": "o", 71 "dtype": "f32", 72 "shape": [ 73 "T", 74 "Dh" 75 ] 76 } 77 ], 78 "scratch": [ 79 { 80 "name": "pw", 81 "dtype": "f32", 82 "shape": [ 83 "T", 84 "T" 85 ] 86 } 87 ], 88 "tolerance": { 89 "o": { 90 "kind": "bound", 91 "rtol": 1, 92 "atol": 1e-35, 93 "why": "reference.py returns the whole bound as the scale, per element: for row i with n = i+1 terms, bound = sum_j p_j |v_jc| c_j. Algorithm covered: scores, row max, exp(score - max), sum, then either p_j = e_j/sum and O = sum_j p_j v_j or O = (sum_j e_j v_j)/sum, every sum in any order, with or without FMA. Each score is within e_j = gamma(Dh) a_j, a_j = 0.125 sum_c |q_c k_jc| (Higham Thm 3.1; 0.125 exact); the row max within E = max_j e_j; the subtraction adds u|s_j - max|; so exp's argument is within tau_j = e_j + E + u(|d_j| + e_j + E), and with exp budgeted at 3 ulp <= 6u relative (OpenCL C 3.0 s7.4; CUDA expf 2 ulp = 4u is inside it) each exp(score - max) has relative error theta_j = e^tau_j (1 + 6u) - 1. The positive denominator sum has relative error K = sum_j p_j((1+theta_j)(1+gamma(n-1)) - 1); the numerator dot, including the p_j division, is within gamma(n+1) and a final division adds u, giving c_j = (1+theta_j)(1+gamma(n+1))(1+u)/(1-K) - 1. WolframLanguageEvaluator: u=2^-24; g[n_]:=n u/(1-n u); N[g[64],10] -> 3.`814711818`*10^-6; N[g[49],10] -> 2.`920636124`*10^-6; N[g[47],10] -> 2.`801426152`*10^-6; N[3*2^-23/u] -> 6.; N[2*2^-23/u] -> 4.; N[64*2^-24/(1-64*2^-24)*98*2,10] -> 0.`0007476835162` (2 gamma(64) a with a near 8*3.5^2 = 98: the order of c_j, so a dropped term or a missing mask fails). atol covers exp, p_j and p_j v_j results flushed or rounded below 2^-126: at most 3 n of them, each < 2^-126 max|v| with max|v| <= Sqrt[12] (normal4 range) and the denominator >= 1: N[3*48*2^-126*Sqrt[12],10] -> 5.`863725906`*10^-36 <= 1e-35. Without the max subtraction exp overflows: N[Log[2^128],10] -> 88.`72283911` is below scores near 98, so O becomes NaN." 94 } 95 }, 96 "timing": { 97 "warmup": 1, 98 "repeats": 5 99 }, 100 "backends": { 101 "omega": { 102 "src": "omega.om" 103 }, 104 "opencl": { 105 "src": "kernel.cl", 106 "launches": [ 107 { 108 "kernel": "attn_p", 109 "global": [ 110 "T" 111 ], 112 "local": null, 113 "args": [ 114 "q", 115 "k", 116 "pw", 117 "T", 118 "Dh" 119 ] 120 }, 121 { 122 "kernel": "attn_o", 123 "global": [ 124 "T", 125 "Dh" 126 ], 127 "local": null, 128 "args": [ 129 "pw", 130 "v", 131 "o", 132 "T", 133 "Dh" 134 ] 135 } 136 ] 137 }, 138 "triton": { 139 "src": "triton_kernel.py" 140 }, 141 "cuda": { 142 "src": "kernel.cu" 143 } 144 } 145 }