Upload web/public/verified_core.js with huggingface_hub
Browse files- web/public/verified_core.js +15 -3
web/public/verified_core.js
CHANGED
|
@@ -226,11 +226,23 @@
|
|
| 226 |
// mirror and compare against what the kernel produced. Sampling cells instead
|
| 227 |
// of whole matrices makes this cheap enough to run continuously, at the real
|
| 228 |
// shapes training uses — not once at boot on toy inputs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
function auditTile(Xq, Wq, rs, cs, d, got, L, nCells) {
|
| 230 |
const { m, k, n } = d, batch = d.batch || 1, relu = !!d.relu, mul = L.mul;
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
let acc = 0;
|
| 235 |
const xrow = bz * m * k + i * k, wo = bz * k * n;
|
| 236 |
for (let p = 0; p < k; p++) acc += mul[(Xq[xrow + p] & 0xFF) * 256 + (Wq[wo + p * n + j] & 0xFF)];
|
|
|
|
| 226 |
// mirror and compare against what the kernel produced. Sampling cells instead
|
| 227 |
// of whole matrices makes this cheap enough to run continuously, at the real
|
| 228 |
// shapes training uses — not once at boot on toy inputs.
|
| 229 |
+
// STRATIFIED sampling. Uniformly random cells are the wrong instrument for
|
| 230 |
+
// the bugs that actually occur here: a bounds-guard off-by-one or a pack-tail
|
| 231 |
+
// padding bug lives on the LAST row/column, and uniform sampling finds that
|
| 232 |
+
// with probability ~1/n per cell — at the 16512-wide logits GEMM, never. So
|
| 233 |
+
// the first cells are the structurally dangerous ones (corners, last row,
|
| 234 |
+
// last column, last batch) chosen deterministically, and the remainder are
|
| 235 |
+
// random interior cells that catch diffuse bugs. Same principle as poisoning
|
| 236 |
+
// the buffer pool: construct the dangerous case, don't wait to land on it.
|
| 237 |
function auditTile(Xq, Wq, rs, cs, d, got, L, nCells) {
|
| 238 |
const { m, k, n } = d, batch = d.batch || 1, relu = !!d.relu, mul = L.mul;
|
| 239 |
+
const N = nCells || 8;
|
| 240 |
+
const edges = [[0, m - 1, n - 1], [0, 0, n - 1], [0, m - 1, 0], [0, 0, 0],
|
| 241 |
+
[batch - 1, m - 1, n - 1], [batch - 1, 0, 0]];
|
| 242 |
+
for (let t = 0; t < N; t++) {
|
| 243 |
+
let bz, i, j;
|
| 244 |
+
if (t < edges.length) { bz = edges[t][0]; i = edges[t][1]; j = edges[t][2]; }
|
| 245 |
+
else { bz = (Math.random() * batch) | 0; i = (Math.random() * m) | 0; j = (Math.random() * n) | 0; }
|
| 246 |
let acc = 0;
|
| 247 |
const xrow = bz * m * k + i * k, wo = bz * k * n;
|
| 248 |
for (let p = 0; p < k; p++) acc += mul[(Xq[xrow + p] & 0xFF) * 256 + (Wq[wo + p * n + j] & 0xFF)];
|