spear-kernels 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +2 -2
  2. package/index.cjs +174 -24
  3. package/index.js +174 -24
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -42,5 +42,5 @@ instance.exports.spear(2); // same protected-division semantics as the JS backen
42
42
  ```
43
43
 
44
44
  Division is **protected** exactly like the engine: denominators floored at
45
- ±1e-4 (sign-preserving), results clamped to ±1e4. Discovered formulas rely on
46
- these rails — do not swap in bare `/`.
45
+ ±1e-4 (sign-preserving), results clamped to ±1e4. Discovered formulas rely on
46
+ these rails do not swap in bare `/`.
package/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- // Auto-generated by scripts/gen-kernels-package.ts — DO NOT EDIT.
1
+ // Auto-generated by scripts/gen-kernels-package.ts DO NOT EDIT.
2
2
  'use strict';
3
3
  const kernels = {
4
4
  "silu": {
@@ -29,11 +29,11 @@ const kernels = {
29
29
  "gelu": {
30
30
  id: "gelu",
31
31
  precise: {
32
- js: "((x) => ((0.999993 * ((0.5 * x) * (1 + Math.tanh((0.797885 * (x + (0.044715 * (x) * (x) * (x)))))))) + -0.000058))",
33
- eval: ((x) => ((0.999993 * ((0.5 * x) * (1 + Math.tanh((0.797885 * (x + (0.044715 * (x) * (x) * (x)))))))) + -0.000058)),
34
- c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.999993f * ((0.5f * x) * (1f + tanhf((0.797885f * (x + (0.044715f * powf(x, 3.0f)))))))) + -0.000058f);\n}",
35
- py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.999993 * ((0.5 * x) * (1 + torch.tanh((0.797885 * (x + (0.044715 * (x ** 3)))))))) + -0.000058)",
36
- wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgwBA2VudgR0YW5oAAEDAgEABwkBBXNwZWFyAAEKUAFOAERhU+dR8f/vP0QAAAAAAADgPyAAokQAAAAAAADwP0S4AZ8fRojpPyAARPcBSG3i5KY/IAAgACAAoqKioKIQAKCiokSQvknToGgOv6AL",
32
+ js: "((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return ((0.5 * x) * (1 + __erf((x * 0.7071067811865475)))); })",
33
+ eval: ((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return ((0.5 * x) * (1 + __erf((x * 0.7071067811865475)))); }),
34
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.5f * x) * (1f + erff((x * 0.707107f))));\n}",
35
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.5 * x) * (1 + torch.erf((x * 0.707107))))",
36
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNlcmYAAQMCAQAHCQEFc3BlYXIAAQopAScARAAAAAAAAOA/IACiRAAAAAAAAPA/IABEzDt/Zp6g5j+iEACgogs=",
37
37
  },
38
38
  fast: {
39
39
  js: "((x) => Math.max(0, x))",
@@ -43,11 +43,11 @@ const kernels = {
43
43
  wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAAChABDgAgAEQAAAAAAAAAAKUL",
44
44
  },
45
45
  meta: {
46
- metric: 3.55135869310835e-8,
46
+ metric: 1.5455587803707568e-34,
47
47
  level: 5,
48
- formulaCost: 11,
48
+ formulaCost: 5,
49
49
  exactCost: 46,
50
- speedupVsExact: 4.181818181818182,
50
+ speedupVsExact: 9.2,
51
51
  vsIterative: null,
52
52
  },
53
53
  },
@@ -919,25 +919,25 @@ const kernels = {
919
919
  "erf_prob": {
920
920
  id: "erf_prob",
921
921
  precise: {
922
- js: "((x) => (1.106774 * Math.min(1e4, Math.max(-1e4, ((x + (0.034298 * (x) * (x) * (x)))) / (((0.995 + (0.378089 * (x) * (x)))) < 1e-4 && ((0.995 + (0.378089 * (x) * (x)))) > -1e-4 ? (((0.995 + (0.378089 * (x) * (x)))) >= 0 ? 1e-4 : -1e-4) : ((0.995 + (0.378089 * (x) * (x)))))))))",
923
- eval: ((x) => (1.106774 * Math.min(1e4, Math.max(-1e4, ((x + (0.034298 * (x) * (x) * (x)))) / (((0.995 + (0.378089 * (x) * (x)))) < 1e-4 && ((0.995 + (0.378089 * (x) * (x)))) > -1e-4 ? (((0.995 + (0.378089 * (x) * (x)))) >= 0 ? 1e-4 : -1e-4) : ((0.995 + (0.378089 * (x) * (x))))))))),
924
- c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (1.106774f * fminf(fmaxf(((x + (0.034298f * powf(x, 3.0f))) / copysignf(fmaxf(fabsf((0.995f + (0.378089f * powf(x, 2.0f)))), 1.0e-4f), (0.995f + (0.378089f * powf(x, 2.0f))))), -1.0e4f), 1.0e4f));\n}",
925
- py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (1.106774 * ((x + (0.034298 * (x ** 3))) / (abs((0.995 + (0.378089 * (x * x)))) < 1e-4 ? 1e-4 : (0.995 + (0.378089 * (x * x))))))",
926
- wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACnYBdABEeQJhp1i18T8gAEQp7KLogY+hPyAAIAAgAKKioqBE16NwPQrX7z9Ezox+NJwy2D8gACAAoqKgmUQtQxzr4jYaP6VE16NwPQrX7z9Ezox+NJwy2D8gACAAoqKgpqNEAAAAAACIw8ClRAAAAAAAiMNApKIL",
922
+ js: "((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); })",
923
+ eval: ((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); }),
924
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return erff(x);\n}",
925
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.erf(x)",
926
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNlcmYAAQMCAQAHCQEFc3BlYXIAAQoIAQYAIAAQAAs=",
927
927
  },
928
928
  fast: {
929
- js: "((x) => Math.atan(x))",
930
- eval: ((x) => Math.atan(x)),
931
- c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return atanf(x);\n}",
932
- py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.atan(x)",
933
- wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgwBA2VudgRhdGFuAAEDAgEABwkBBXNwZWFyAAEKCAEGACAAEAAL",
929
+ js: "((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); })",
930
+ eval: ((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); }),
931
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return erff(x);\n}",
932
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.erf(x)",
933
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNlcmYAAQMCAQAHCQEFc3BlYXIAAQoIAQYAIAAQAAs=",
934
934
  },
935
935
  meta: {
936
- metric: 0.00004650870031371604,
937
- level: 3,
938
- formulaCost: 12,
936
+ metric: 0,
937
+ level: 5,
938
+ formulaCost: 1,
939
939
  exactCost: 26,
940
- speedupVsExact: 2.1666666666666665,
940
+ speedupVsExact: 26,
941
941
  vsIterative: null,
942
942
  },
943
943
  },
@@ -2002,8 +2002,158 @@ const kernels = {
2002
2002
  vsIterative: null,
2003
2003
  },
2004
2004
  },
2005
+ "rope_freq": {
2006
+ id: "rope_freq",
2007
+ precise: {
2008
+ js: "((x) => ((0.9999991529919943 * ((0.999947 * Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x))))))) + -0.000038)) + 0.00001879512303862185))",
2009
+ eval: ((x) => ((0.9999991529919943 * ((0.999947 * Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x))))))) + -0.000038)) + 0.00001879512303862185)),
2010
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.999999f * ((0.999947f * cosf((1023.994f * expf(fmaxf(-50.0f, fminf(50.0f, (-0.28782f * x))))))) + -0.000038f)) + 0.000019f);\n}",
2011
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.999999 * ((0.999947 * torch.cos((1023.994 * torch.exp(torch.clamp((-0.28782 * x), -50.0, 50.0))))) + -0.000038)) + 0.000019)",
2012
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AhUCA2VudgNleHAAAQNlbnYDY29zAAEDAgEABwkBBXNwZWFyAAIKWgFYAEQqG0Q5/v/vP0RLd9fZkP/vP0TLoUW28/+PQERBn8iTpGvSvyAAokQAAAAAAABJwKVEAAAAAAAASUCkEACiEAGiRBgK2A5G7AO/oKJEuB45BUe18z6gCw==",
2013
+ },
2014
+ fast: {
2015
+ js: "((x) => Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x)))))))",
2016
+ eval: ((x) => Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x))))))),
2017
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return cosf((1023.994f * expf(fmaxf(-50.0f, fminf(50.0f, (-0.28782f * x))))));\n}",
2018
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.cos((1023.994 * torch.exp(torch.clamp((-0.28782 * x), -50.0, 50.0))))",
2019
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AhUCA2VudgNleHAAAQNlbnYDY29zAAEDAgEABwkBBXNwZWFyAAIKMgEwAETLoUW28/+PQERBn8iTpGvSvyAAokQAAAAAAABJwKVEAAAAAAAASUCkEACiEAEL",
2020
+ },
2021
+ meta: {
2022
+ metric: 8.450097215964813e-7,
2023
+ level: 5,
2024
+ formulaCost: 8,
2025
+ exactCost: 43,
2026
+ speedupVsExact: 5.375,
2027
+ vsIterative: null,
2028
+ },
2029
+ },
2030
+ "bilateral_weight": {
2031
+ id: "bilateral_weight",
2032
+ precise: {
2033
+ js: "((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2)))))))",
2034
+ eval: ((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2))))))),
2035
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return fminf(fmaxf((expf(fmaxf(-50.0f, fminf(50.0f, (-(powf(x, 2.0f) * 50f))))) / copysignf(fmaxf(fabsf((1f + (powf(x, 2.0f) * 2f))), 1.0e-4f), (1f + (powf(x, 2.0f) * 2f)))), -1.0e4f), 1.0e4f);\n}",
2036
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (torch.exp(torch.clamp((-((x * x) * 50)), -50.0, 50.0)) / (abs((1 + ((x * x) * 2))) < 1e-4 ? 1e-4 : (1 + ((x * x) * 2))))",
2037
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNleHAAAQMCAQAHCQEFc3BlYXIAAQp9AXsAIAAgAKJEAAAAAAAASUCimkQAAAAAAABJwKVEAAAAAAAASUCkEABEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgmUQtQxzr4jYaP6VEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgpqNEAAAAAACIw8ClRAAAAAAAiMNApAs=",
2038
+ },
2039
+ fast: {
2040
+ js: "((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2)))))))",
2041
+ eval: ((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2))))))),
2042
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return fminf(fmaxf((expf(fmaxf(-50.0f, fminf(50.0f, (-(powf(x, 2.0f) * 50f))))) / copysignf(fmaxf(fabsf((1f + (powf(x, 2.0f) * 2f))), 1.0e-4f), (1f + (powf(x, 2.0f) * 2f)))), -1.0e4f), 1.0e4f);\n}",
2043
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (torch.exp(torch.clamp((-((x * x) * 50)), -50.0, 50.0)) / (abs((1 + ((x * x) * 2))) < 1e-4 ? 1e-4 : (1 + ((x * x) * 2))))",
2044
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNleHAAAQMCAQAHCQEFc3BlYXIAAQp9AXsAIAAgAKJEAAAAAAAASUCimkQAAAAAAABJwKVEAAAAAAAASUCkEABEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgmUQtQxzr4jYaP6VEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgpqNEAAAAAACIw8ClRAAAAAAAiMNApAs=",
2045
+ },
2046
+ meta: {
2047
+ metric: 9.336399957342636e-35,
2048
+ level: 5,
2049
+ formulaCost: 11,
2050
+ exactCost: 45,
2051
+ speedupVsExact: 4.090909090909091,
2052
+ vsIterative: null,
2053
+ },
2054
+ },
2055
+ "bs_d1_sigma": {
2056
+ id: "bs_d1_sigma",
2057
+ precise: {
2058
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((Math.abs(x)) < 1e-4 && (Math.abs(x)) > -1e-4 ? ((Math.abs(x)) >= 0 ? 1e-4 : -1e-4) : (Math.abs(x))))) + (0.25 * Math.abs(x))))",
2059
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((Math.abs(x)) < 1e-4 && (Math.abs(x)) > -1e-4 ? ((Math.abs(x)) >= 0 ? 1e-4 : -1e-4) : (Math.abs(x))))) + (0.25 * Math.abs(x)))),
2060
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((0.21562f / copysignf(fmaxf(fabsf(fabsf(x)), 1.0e-4f), fabsf(x))), -1.0e4f), 1.0e4f) + (0.25f * fabsf(x)));\n}",
2061
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.21562 / (abs(torch.abs(x)) < 1e-4 ? 1e-4 : torch.abs(x))) + (0.25 * torch.abs(x)))",
2062
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACkIBQABEop9GrXKZyz8gAJmZRC1DHOviNho/pSAAmaajRAAAAAAAiMPApUQAAAAAAIjDQKREAAAAAAAA0D8gAJmioAs=",
2063
+ },
2064
+ fast: {
2065
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (3.635301) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (4.215319 * x)))",
2066
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (3.635301) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (4.215319 * x))),
2067
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((3.635301f / copysignf(fmaxf(fabsf(x), 1.0e-4f), x)), -1.0e4f), 1.0e4f) + (4.215319f * x));\n}",
2068
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((3.635301 / (abs(x) < 1e-4 ? 1e-4 : x)) + (4.215319 * x))",
2069
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACj8BPQBExO3QsBgVDUAgAJlELUMc6+I2Gj+lIACmo0QAAAAAAIjDwKVEAAAAAACIw0CkRGfUfJV83BBAIACioAs=",
2070
+ },
2071
+ meta: {
2072
+ metric: 1.6217711315014304e-18,
2073
+ level: 5,
2074
+ formulaCost: 8,
2075
+ exactCost: 9,
2076
+ speedupVsExact: 1.125,
2077
+ vsIterative: null,
2078
+ },
2079
+ },
2080
+ "mel_scale": {
2081
+ id: "mel_scale",
2082
+ precise: {
2083
+ js: "((x) => (1126.994181 * Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286))))))",
2084
+ eval: ((x) => (1126.994181 * Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286)))))),
2085
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (1126.994181f * logf(fmaxf(1.0e-30f, (1f + (x * 0.001429f)))));\n}",
2086
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (1126.994181 * torch.log(torch.clamp((1 + (x * 0.001429)), min=1e-30)))",
2087
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQowAS4ARDiFlQr6m5FARAAAAAAAAPA/IABEsak05NxnVz+ioESgwuv+S0i0OaUQAKIL",
2088
+ },
2089
+ fast: {
2090
+ js: "((x) => Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286)))))",
2091
+ eval: ((x) => Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286))))),
2092
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return logf(fmaxf(1.0e-30f, (1f + (x * 0.001429f))));\n}",
2093
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.log(torch.clamp((1 + (x * 0.001429)), min=1e-30))",
2094
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQomASQARAAAAAAAAPA/IABEsak05NxnVz+ioESgwuv+S0i0OaUQAAs=",
2095
+ },
2096
+ meta: {
2097
+ metric: 1.4594066099947563e-12,
2098
+ level: 5,
2099
+ formulaCost: 4,
2100
+ exactCost: 23,
2101
+ speedupVsExact: 5.75,
2102
+ vsIterative: null,
2103
+ },
2104
+ },
2105
+ "bs_d2_sigma": {
2106
+ id: "bs_d2_sigma",
2107
+ precise: {
2108
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x))))",
2109
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x)))),
2110
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((0.21562f / copysignf(fmaxf(fabsf(x), 1.0e-4f), x)), -1.0e4f), 1.0e4f) + (-(0.25f * x)));\n}",
2111
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.21562 / (abs(x) < 1e-4 ? 1e-4 : x)) + (-(0.25 * x)))",
2112
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACkABPgBEop9GrXKZyz8gAJlELUMc6+I2Gj+lIACmo0QAAAAAAIjDwKVEAAAAAACIw0CkRAAAAAAAANA/IACimqAL",
2113
+ },
2114
+ fast: {
2115
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x))))",
2116
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x)))),
2117
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((0.21562f / copysignf(fmaxf(fabsf(x), 1.0e-4f), x)), -1.0e4f), 1.0e4f) + (-(0.25f * x)));\n}",
2118
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.21562 / (abs(x) < 1e-4 ? 1e-4 : x)) + (-(0.25 * x)))",
2119
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACkABPgBEop9GrXKZyz8gAJlELUMc6+I2Gj+lIACmo0QAAAAAAIjDwKVEAAAAAACIw0CkRAAAAAAAANA/IACimqAL",
2120
+ },
2121
+ meta: {
2122
+ metric: 1.6217711130493227e-18,
2123
+ level: 5,
2124
+ formulaCost: 7,
2125
+ exactCost: 11,
2126
+ speedupVsExact: 1.5714285714285714,
2127
+ vsIterative: null,
2128
+ },
2129
+ },
2130
+ "a_weighting": {
2131
+ id: "a_weighting",
2132
+ precise: {
2133
+ js: "((x) => ((0.9803615530479888 * ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2)) + 0.039276893904016105))",
2134
+ eval: ((x) => ((0.9803615530479888 * ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2)) + 0.039276893904016105)),
2135
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.980362f * ((8.859884f * logf(fmaxf(1.0e-30f, fminf(fmaxf((((148691236f * powf(x, 2.0f)) * powf(x, 2.0f)) / copysignf(fmaxf(fabsf(((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f)))), 1.0e-4f), ((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f))))), -1.0e4f), 1.0e4f)))) + 2f)) + 0.039277f);\n}",
2136
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.980362 * ((8.859884 * torch.log(torch.clamp((((148691236 * (x * x)) * (x * x)) / (abs((((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236)))) < 1e-4 ? 1e-4 : (((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236))))), min=1e-30))) + 2)) + 0.039277)",
2137
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQrxAQHuAQBEphkTMR9f7z9EE7U0t0K4IUBEAAAASLK5oUEgACAAoqIgACAAoqIgACAAokT2KFyPwoV6QKAgACAAokTsUbgepafGQKAgACAAokQfhevR4J0gQaCimZ8gACAAokQAAABIsrmhQaCioplELUMc6+I2Gj+lIAAgAKJE9ihcj8KFekCgIAAgAKJE7FG4HqWnxkCgIAAgAKJEH4Xr0eCdIEGgopmfIAAgAKJEAAAASLK5oUGgoqKmo0QAAAAAAIjDwKVEAAAAAACIw0CkRKDC6/5LSLQ5pRAAokQAAAAAAAAAQKCiRK7HnN0ZHKQ/oAs=",
2138
+ },
2139
+ fast: {
2140
+ js: "((x) => ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2))",
2141
+ eval: ((x) => ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2)),
2142
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((8.859884f * logf(fmaxf(1.0e-30f, fminf(fmaxf((((148691236f * powf(x, 2.0f)) * powf(x, 2.0f)) / copysignf(fmaxf(fabsf(((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f)))), 1.0e-4f), ((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f))))), -1.0e4f), 1.0e4f)))) + 2f);\n}",
2143
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((8.859884 * torch.log(torch.clamp((((148691236 * (x * x)) * (x * x)) / (abs((((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236)))) < 1e-4 ? 1e-4 : (((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236))))), min=1e-30))) + 2)",
2144
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQrdAQHaAQBEE7U0t0K4IUBEAAAASLK5oUEgACAAoqIgACAAoqIgACAAokT2KFyPwoV6QKAgACAAokTsUbgepafGQKAgACAAokQfhevR4J0gQaCimZ8gACAAokQAAABIsrmhQaCioplELUMc6+I2Gj+lIAAgAKJE9ihcj8KFekCgIAAgAKJE7FG4HqWnxkCgIAAgAKJEH4Xr0eCdIEGgopmfIAAgAKJEAAAASLK5oUGgoqKmo0QAAAAAAIjDwKVEAAAAAACIw0CkRKDC6/5LSLQ5pRAAokQAAAAAAAAAQKAL",
2145
+ },
2146
+ meta: {
2147
+ metric: 2.7800484820648814e-29,
2148
+ level: 5,
2149
+ formulaCost: 26,
2150
+ exactCost: 55,
2151
+ speedupVsExact: 2.1153846153846154,
2152
+ vsIterative: null,
2153
+ },
2154
+ },
2005
2155
  };
2006
2156
 
2007
- const kernelIds = ["silu","gelu","sigmoid","kv_cache","free_fall","kepler","gaussian_cdf","damped_pendulum","rl_distillation","lambert_w","rc_circuit","gaussian_kernel","diffusion_beta","bilinear_interp","european_call","temporal_grad","lorentz","hill","kerr","lennard_jones","damped_oscillation","logistic_growth","softplus","kdv_soliton","kerr_spin","pendulum_hybrid","eigen3_sym","ik_reach","idm_following","gemv4","rope_rot","gauss_shader","ema_smooth","smoothstep","srgb_gamma","tanh_sat","atan_unit","srgb_decode","erf_prob","huber_loss","cosh_curve","bessel_j0","bessel_j1","blackbody_r","aces_fit","logsumexp2","probit_quantile","pmt_finance","blackbody_g","blackbody_b","bessel_j2","logit_ml","kelly_criterion","rsi_momentum","implied_vol","michaelis_menten","temperature_softmax","doppler_effect","stefan_boltzmann","mm1_queue_wait","grover_amplitude","concurrence_pure","chsh_correlation","legendre_p2","laguerre_l2","asin_hard","qfi_dephasing","amp_damp_fid","loschmidt_rate","bessel_i0e","elliptic_k","kepler_solver","fast_exp_alu","fresnel_schlick","rayleigh_phase","smootherstep","fog_exp2","back_ease_out","light_falloff_punctual","bias_slope","uncharted2_tonemap","mish"];
2157
+ const kernelIds = ["silu","gelu","sigmoid","kv_cache","free_fall","kepler","gaussian_cdf","damped_pendulum","rl_distillation","lambert_w","rc_circuit","gaussian_kernel","diffusion_beta","bilinear_interp","european_call","temporal_grad","lorentz","hill","kerr","lennard_jones","damped_oscillation","logistic_growth","softplus","kdv_soliton","kerr_spin","pendulum_hybrid","eigen3_sym","ik_reach","idm_following","gemv4","rope_rot","gauss_shader","ema_smooth","smoothstep","srgb_gamma","tanh_sat","atan_unit","srgb_decode","erf_prob","huber_loss","cosh_curve","bessel_j0","bessel_j1","blackbody_r","aces_fit","logsumexp2","probit_quantile","pmt_finance","blackbody_g","blackbody_b","bessel_j2","logit_ml","kelly_criterion","rsi_momentum","implied_vol","michaelis_menten","temperature_softmax","doppler_effect","stefan_boltzmann","mm1_queue_wait","grover_amplitude","concurrence_pure","chsh_correlation","legendre_p2","laguerre_l2","asin_hard","qfi_dephasing","amp_damp_fid","loschmidt_rate","bessel_i0e","elliptic_k","kepler_solver","fast_exp_alu","fresnel_schlick","rayleigh_phase","smootherstep","fog_exp2","back_ease_out","light_falloff_punctual","bias_slope","uncharted2_tonemap","mish","rope_freq","bilateral_weight","bs_d1_sigma","mel_scale","bs_d2_sigma","a_weighting"];
2008
2158
 
2009
2159
  module.exports = { kernels, kernelIds, default: kernels };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Auto-generated by scripts/gen-kernels-package.ts — DO NOT EDIT.
1
+ // Auto-generated by scripts/gen-kernels-package.ts DO NOT EDIT.
2
2
  // Self-contained runtime: the arrow functions below ARE the kernels.
3
3
  export const kernels = {
4
4
  "silu": {
@@ -29,11 +29,11 @@ export const kernels = {
29
29
  "gelu": {
30
30
  id: "gelu",
31
31
  precise: {
32
- js: "((x) => ((0.999993 * ((0.5 * x) * (1 + Math.tanh((0.797885 * (x + (0.044715 * (x) * (x) * (x)))))))) + -0.000058))",
33
- eval: ((x) => ((0.999993 * ((0.5 * x) * (1 + Math.tanh((0.797885 * (x + (0.044715 * (x) * (x) * (x)))))))) + -0.000058)),
34
- c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.999993f * ((0.5f * x) * (1f + tanhf((0.797885f * (x + (0.044715f * powf(x, 3.0f)))))))) + -0.000058f);\n}",
35
- py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.999993 * ((0.5 * x) * (1 + torch.tanh((0.797885 * (x + (0.044715 * (x ** 3)))))))) + -0.000058)",
36
- wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgwBA2VudgR0YW5oAAEDAgEABwkBBXNwZWFyAAEKUAFOAERhU+dR8f/vP0QAAAAAAADgPyAAokQAAAAAAADwP0S4AZ8fRojpPyAARPcBSG3i5KY/IAAgACAAoqKioKIQAKCiokSQvknToGgOv6AL",
32
+ js: "((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return ((0.5 * x) * (1 + __erf((x * 0.7071067811865475)))); })",
33
+ eval: ((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return ((0.5 * x) * (1 + __erf((x * 0.7071067811865475)))); }),
34
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.5f * x) * (1f + erff((x * 0.707107f))));\n}",
35
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.5 * x) * (1 + torch.erf((x * 0.707107))))",
36
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNlcmYAAQMCAQAHCQEFc3BlYXIAAQopAScARAAAAAAAAOA/IACiRAAAAAAAAPA/IABEzDt/Zp6g5j+iEACgogs=",
37
37
  },
38
38
  fast: {
39
39
  js: "((x) => Math.max(0, x))",
@@ -43,11 +43,11 @@ export const kernels = {
43
43
  wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAAChABDgAgAEQAAAAAAAAAAKUL",
44
44
  },
45
45
  meta: {
46
- metric: 3.55135869310835e-8,
46
+ metric: 1.5455587803707568e-34,
47
47
  level: 5,
48
- formulaCost: 11,
48
+ formulaCost: 5,
49
49
  exactCost: 46,
50
- speedupVsExact: 4.181818181818182,
50
+ speedupVsExact: 9.2,
51
51
  vsIterative: null,
52
52
  },
53
53
  },
@@ -919,25 +919,25 @@ export const kernels = {
919
919
  "erf_prob": {
920
920
  id: "erf_prob",
921
921
  precise: {
922
- js: "((x) => (1.106774 * Math.min(1e4, Math.max(-1e4, ((x + (0.034298 * (x) * (x) * (x)))) / (((0.995 + (0.378089 * (x) * (x)))) < 1e-4 && ((0.995 + (0.378089 * (x) * (x)))) > -1e-4 ? (((0.995 + (0.378089 * (x) * (x)))) >= 0 ? 1e-4 : -1e-4) : ((0.995 + (0.378089 * (x) * (x)))))))))",
923
- eval: ((x) => (1.106774 * Math.min(1e4, Math.max(-1e4, ((x + (0.034298 * (x) * (x) * (x)))) / (((0.995 + (0.378089 * (x) * (x)))) < 1e-4 && ((0.995 + (0.378089 * (x) * (x)))) > -1e-4 ? (((0.995 + (0.378089 * (x) * (x)))) >= 0 ? 1e-4 : -1e-4) : ((0.995 + (0.378089 * (x) * (x))))))))),
924
- c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (1.106774f * fminf(fmaxf(((x + (0.034298f * powf(x, 3.0f))) / copysignf(fmaxf(fabsf((0.995f + (0.378089f * powf(x, 2.0f)))), 1.0e-4f), (0.995f + (0.378089f * powf(x, 2.0f))))), -1.0e4f), 1.0e4f));\n}",
925
- py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (1.106774 * ((x + (0.034298 * (x ** 3))) / (abs((0.995 + (0.378089 * (x * x)))) < 1e-4 ? 1e-4 : (0.995 + (0.378089 * (x * x))))))",
926
- wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACnYBdABEeQJhp1i18T8gAEQp7KLogY+hPyAAIAAgAKKioqBE16NwPQrX7z9Ezox+NJwy2D8gACAAoqKgmUQtQxzr4jYaP6VE16NwPQrX7z9Ezox+NJwy2D8gACAAoqKgpqNEAAAAAACIw8ClRAAAAAAAiMNApKIL",
922
+ js: "((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); })",
923
+ eval: ((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); }),
924
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return erff(x);\n}",
925
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.erf(x)",
926
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNlcmYAAQMCAQAHCQEFc3BlYXIAAQoIAQYAIAAQAAs=",
927
927
  },
928
928
  fast: {
929
- js: "((x) => Math.atan(x))",
930
- eval: ((x) => Math.atan(x)),
931
- c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return atanf(x);\n}",
932
- py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.atan(x)",
933
- wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgwBA2VudgRhdGFuAAEDAgEABwkBBXNwZWFyAAEKCAEGACAAEAAL",
929
+ js: "((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); })",
930
+ eval: ((x) => { const __erf = (x) => { const s = x < 0 ? -1 : 1; const ax = Math.abs(x); const t = 1 / (1 + 0.3275911 * ax); return s * (1 - ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t * Math.exp(-ax * ax)); }; return __erf(x); }),
931
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return erff(x);\n}",
932
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.erf(x)",
933
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNlcmYAAQMCAQAHCQEFc3BlYXIAAQoIAQYAIAAQAAs=",
934
934
  },
935
935
  meta: {
936
- metric: 0.00004650870031371604,
937
- level: 3,
938
- formulaCost: 12,
936
+ metric: 0,
937
+ level: 5,
938
+ formulaCost: 1,
939
939
  exactCost: 26,
940
- speedupVsExact: 2.1666666666666665,
940
+ speedupVsExact: 26,
941
941
  vsIterative: null,
942
942
  },
943
943
  },
@@ -2002,8 +2002,158 @@ export const kernels = {
2002
2002
  vsIterative: null,
2003
2003
  },
2004
2004
  },
2005
+ "rope_freq": {
2006
+ id: "rope_freq",
2007
+ precise: {
2008
+ js: "((x) => ((0.9999991529919943 * ((0.999947 * Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x))))))) + -0.000038)) + 0.00001879512303862185))",
2009
+ eval: ((x) => ((0.9999991529919943 * ((0.999947 * Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x))))))) + -0.000038)) + 0.00001879512303862185)),
2010
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.999999f * ((0.999947f * cosf((1023.994f * expf(fmaxf(-50.0f, fminf(50.0f, (-0.28782f * x))))))) + -0.000038f)) + 0.000019f);\n}",
2011
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.999999 * ((0.999947 * torch.cos((1023.994 * torch.exp(torch.clamp((-0.28782 * x), -50.0, 50.0))))) + -0.000038)) + 0.000019)",
2012
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AhUCA2VudgNleHAAAQNlbnYDY29zAAEDAgEABwkBBXNwZWFyAAIKWgFYAEQqG0Q5/v/vP0RLd9fZkP/vP0TLoUW28/+PQERBn8iTpGvSvyAAokQAAAAAAABJwKVEAAAAAAAASUCkEACiEAGiRBgK2A5G7AO/oKJEuB45BUe18z6gCw==",
2013
+ },
2014
+ fast: {
2015
+ js: "((x) => Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x)))))))",
2016
+ eval: ((x) => Math.cos((1023.994 * Math.exp(Math.max(-50, Math.min(50, (-0.28782 * x))))))),
2017
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return cosf((1023.994f * expf(fmaxf(-50.0f, fminf(50.0f, (-0.28782f * x))))));\n}",
2018
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.cos((1023.994 * torch.exp(torch.clamp((-0.28782 * x), -50.0, 50.0))))",
2019
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AhUCA2VudgNleHAAAQNlbnYDY29zAAEDAgEABwkBBXNwZWFyAAIKMgEwAETLoUW28/+PQERBn8iTpGvSvyAAokQAAAAAAABJwKVEAAAAAAAASUCkEACiEAEL",
2020
+ },
2021
+ meta: {
2022
+ metric: 8.450097215964813e-7,
2023
+ level: 5,
2024
+ formulaCost: 8,
2025
+ exactCost: 43,
2026
+ speedupVsExact: 5.375,
2027
+ vsIterative: null,
2028
+ },
2029
+ },
2030
+ "bilateral_weight": {
2031
+ id: "bilateral_weight",
2032
+ precise: {
2033
+ js: "((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2)))))))",
2034
+ eval: ((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2))))))),
2035
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return fminf(fmaxf((expf(fmaxf(-50.0f, fminf(50.0f, (-(powf(x, 2.0f) * 50f))))) / copysignf(fmaxf(fabsf((1f + (powf(x, 2.0f) * 2f))), 1.0e-4f), (1f + (powf(x, 2.0f) * 2f)))), -1.0e4f), 1.0e4f);\n}",
2036
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (torch.exp(torch.clamp((-((x * x) * 50)), -50.0, 50.0)) / (abs((1 + ((x * x) * 2))) < 1e-4 ? 1e-4 : (1 + ((x * x) * 2))))",
2037
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNleHAAAQMCAQAHCQEFc3BlYXIAAQp9AXsAIAAgAKJEAAAAAAAASUCimkQAAAAAAABJwKVEAAAAAAAASUCkEABEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgmUQtQxzr4jYaP6VEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgpqNEAAAAAACIw8ClRAAAAAAAiMNApAs=",
2038
+ },
2039
+ fast: {
2040
+ js: "((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2)))))))",
2041
+ eval: ((x) => Math.min(1e4, Math.max(-1e4, (Math.exp(Math.max(-50, Math.min(50, (-((x) * (x) * 50)))))) / (((1 + ((x) * (x) * 2))) < 1e-4 && ((1 + ((x) * (x) * 2))) > -1e-4 ? (((1 + ((x) * (x) * 2))) >= 0 ? 1e-4 : -1e-4) : ((1 + ((x) * (x) * 2))))))),
2042
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return fminf(fmaxf((expf(fmaxf(-50.0f, fminf(50.0f, (-(powf(x, 2.0f) * 50f))))) / copysignf(fmaxf(fabsf((1f + (powf(x, 2.0f) * 2f))), 1.0e-4f), (1f + (powf(x, 2.0f) * 2f)))), -1.0e4f), 1.0e4f);\n}",
2043
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (torch.exp(torch.clamp((-((x * x) * 50)), -50.0, 50.0)) / (abs((1 + ((x * x) * 2))) < 1e-4 ? 1e-4 : (1 + ((x * x) * 2))))",
2044
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNleHAAAQMCAQAHCQEFc3BlYXIAAQp9AXsAIAAgAKJEAAAAAAAASUCimkQAAAAAAABJwKVEAAAAAAAASUCkEABEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgmUQtQxzr4jYaP6VEAAAAAAAA8D8gACAAokQAAAAAAAAAQKKgpqNEAAAAAACIw8ClRAAAAAAAiMNApAs=",
2045
+ },
2046
+ meta: {
2047
+ metric: 9.336399957342636e-35,
2048
+ level: 5,
2049
+ formulaCost: 11,
2050
+ exactCost: 45,
2051
+ speedupVsExact: 4.090909090909091,
2052
+ vsIterative: null,
2053
+ },
2054
+ },
2055
+ "bs_d1_sigma": {
2056
+ id: "bs_d1_sigma",
2057
+ precise: {
2058
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((Math.abs(x)) < 1e-4 && (Math.abs(x)) > -1e-4 ? ((Math.abs(x)) >= 0 ? 1e-4 : -1e-4) : (Math.abs(x))))) + (0.25 * Math.abs(x))))",
2059
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((Math.abs(x)) < 1e-4 && (Math.abs(x)) > -1e-4 ? ((Math.abs(x)) >= 0 ? 1e-4 : -1e-4) : (Math.abs(x))))) + (0.25 * Math.abs(x)))),
2060
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((0.21562f / copysignf(fmaxf(fabsf(fabsf(x)), 1.0e-4f), fabsf(x))), -1.0e4f), 1.0e4f) + (0.25f * fabsf(x)));\n}",
2061
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.21562 / (abs(torch.abs(x)) < 1e-4 ? 1e-4 : torch.abs(x))) + (0.25 * torch.abs(x)))",
2062
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACkIBQABEop9GrXKZyz8gAJmZRC1DHOviNho/pSAAmaajRAAAAAAAiMPApUQAAAAAAIjDQKREAAAAAAAA0D8gAJmioAs=",
2063
+ },
2064
+ fast: {
2065
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (3.635301) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (4.215319 * x)))",
2066
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (3.635301) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (4.215319 * x))),
2067
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((3.635301f / copysignf(fmaxf(fabsf(x), 1.0e-4f), x)), -1.0e4f), 1.0e4f) + (4.215319f * x));\n}",
2068
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((3.635301 / (abs(x) < 1e-4 ? 1e-4 : x)) + (4.215319 * x))",
2069
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACj8BPQBExO3QsBgVDUAgAJlELUMc6+I2Gj+lIACmo0QAAAAAAIjDwKVEAAAAAACIw0CkRGfUfJV83BBAIACioAs=",
2070
+ },
2071
+ meta: {
2072
+ metric: 1.6217711315014304e-18,
2073
+ level: 5,
2074
+ formulaCost: 8,
2075
+ exactCost: 9,
2076
+ speedupVsExact: 1.125,
2077
+ vsIterative: null,
2078
+ },
2079
+ },
2080
+ "mel_scale": {
2081
+ id: "mel_scale",
2082
+ precise: {
2083
+ js: "((x) => (1126.994181 * Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286))))))",
2084
+ eval: ((x) => (1126.994181 * Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286)))))),
2085
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (1126.994181f * logf(fmaxf(1.0e-30f, (1f + (x * 0.001429f)))));\n}",
2086
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return (1126.994181 * torch.log(torch.clamp((1 + (x * 0.001429)), min=1e-30)))",
2087
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQowAS4ARDiFlQr6m5FARAAAAAAAAPA/IABEsak05NxnVz+ioESgwuv+S0i0OaUQAKIL",
2088
+ },
2089
+ fast: {
2090
+ js: "((x) => Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286)))))",
2091
+ eval: ((x) => Math.log(Math.max(1e-30, (1 + (x * 0.0014285714285714286))))),
2092
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return logf(fmaxf(1.0e-30f, (1f + (x * 0.001429f))));\n}",
2093
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return torch.log(torch.clamp((1 + (x * 0.001429)), min=1e-30))",
2094
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQomASQARAAAAAAAAPA/IABEsak05NxnVz+ioESgwuv+S0i0OaUQAAs=",
2095
+ },
2096
+ meta: {
2097
+ metric: 1.4594066099947563e-12,
2098
+ level: 5,
2099
+ formulaCost: 4,
2100
+ exactCost: 23,
2101
+ speedupVsExact: 5.75,
2102
+ vsIterative: null,
2103
+ },
2104
+ },
2105
+ "bs_d2_sigma": {
2106
+ id: "bs_d2_sigma",
2107
+ precise: {
2108
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x))))",
2109
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x)))),
2110
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((0.21562f / copysignf(fmaxf(fabsf(x), 1.0e-4f), x)), -1.0e4f), 1.0e4f) + (-(0.25f * x)));\n}",
2111
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.21562 / (abs(x) < 1e-4 ? 1e-4 : x)) + (-(0.25 * x)))",
2112
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACkABPgBEop9GrXKZyz8gAJlELUMc6+I2Gj+lIACmo0QAAAAAAIjDwKVEAAAAAACIw0CkRAAAAAAAANA/IACimqAL",
2113
+ },
2114
+ fast: {
2115
+ js: "((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x))))",
2116
+ eval: ((x) => (Math.min(1e4, Math.max(-1e4, (0.21562036) / ((x) < 1e-4 && (x) > -1e-4 ? ((x) >= 0 ? 1e-4 : -1e-4) : (x)))) + (-(0.25 * x)))),
2117
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return (fminf(fmaxf((0.21562f / copysignf(fmaxf(fabsf(x), 1.0e-4f), x)), -1.0e4f), 1.0e4f) + (-(0.25f * x)));\n}",
2118
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.21562 / (abs(x) < 1e-4 ? 1e-4 : x)) + (-(0.25 * x)))",
2119
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AwIBAAcJAQVzcGVhcgAACkABPgBEop9GrXKZyz8gAJlELUMc6+I2Gj+lIACmo0QAAAAAAIjDwKVEAAAAAACIw0CkRAAAAAAAANA/IACimqAL",
2120
+ },
2121
+ meta: {
2122
+ metric: 1.6217711130493227e-18,
2123
+ level: 5,
2124
+ formulaCost: 7,
2125
+ exactCost: 11,
2126
+ speedupVsExact: 1.5714285714285714,
2127
+ vsIterative: null,
2128
+ },
2129
+ },
2130
+ "a_weighting": {
2131
+ id: "a_weighting",
2132
+ precise: {
2133
+ js: "((x) => ((0.9803615530479888 * ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2)) + 0.039276893904016105))",
2134
+ eval: ((x) => ((0.9803615530479888 * ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2)) + 0.039276893904016105)),
2135
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((0.980362f * ((8.859884f * logf(fmaxf(1.0e-30f, fminf(fmaxf((((148691236f * powf(x, 2.0f)) * powf(x, 2.0f)) / copysignf(fmaxf(fabsf(((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f)))), 1.0e-4f), ((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f))))), -1.0e4f), 1.0e4f)))) + 2f)) + 0.039277f);\n}",
2136
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((0.980362 * ((8.859884 * torch.log(torch.clamp((((148691236 * (x * x)) * (x * x)) / (abs((((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236)))) < 1e-4 ? 1e-4 : (((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236))))), min=1e-30))) + 2)) + 0.039277)",
2137
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQrxAQHuAQBEphkTMR9f7z9EE7U0t0K4IUBEAAAASLK5oUEgACAAoqIgACAAoqIgACAAokT2KFyPwoV6QKAgACAAokTsUbgepafGQKAgACAAokQfhevR4J0gQaCimZ8gACAAokQAAABIsrmhQaCioplELUMc6+I2Gj+lIAAgAKJE9ihcj8KFekCgIAAgAKJE7FG4HqWnxkCgIAAgAKJEH4Xr0eCdIEGgopmfIAAgAKJEAAAASLK5oUGgoqKmo0QAAAAAAIjDwKVEAAAAAACIw0CkRKDC6/5LSLQ5pRAAokQAAAAAAAAAQKCiRK7HnN0ZHKQ/oAs=",
2138
+ },
2139
+ fast: {
2140
+ js: "((x) => ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2))",
2141
+ eval: ((x) => ((8.859884 * Math.log(Math.max(1e-30, Math.min(1e4, Math.max(-1e4, (((148691236 * (x) * (x)) * (x) * (x))) / (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) < 1e-4 && ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) > -1e-4 ? (((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))) >= 0 ? 1e-4 : -1e-4) : ((((x) * (x) + 424.36) * (Math.sqrt(Math.abs((((x) * (x) + 11599.29) * ((x) * (x) + 544496.41)))) * ((x) * (x) + 148691236)))))))))) + 2)),
2142
+ c: "// Evolved by SPEAR — algebraic only, FP16 safe\n__device__ inline float spear_fn(const float x) {\n return ((8.859884f * logf(fmaxf(1.0e-30f, fminf(fmaxf((((148691236f * powf(x, 2.0f)) * powf(x, 2.0f)) / copysignf(fmaxf(fabsf(((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f)))), 1.0e-4f), ((powf(x, 2.0f) + 424.36f) * (sqrtf(fabsf(((powf(x, 2.0f) + 11599.29f) * (powf(x, 2.0f) + 544496.41f)))) * (powf(x, 2.0f) + 148691236f))))), -1.0e4f), 1.0e4f)))) + 2f);\n}",
2143
+ py: "import torch\n\ndef spear_fn(x):\n # Evolved by SPEAR — zero transcendental ops (exp/erf/tanh free)\n return ((8.859884 * torch.log(torch.clamp((((148691236 * (x * x)) * (x * x)) / (abs((((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236)))) < 1e-4 ? 1e-4 : (((x * x) + 424.36) * (torch.sqrt(torch.abs((((x * x) + 11599.29) * ((x * x) + 544496.41)))) * ((x * x) + 148691236))))), min=1e-30))) + 2)",
2144
+ wasmBase64: "AGFzbQEAAAABCwJgAXwBfGABfAF8AgsBA2VudgNsb2cAAQMCAQAHCQEFc3BlYXIAAQrdAQHaAQBEE7U0t0K4IUBEAAAASLK5oUEgACAAoqIgACAAoqIgACAAokT2KFyPwoV6QKAgACAAokTsUbgepafGQKAgACAAokQfhevR4J0gQaCimZ8gACAAokQAAABIsrmhQaCioplELUMc6+I2Gj+lIAAgAKJE9ihcj8KFekCgIAAgAKJE7FG4HqWnxkCgIAAgAKJEH4Xr0eCdIEGgopmfIAAgAKJEAAAASLK5oUGgoqKmo0QAAAAAAIjDwKVEAAAAAACIw0CkRKDC6/5LSLQ5pRAAokQAAAAAAAAAQKAL",
2145
+ },
2146
+ meta: {
2147
+ metric: 2.7800484820648814e-29,
2148
+ level: 5,
2149
+ formulaCost: 26,
2150
+ exactCost: 55,
2151
+ speedupVsExact: 2.1153846153846154,
2152
+ vsIterative: null,
2153
+ },
2154
+ },
2005
2155
  };
2006
2156
 
2007
- export const kernelIds = ["silu","gelu","sigmoid","kv_cache","free_fall","kepler","gaussian_cdf","damped_pendulum","rl_distillation","lambert_w","rc_circuit","gaussian_kernel","diffusion_beta","bilinear_interp","european_call","temporal_grad","lorentz","hill","kerr","lennard_jones","damped_oscillation","logistic_growth","softplus","kdv_soliton","kerr_spin","pendulum_hybrid","eigen3_sym","ik_reach","idm_following","gemv4","rope_rot","gauss_shader","ema_smooth","smoothstep","srgb_gamma","tanh_sat","atan_unit","srgb_decode","erf_prob","huber_loss","cosh_curve","bessel_j0","bessel_j1","blackbody_r","aces_fit","logsumexp2","probit_quantile","pmt_finance","blackbody_g","blackbody_b","bessel_j2","logit_ml","kelly_criterion","rsi_momentum","implied_vol","michaelis_menten","temperature_softmax","doppler_effect","stefan_boltzmann","mm1_queue_wait","grover_amplitude","concurrence_pure","chsh_correlation","legendre_p2","laguerre_l2","asin_hard","qfi_dephasing","amp_damp_fid","loschmidt_rate","bessel_i0e","elliptic_k","kepler_solver","fast_exp_alu","fresnel_schlick","rayleigh_phase","smootherstep","fog_exp2","back_ease_out","light_falloff_punctual","bias_slope","uncharted2_tonemap","mish"];
2157
+ export const kernelIds = ["silu","gelu","sigmoid","kv_cache","free_fall","kepler","gaussian_cdf","damped_pendulum","rl_distillation","lambert_w","rc_circuit","gaussian_kernel","diffusion_beta","bilinear_interp","european_call","temporal_grad","lorentz","hill","kerr","lennard_jones","damped_oscillation","logistic_growth","softplus","kdv_soliton","kerr_spin","pendulum_hybrid","eigen3_sym","ik_reach","idm_following","gemv4","rope_rot","gauss_shader","ema_smooth","smoothstep","srgb_gamma","tanh_sat","atan_unit","srgb_decode","erf_prob","huber_loss","cosh_curve","bessel_j0","bessel_j1","blackbody_r","aces_fit","logsumexp2","probit_quantile","pmt_finance","blackbody_g","blackbody_b","bessel_j2","logit_ml","kelly_criterion","rsi_momentum","implied_vol","michaelis_menten","temperature_softmax","doppler_effect","stefan_boltzmann","mm1_queue_wait","grover_amplitude","concurrence_pure","chsh_correlation","legendre_p2","laguerre_l2","asin_hard","qfi_dephasing","amp_damp_fid","loschmidt_rate","bessel_i0e","elliptic_k","kepler_solver","fast_exp_alu","fresnel_schlick","rayleigh_phase","smootherstep","fog_exp2","back_ease_out","light_falloff_punctual","bias_slope","uncharted2_tonemap","mish","rope_freq","bilateral_weight","bs_d1_sigma","mel_scale","bs_d2_sigma","a_weighting"];
2008
2158
 
2009
2159
  export default kernels;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spear-kernels",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Closed-form kernels discovered by the SPEAR symbolic regression engine, shipped as JS, CUDA C, PyTorch and WebAssembly.",
5
5
  "license": "MIT",
6
6
  "type": "module",