interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / workloads / quant_int8 / workload.json

108 lines · 2449 bytes Raw Blame History
1{
2 "name": "quant_int8",
3 "family": "quantization",
4 "summary": "per-row symmetric int8 quantization of an R x C f32 matrix: s[r] = max_c |x[r][c]| / 127 (f32), q[r][c] = clamp(round_half_even(x[r][c] / s[r]), -127, 127) (i8); a zero row gives s = 0 and q = 0",
5 "provenance": "authored for OpenAccel Lab (Apache-2.0); the per-row absmax scheme of LLM.int8()-style weight quantization",
6 "params": {
7 "R": 32,
8 "C": 256
9 },
10 "cases": [
11 {},
12 {
13 "R": 1,
14 "C": 1
15 },
16 {
17 "R": 5,
18 "C": 77
19 }
20 ],
21 "shrink": {
22 "R": {
23 "min": 1
24 },
25 "C": {
26 "min": 1
27 }
28 },
29 "inputs": [
30 {
31 "name": "x",
32 "dtype": "f32",
33 "shape": [
34 "R",
35 "C"
36 ],
37 "gen": {
38 "kind": "normal4",
39 "mean": 0.0,
40 "std": 1.5
41 }
42 }
43 ],
44 "outputs": [
45 {
46 "name": "q",
47 "dtype": "i8",
48 "shape": [
49 "R",
50 "C"
51 ]
52 },
53 {
54 "name": "s",
55 "dtype": "f32",
56 "shape": [
57 "R"
58 ]
59 }
60 ],
61 "tolerance": {
62 "q": {
63 "kind": "int",
64 "atol": 1,
65 "why": "the reference is round_half_even(127 x / amax) on the exact values (numpy rint in float64). An entrant divides by its own f32 scale s' = (amax/127)(1+e1) and rounds y' = (x/s')(1+e2), |e1|, |e2| <= 5u (2.5 ulp, the OpenCL C single-precision divide limit without -cl-fp32-correctly-rounded-divide-sqrt; 1 ulp <= 2u relative), so |y' - y| <= |y|((1+5u)/(1-5u)^2 - 1) with |y| <= 127: WolframLanguageEvaluator: u=2^-24; N[127*((1+5u)/(1-5u)^2-1),10] -> 0.0001135469047. That is < 1/2, so the two roundings differ by at most 1 (only when y is within 1.2e-4 of a half-integer). A wrong scale (no abs, wrong divisor) or a sign error moves q by far more than 1."
66 },
67 "s": {
68 "kind": "bound",
69 "rtol": "5*u",
70 "atol": 0,
71 "why": "amax is exact (abs and max do not round); s = amax/127 is one division, correctly rounded on IEEE hosts and within 2.5 ulp under OpenCL C (s7.4) and Triton's GPU fdiv. 1 ulp <= 2u relative, so 2.5 ulp <= 5u: WolframLanguageEvaluator: u=2^-24; N[(5/2)*2^-23/u] -> 5.; N[5u,10] -> 2.980232239*10^-7."
72 }
73 },
74 "timing": {
75 "warmup": 2,
76 "repeats": 10
77 },
78 "backends": {
79 "omega": {
80 "src": "omega.om"
81 },
82 "opencl": {
83 "src": "kernel.cl",
84 "launches": [
85 {
86 "kernel": "quant_int8",
87 "global": [
88 "R"
89 ],
90 "local": null,
91 "args": [
92 "x",
93 "q",
94 "s",
95 "R",
96 "C"
97 ]
98 }
99 ]
100 },
101 "triton": {
102 "src": "triton_kernel.py"
103 },
104 "cuda": {
105 "src": "kernel.cu"
106 }
107 }
108}