Quazim0t0 commited on
Commit
6ec688e
·
verified ·
1 Parent(s): 24b5ef3

Upload web/test_ieee.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. web/test_ieee.js +25 -0
web/test_ieee.js CHANGED
@@ -215,6 +215,31 @@ console.log("\nfmaF32Spec: single rounding, cross-checked against an independent
215
  console.log(" note test_vectors_fma.json not present — cross-oracle check skipped");
216
  }
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  // 3) the b2b immunity scan's fused emulation, validated: on the quantize
219
  // domain (x >= 0, x*inv <= ~127.5, addend 0.5) the exact product spans
220
  // <= 53 bits including the 0.5, so fround(x*inv + 0.5) IS the true fma
 
215
  console.log(" note test_vectors_fma.json not present — cross-oracle check skipped");
216
  }
217
 
218
+ // 2b) same cross-check for MUL and ADD — vectors computed by neural-rdna2's
219
+ // LUT-BACKED verified fp32 core (the wave interpreter's own arithmetic:
220
+ // every mantissa product through the exported mul4 atom, exact
221
+ // exponent/round wiring). Epilogue-shaped ranges + subnormal/overflow
222
+ // regimes + raw finite bits + signed zeros.
223
+ {
224
+ let vecs = null;
225
+ try { vecs = JSON.parse(fs.readFileSync(path.join(__dirname, "test_vectors_fp32.json"), "utf8")); } catch (e) {}
226
+ if (vecs) {
227
+ const buf = new ArrayBuffer(4), dv = new DataView(buf);
228
+ const fromBits = (u) => { dv.setUint32(0, u); return dv.getFloat32(0); };
229
+ const toBits = (x) => { dv.setFloat32(0, x); return dv.getUint32(0); };
230
+ let badM = 0, badA = 0;
231
+ for (const [ah, bh, mh, sh] of vecs.vectors) {
232
+ const a = fromBits(parseInt(ah, 16)), b = fromBits(parseInt(bh, 16));
233
+ if (toBits(mulF32Spec(a, b)) !== parseInt(mh, 16)) badM++;
234
+ if (toBits(addF32Spec(a, b)) !== parseInt(sh, 16)) badA++;
235
+ }
236
+ ok(badM === 0, `mulF32Spec agrees bit-for-bit with the LUT-backed RDNA2 core on ${vecs.vectors.length} vectors`);
237
+ ok(badA === 0, `addF32Spec agrees bit-for-bit with the LUT-backed RDNA2 core on ${vecs.vectors.length} vectors`);
238
+ } else {
239
+ console.log(" note test_vectors_fp32.json not present — fp32 cross-oracle check skipped");
240
+ }
241
+ }
242
+
243
  // 3) the b2b immunity scan's fused emulation, validated: on the quantize
244
  // domain (x >= 0, x*inv <= ~127.5, addend 0.5) the exact product spans
245
  // <= 53 bits including the 0.5, so fround(x*inv + 0.5) IS the true fma