Skip to content

Quantized dot product

How much work does it take to multiply by a row of two-bit weights? Quantize the row once, then score the same packed bytes three ways. Quantization changes the answer once. The choice of scoring loop changes the time and temporary storage.

How much work does it take to multiply by a row of two-bit weights? Quantize the row once, then score the same packed bytes three ways. Quantization changes the answer once. The choice of scoring loop changes the time and temporary storage.

Scoring 65,539 two-bit weights took 64.7 µs directly from packed bytes and 162.6 µs with per-call expansion

  • knotkit/prng: Generates seeded pseudorandom numbers and unbiased integers for reproducible simulations and tests
  • knotkit/errors: Provides the base error classes every Knotkit package throws from, discriminated by package, category, and cause
{"v":1,"box":[110.0868,94.1597,815.7333,444.3555],"x":{"s":"linear","lim":[-1.09,1.09],"inv":false,"g":0,"t":"Float32 weight","tk":[[-1,"−1.00"],[-0.5,"−0.50"],[0,"0.00"],[0.5,"+0.50"],[1,"+1.00"]]},"y":{"s":"linear","lim":[-1.09,1.09],"inv":false,"g":0,"tk":[[-0.75,"−0.75 (00)"],[-0.25,"−0.25 (01)"],[0.25,"+0.25 (10)"],[0.75,"+0.75 (11)"]]},"ti":"Each weight snaps to one of 4 levels; all four fit byte 0xe4","a":[{"k":"line","c":"#c4501b","s":"x","d":[-1,-0.75,-0.99,-0.75,-0.98,-0.75,-0.97,-0.75,-0.96,-0.75,-0.95,-0.75,-0.94,-0.75,-0.93,-0.75,-0.92,-0.75,-0.91,-0.75,-0.9,-0.75,-0.89,-0.75,-0.88,-0.75,-0.87,-0.75,-0.86,-0.75,-0.85,-0.75,-0.84,-0.75,-0.83,-0.75,-0.82,-0.75,-0.81,-0.75,-0.8,-0.75,-0.79,-0.75,-0.78,-0.75,-0.77,-0.75,-0.76,-0.75,-0.75,-0.75,-0.74,-0.75,-0.73,-0.75,-0.72,-0.75,-0.71,-0.75,-0.7,-0.75,-0.69,-0.75,-0.68,-0.75,-0.67,-0.75,-0.66,-0.75,-0.65,-0.75,-0.64,-0.75,-0.63,-0.75,-0.62,-0.75,-0.61,-0.75,-0.6,-0.75,-0.59,-0.75,-0.58,-0.75,-0.57,-0.75,-0.56,-0.75,-0.55,-0.75,-0.54,-0.75,-0.53,-0.75,-0.52,-0.75,-0.51,-0.75,-0.5,-0.75,-0.49,-0.25,-0.48,-0.25,-0.47,-0.25,-0.46,-0.25,-0.45,-0.25,-0.44,-0.25,-0.43,-0.25,-0.42,-0.25,-0.41,-0.25,-0.4,-0.25,-0.39,-0.25,-0.38,-0.25,-0.37,-0.25,-0.36,-0.25,-0.35,-0.25,-0.34,-0.25,-0.33,-0.25,-0.32,-0.25,-0.31,-0.25,-0.3,-0.25,-0.29,-0.25,-0.28,-0.25,-0.27,-0.25,-0.26,-0.25,-0.25,-0.25,-0.24,-0.25,-0.23,-0.25,-0.22,-0.25,-0.21,-0.25,-0.2,-0.25,-0.19,-0.25,-0.18,-0.25,-0.17,-0.25,-0.16,-0.25,-0.15,-0.25,-0.14,-0.25,-0.13,-0.25,-0.12,-0.25,-0.11,-0.25,-0.1,-0.25,-0.09,-0.25,-0.08,-0.25,-0.07,-0.25,-0.06,-0.25,-0.05,-0.25,-0.04,-0.25,-0.03,-0.25,-0.02,-0.25,-0.01,-0.25,0,0.25,0.01,0.25,0.02,0.25,0.03,0.25,0.04,0.25,0.05,0.25,0.06,0.25,0.07,0.25,0.08,0.25,0.09,0.25,0.1,0.25,0.11,0.25,0.12,0.25,0.13,0.25,0.14,0.25,0.15,0.25,0.16,0.25,0.17,0.25,0.18,0.25,0.19,0.25,0.2,0.25,0.21,0.25,0.22,0.25,0.23,0.25,0.24,0.25,0.25,0.25,0.26,0.25,0.27,0.25,0.28,0.25,0.29,0.25,0.3,0.25,0.31,0.25,0.32,0.25,0.33,0.25,0.34,0.25,0.35,0.25,0.36,0.25,0.37,0.25,0.38,0.25,0.39,0.25,0.4,0.25,0.41,0.25,0.42,0.25,0.43,0.25,0.44,0.25,0.45,0.25,0.46,0.25,0.47,0.25,0.48,0.25,0.49,0.25,0.5,0.25,0.51,0.75,0.52,0.75,0.53,0.75,0.54,0.75,0.55,0.75,0.56,0.75,0.57,0.75,0.58,0.75,0.59,0.75,0.6,0.75,0.61,0.75,0.62,0.75,0.63,0.75,0.64,0.75,0.65,0.75,0.66,0.75,0.67,0.75,0.68,0.75,0.69,0.75,0.7,0.75,0.71,0.75,0.72,0.75,0.73,0.75,0.74,0.75,0.75,0.75,0.76,0.75,0.77,0.75,0.78,0.75,0.79,0.75,0.8,0.75,0.81,0.75,0.82,0.75,0.83,0.75,0.84,0.75,0.85,0.75,0.86,0.75,0.87,0.75,0.88,0.75,0.89,0.75,0.9,0.75,0.91,0.75,0.92,0.75,0.93,0.75,0.94,0.75,0.95,0.75,0.96,0.75,0.97,0.75,0.98,0.75,0.99,0.75,1,0.75],"p":[139.22,389.74,142.46,389.74,145.69,389.74,148.93,389.74,152.17,389.74,155.4,389.74,158.64,389.74,161.88,389.74,165.11,389.74,168.35,389.74,171.59,389.74,174.83,389.74,178.06,389.74,181.3,389.74,184.54,389.74,187.77,389.74,191.01,389.74,194.25,389.74,197.48,389.74,200.72,389.74,203.96,389.74,207.19,389.74,210.43,389.74,213.67,389.74,216.9,389.74,220.14,389.74,223.38,389.74,226.62,389.74,229.85,389.74,233.09,389.74,236.33,389.74,239.56,389.74,242.8,389.74,246.04,389.74,249.27,389.74,252.51,389.74,255.75,389.74,258.98,389.74,262.22,389.74,265.46,389.74,268.7,389.74,271.93,389.74,275.17,389.74,278.41,389.74,281.64,389.74,284.88,389.74,288.12,389.74,291.35,389.74,294.59,389.74,297.83,389.74,301.06,389.74,304.3,309.42,307.54,309.42,310.78,309.42,314.01,309.42,317.25,309.42,320.49,309.42,323.72,309.42,326.96,309.42,330.2,309.42,333.43,309.42,336.67,309.42,339.91,309.42,343.14,309.42,346.38,309.42,349.62,309.42,352.86,309.42,356.09,309.42,359.33,309.42,362.57,309.42,365.8,309.42,369.04,309.42,372.28,309.42,375.51,309.42,378.75,309.42,381.99,309.42,385.22,309.42,388.46,309.42,391.7,309.42,394.93,309.42,398.17,309.42,401.41,309.42,404.65,309.42,407.88,309.42,411.12,309.42,414.36,309.42,417.59,309.42,420.83,309.42,424.07,309.42,427.3,309.42,430.54,309.42,433.78,309.42,437.01,309.42,440.25,309.42,443.49,309.42,446.73,309.42,449.96,309.42,453.2,309.42,456.44,309.42,459.67,309.42,462.91,229.1,466.15,229.1,469.38,229.1,472.62,229.1,475.86,229.1,479.09,229.1,482.33,229.1,485.57,229.1,488.81,229.1,492.04,229.1,495.28,229.1,498.52,229.1,501.75,229.1,504.99,229.1,508.23,229.1,511.46,229.1,514.7,229.1,517.94,229.1,521.17,229.1,524.41,229.1,527.65,229.1,530.89,229.1,534.12,229.1,537.36,229.1,540.6,229.1,543.83,229.1,547.07,229.1,550.31,229.1,553.54,229.1,556.78,229.1,560.02,229.1,563.25,229.1,566.49,229.1,569.73,229.1,572.97,229.1,576.2,229.1,579.44,229.1,582.68,229.1,585.91,229.1,589.15,229.1,592.39,229.1,595.62,229.1,598.86,229.1,602.1,229.1,605.33,229.1,608.57,229.1,611.81,229.1,615.04,229.1,618.28,229.1,621.52,229.1,624.76,229.1,627.99,148.78,631.23,148.78,634.47,148.78,637.7,148.78,640.94,148.78,644.18,148.78,647.41,148.78,650.65,148.78,653.89,148.78,657.12,148.78,660.36,148.78,663.6,148.78,666.84,148.78,670.07,148.78,673.31,148.78,676.55,148.78,679.78,148.78,683.02,148.78,686.26,148.78,689.49,148.78,692.73,148.78,695.97,148.78,699.2,148.78,702.44,148.78,705.68,148.78,708.92,148.78,712.15,148.78,715.39,148.78,718.63,148.78,721.86,148.78,725.1,148.78,728.34,148.78,731.57,148.78,734.81,148.78,738.05,148.78,741.28,148.78,744.52,148.78,747.76,148.78,751,148.78,754.23,148.78,757.47,148.78,760.71,148.78,763.94,148.78,767.18,148.78,770.42,148.78,773.65,148.78,776.89,148.78,780.13,148.78,783.36,148.78,786.6,148.78],"ds":"post"},{"k":"scatter","c":"#1d5fa6","s":"xy","d":[-0.899999976158,-0.75,-0.300000011921,-0.25,0.10000000149,0.25,0.800000011921,0.75],"p":[171.59,389.74,365.8,309.42,495.28,229.1,721.86,148.78],"r":4.96},{"k":"segments","c":"#8c8c84"},{"k":"segments","c":"#8c8c84"},{"k":"fill","c":"#5b6b7c"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#5c5c57"},{"k":"annotation","c":"#c4501b"},{"k":"annotation","c":"#1d5fa6"},{"k":"annotation","c":"#5b6b7c"}],"lg":[]} −1.00 −0.50 0.00 +0.50 +1.00 Float32 weight −0.75 (00) −0.25 (01) +0.25 (10) +0.75 (11) −0.9 → 00 −0.3 → 01 +0.1 → 10 +0.8 → 11 Two-bit reconstruction (code) Rounding rule The four weights Rounding error Each weight snaps to one of 4 levels; all four fit byte 0xe4 {"v":1,"box":[110.0868,605.1597,815.7333,955.3555],"x":{"s":"linear","lim":[-0.18,4.18],"inv":false,"g":1,"t":"Weights accumulated","tk":[[0,"0"],[1,"1"],[2,"2"],[3,"3"],[4,"4"]]},"y":{"s":"linear","lim":[-1.89224995017,0.342249997854],"inv":false,"g":1,"tk":[[-1.79999995232,"−1.80"],[-1,"−1.00"],[0,"0"],[0.25,"+0.25"]]},"ti":"Rounding flips the sign: −0.40 becomes +0.25","a":[{"k":"line","c":"#fffff8","s":"x","d":[0,0,1,-1.79999995232,2,-1.4999999404,3,-1.19999993593,4,-0.399999924004],"p":[139.22,658.8,301.06,940.9,462.91,893.88,624.76,846.86,786.6,721.49]},{"k":"line","c":"#5b6b7c","s":"x","d":[0,0,1,-1.79999995232,2,-1.4999999404,3,-1.19999993593,4,-0.399999924004],"p":[139.22,658.8,301.06,940.9,462.91,893.88,624.76,846.86,786.6,721.49]},{"k":"line","c":"#fffff8","s":"x","d":[0,0,1,-1.5,2,-1.25,3,-0.5,4,0.25],"p":[139.22,658.8,301.06,893.88,462.91,854.7,624.76,737.16,786.6,619.62]},{"k":"line","c":"#c4501b","s":"x","d":[0,0,1,-1.5,2,-1.25,3,-0.5,4,0.25],"p":[139.22,658.8,301.06,893.88,462.91,854.7,624.76,737.16,786.6,619.62]},{"k":"segments","c":"#8c8c84"},{"k":"segments","c":"#8c8c84"},{"k":"line","c":"#8c8c84"},{"k":"annotation","c":"#5c5c57"},{"k":"annotation","c":"#5b6b7c"},{"k":"annotation","c":"#c4501b"}],"lg":[]} 0 1 2 3 4 Weights accumulated −1.80 −1.00 0 +0.25 Running dot product Original weights −0.40 Packed weights +0.25 Rounding flips the sign: −0.40 becomes +0.25
{"v":1,"box":[110.0868,122.3921,366.0206,444.3555],"x":{"s":"linear","lim":[-1.09,1.09],"inv":false,"g":0,"t":"Float32 weight","tk":[[-1,"−1.00"],[-0.5,"−0.50"],[0,"0.00"],[0.5,"+0.50"],[1,"+1.00"]]},"y":{"s":"linear","lim":[-1.09,1.09],"inv":false,"g":0,"tk":[[-0.75,"−0.75 (00)"],[-0.25,"−0.25 (01)"],[0.25,"+0.25 (10)"],[0.75,"+0.75 (11)"]]},"ti":"Each weight snaps to one of 4 levels; all\nfour fit byte 0xe4","a":[{"k":"line","c":"#c4501b","s":"x","d":[-1,-0.75,-0.99,-0.75,-0.98,-0.75,-0.97,-0.75,-0.96,-0.75,-0.95,-0.75,-0.94,-0.75,-0.93,-0.75,-0.92,-0.75,-0.91,-0.75,-0.9,-0.75,-0.89,-0.75,-0.88,-0.75,-0.87,-0.75,-0.86,-0.75,-0.85,-0.75,-0.84,-0.75,-0.83,-0.75,-0.82,-0.75,-0.81,-0.75,-0.8,-0.75,-0.79,-0.75,-0.78,-0.75,-0.77,-0.75,-0.76,-0.75,-0.75,-0.75,-0.74,-0.75,-0.73,-0.75,-0.72,-0.75,-0.71,-0.75,-0.7,-0.75,-0.69,-0.75,-0.68,-0.75,-0.67,-0.75,-0.66,-0.75,-0.65,-0.75,-0.64,-0.75,-0.63,-0.75,-0.62,-0.75,-0.61,-0.75,-0.6,-0.75,-0.59,-0.75,-0.58,-0.75,-0.57,-0.75,-0.56,-0.75,-0.55,-0.75,-0.54,-0.75,-0.53,-0.75,-0.52,-0.75,-0.51,-0.75,-0.5,-0.75,-0.49,-0.25,-0.48,-0.25,-0.47,-0.25,-0.46,-0.25,-0.45,-0.25,-0.44,-0.25,-0.43,-0.25,-0.42,-0.25,-0.41,-0.25,-0.4,-0.25,-0.39,-0.25,-0.38,-0.25,-0.37,-0.25,-0.36,-0.25,-0.35,-0.25,-0.34,-0.25,-0.33,-0.25,-0.32,-0.25,-0.31,-0.25,-0.3,-0.25,-0.29,-0.25,-0.28,-0.25,-0.27,-0.25,-0.26,-0.25,-0.25,-0.25,-0.24,-0.25,-0.23,-0.25,-0.22,-0.25,-0.21,-0.25,-0.2,-0.25,-0.19,-0.25,-0.18,-0.25,-0.17,-0.25,-0.16,-0.25,-0.15,-0.25,-0.14,-0.25,-0.13,-0.25,-0.12,-0.25,-0.11,-0.25,-0.1,-0.25,-0.09,-0.25,-0.08,-0.25,-0.07,-0.25,-0.06,-0.25,-0.05,-0.25,-0.04,-0.25,-0.03,-0.25,-0.02,-0.25,-0.01,-0.25,0,0.25,0.01,0.25,0.02,0.25,0.03,0.25,0.04,0.25,0.05,0.25,0.06,0.25,0.07,0.25,0.08,0.25,0.09,0.25,0.1,0.25,0.11,0.25,0.12,0.25,0.13,0.25,0.14,0.25,0.15,0.25,0.16,0.25,0.17,0.25,0.18,0.25,0.19,0.25,0.2,0.25,0.21,0.25,0.22,0.25,0.23,0.25,0.24,0.25,0.25,0.25,0.26,0.25,0.27,0.25,0.28,0.25,0.29,0.25,0.3,0.25,0.31,0.25,0.32,0.25,0.33,0.25,0.34,0.25,0.35,0.25,0.36,0.25,0.37,0.25,0.38,0.25,0.39,0.25,0.4,0.25,0.41,0.25,0.42,0.25,0.43,0.25,0.44,0.25,0.45,0.25,0.46,0.25,0.47,0.25,0.48,0.25,0.49,0.25,0.5,0.25,0.51,0.75,0.52,0.75,0.53,0.75,0.54,0.75,0.55,0.75,0.56,0.75,0.57,0.75,0.58,0.75,0.59,0.75,0.6,0.75,0.61,0.75,0.62,0.75,0.63,0.75,0.64,0.75,0.65,0.75,0.66,0.75,0.67,0.75,0.68,0.75,0.69,0.75,0.7,0.75,0.71,0.75,0.72,0.75,0.73,0.75,0.74,0.75,0.75,0.75,0.76,0.75,0.77,0.75,0.78,0.75,0.79,0.75,0.8,0.75,0.81,0.75,0.82,0.75,0.83,0.75,0.84,0.75,0.85,0.75,0.86,0.75,0.87,0.75,0.88,0.75,0.89,0.75,0.9,0.75,0.91,0.75,0.92,0.75,0.93,0.75,0.94,0.75,0.95,0.75,0.96,0.75,0.97,0.75,0.98,0.75,0.99,0.75,1,0.75],"p":[120.65,394.14,121.83,394.14,123,394.14,124.17,394.14,125.35,394.14,126.52,394.14,127.7,394.14,128.87,394.14,130.04,394.14,131.22,394.14,132.39,394.14,133.57,394.14,134.74,394.14,135.91,394.14,137.09,394.14,138.26,394.14,139.44,394.14,140.61,394.14,141.79,394.14,142.96,394.14,144.13,394.14,145.31,394.14,146.48,394.14,147.66,394.14,148.83,394.14,150,394.14,151.18,394.14,152.35,394.14,153.53,394.14,154.7,394.14,155.87,394.14,157.05,394.14,158.22,394.14,159.4,394.14,160.57,394.14,161.74,394.14,162.92,394.14,164.09,394.14,165.27,394.14,166.44,394.14,167.61,394.14,168.79,394.14,169.96,394.14,171.14,394.14,172.31,394.14,173.48,394.14,174.66,394.14,175.83,394.14,177.01,394.14,178.18,394.14,179.35,394.14,180.53,320.3,181.7,320.3,182.88,320.3,184.05,320.3,185.22,320.3,186.4,320.3,187.57,320.3,188.75,320.3,189.92,320.3,191.09,320.3,192.27,320.3,193.44,320.3,194.62,320.3,195.79,320.3,196.96,320.3,198.14,320.3,199.31,320.3,200.49,320.3,201.66,320.3,202.83,320.3,204.01,320.3,205.18,320.3,206.36,320.3,207.53,320.3,208.7,320.3,209.88,320.3,211.05,320.3,212.23,320.3,213.4,320.3,214.57,320.3,215.75,320.3,216.92,320.3,218.1,320.3,219.27,320.3,220.44,320.3,221.62,320.3,222.79,320.3,223.97,320.3,225.14,320.3,226.31,320.3,227.49,320.3,228.66,320.3,229.84,320.3,231.01,320.3,232.18,320.3,233.36,320.3,234.53,320.3,235.71,320.3,236.88,320.3,238.05,246.45,239.23,246.45,240.4,246.45,241.58,246.45,242.75,246.45,243.92,246.45,245.1,246.45,246.27,246.45,247.45,246.45,248.62,246.45,249.79,246.45,250.97,246.45,252.14,246.45,253.32,246.45,254.49,246.45,255.66,246.45,256.84,246.45,258.01,246.45,259.19,246.45,260.36,246.45,261.53,246.45,262.71,246.45,263.88,246.45,265.06,246.45,266.23,246.45,267.4,246.45,268.58,246.45,269.75,246.45,270.93,246.45,272.1,246.45,273.27,246.45,274.45,246.45,275.62,246.45,276.8,246.45,277.97,246.45,279.14,246.45,280.32,246.45,281.49,246.45,282.67,246.45,283.84,246.45,285.01,246.45,286.19,246.45,287.36,246.45,288.54,246.45,289.71,246.45,290.88,246.45,292.06,246.45,293.23,246.45,294.41,246.45,295.58,246.45,296.75,246.45,297.93,172.61,299.1,172.61,300.28,172.61,301.45,172.61,302.62,172.61,303.8,172.61,304.97,172.61,306.15,172.61,307.32,172.61,308.49,172.61,309.67,172.61,310.84,172.61,312.02,172.61,313.19,172.61,314.36,172.61,315.54,172.61,316.71,172.61,317.89,172.61,319.06,172.61,320.23,172.61,321.41,172.61,322.58,172.61,323.76,172.61,324.93,172.61,326.1,172.61,327.28,172.61,328.45,172.61,329.63,172.61,330.8,172.61,331.97,172.61,333.15,172.61,334.32,172.61,335.5,172.61,336.67,172.61,337.84,172.61,339.02,172.61,340.19,172.61,341.37,172.61,342.54,172.61,343.71,172.61,344.89,172.61,346.06,172.61,347.24,172.61,348.41,172.61,349.58,172.61,350.76,172.61,351.93,172.61,353.11,172.61,354.28,172.61,355.45,172.61],"ds":"post"},{"k":"scatter","c":"#1d5fa6","s":"xy","d":[-0.899999976158,-0.75,-0.300000011921,-0.25,0.10000000149,0.25,0.800000011921,0.75],"p":[132.39,394.14,202.83,320.3,249.79,246.45,331.97,172.61],"r":4.96},{"k":"segments","c":"#8c8c84"},{"k":"segments","c":"#8c8c84"},{"k":"fill","c":"#5b6b7c"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#2b2b28"},{"k":"annotation","c":"#5c5c57"},{"k":"annotation","c":"#c4501b"},{"k":"annotation","c":"#1d5fa6"},{"k":"annotation","c":"#5b6b7c"}],"lg":[]} −1.00 −0.50 0.00 +0.50 +1.00 Float32 weight −0.75 (00) −0.25 (01) +0.25 (10) +0.75 (11) −0.9 → 00 −0.3 → 01 +0.1 → 10 +0.8 → 11 Two-bit reconstruction (code) Rounding rule The four weights Rounding error Each weight snaps to one of 4 levels; all four fit byte 0xe4 {"v":1,"box":[110.0868,633.3921,366.0206,955.3555],"x":{"s":"linear","lim":[-0.18,4.18],"inv":false,"g":1,"t":"Weights accumulated","tk":[[0,"0"],[1,"1"],[2,"2"],[3,"3"],[4,"4"]]},"y":{"s":"linear","lim":[-1.89224995017,0.342249997854],"inv":false,"g":1,"tk":[[-1.79999995232,"−1.80"],[-1,"−1.00"],[0,"0"],[0.25,"+0.25"]]},"ti":"Rounding flips the sign: −0.40 becomes\n+0.25","a":[{"k":"line","c":"#fffff8","s":"x","d":[0,0,1,-1.79999995232,2,-1.4999999404,3,-1.19999993593,4,-0.399999924004],"p":[120.65,682.71,179.35,942.06,238.05,898.84,296.75,855.61,355.45,740.34]},{"k":"line","c":"#5b6b7c","s":"x","d":[0,0,1,-1.79999995232,2,-1.4999999404,3,-1.19999993593,4,-0.399999924004],"p":[120.65,682.71,179.35,942.06,238.05,898.84,296.75,855.61,355.45,740.34]},{"k":"line","c":"#fffff8","s":"x","d":[0,0,1,-1.5,2,-1.25,3,-0.5,4,0.25],"p":[120.65,682.71,179.35,898.84,238.05,862.82,296.75,754.75,355.45,646.68]},{"k":"line","c":"#c4501b","s":"x","d":[0,0,1,-1.5,2,-1.25,3,-0.5,4,0.25],"p":[120.65,682.71,179.35,898.84,238.05,862.82,296.75,754.75,355.45,646.68]},{"k":"segments","c":"#8c8c84"},{"k":"segments","c":"#8c8c84"},{"k":"line","c":"#8c8c84"},{"k":"annotation","c":"#5c5c57"},{"k":"annotation","c":"#5b6b7c"},{"k":"annotation","c":"#c4501b"}],"lg":[]} 0 1 2 3 4 Weights accumulated −1.80 −1.00 0 +0.25 Running dot product Original weights −0.40 Packed weights +0.25 Rounding flips the sign: −0.40 becomes +0.25
  • Four Float32 weights (16 bytes) pack into 1 byte, 0xe4.
  • Reconstructed weights in input order: -0.75, -0.25, 0.25, 0.75.
  • With activations [2, -1, 3, 1], the dot product changes from -0.40 to 0.25.
  • Expanded, scalar and grouped scoring give 0.25, 0.25, 0.25.

Hover or focus a chart for exact values. Drawn by demo.ts at build time, from the fixtures the benchmark uses; it reproduces the README figure.

Terminal window
git clone https://github.com/jkomyno/knotkit.git && cd knotkit && bun install
bun run demo:problem:quantized-dot-product

problems/quantized-dot-product/README.md states the fixture, the seed, and the result table.