Quazim0t0 commited on
Commit
0534942
·
verified ·
1 Parent(s): a879f4a

Upload web/public/webgpu.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. web/public/webgpu.js +10 -0
web/public/webgpu.js CHANGED
@@ -457,6 +457,16 @@
457
  console.warn("B2B gate: no rounding-boundary input found in 800 trials — respec discrimination unproven this boot (sweep still exact)");
458
  return null;
459
  }
 
 
 
 
 
 
 
 
 
 
460
  const lutMlpEnv = { dp4: false, gemm: bgLutPipe, rowmax: rowmaxPipe, quant: quantI32Pipe, lutBuf };
461
  let mlpLut = (xq, w1q, w2q, xs, w1s, w2s, d) => gpuMlpChain(device, lutMlpEnv, xq, w1q, w2q, xs, w1s, w2s, d);
462
  const mlpLutBad = await gateMlp(mlpLut);
 
457
  console.warn("B2B gate: no rounding-boundary input found in 800 trials — respec discrimination unproven this boot (sweep still exact)");
458
  return null;
459
  }
460
+ // FMA-contraction note for the quantize kernel: WGSL permits a compiler
461
+ // to contract `H*inv + 0.5` into a hardware FMA (e.g. RDNA2 V_FMA_F32 —
462
+ // ONE rounding instead of two). This CANNOT change the quantized int8:
463
+ // adding 0.5 is exact except at binade crossings, and there the
464
+ // double-rounding anomaly only moves the value within the same integer
465
+ // cell (the RNE tie parity resolves both schedules to the same side of
466
+ // the integer), so floor() sees no difference. Verified empirically in
467
+ // test_b2b.js: 48M draws targeted at binade edges, 1.9M last-ulp
468
+ // fused-vs-stepped differences, ZERO floor-visible. The `+0.5` respec is
469
+ // contraction-immune by construction — `round(x/scale)` was not.
470
  const lutMlpEnv = { dp4: false, gemm: bgLutPipe, rowmax: rowmaxPipe, quant: quantI32Pipe, lutBuf };
471
  let mlpLut = (xq, w1q, w2q, xs, w1s, w2s, d) => gpuMlpChain(device, lutMlpEnv, xq, w1q, w2q, xs, w1s, w2s, d);
472
  const mlpLutBad = await gateMlp(mlpLut);