Validate native Windows M against real PTX and correct patch-merge bounds

This commit is contained in:
Codex committed 2026-09-30 19:01:18 +03:00
1 parent 5592b7a921
commit 2db93adb1a
13 files changed
+611 -17

No files matched your search

+14 -8
View File
@@ -96,7 +96,8 @@ def split_args(s):
def parse_kernel(path, name):
src = open(path).read()
with open(path) as file:
src = file.read()
i = src.index('.entry ' + name + '(')
j = src.find('\n.visible', i + 10)
j = len(src) if j < 0 else j
@@ -340,12 +341,11 @@ class Block:
steps = 0
while pc < len(stmts):
st = stmts[pc]
for l in st.labels:
if l in pending:
active |= pending.pop(l)
if pc in pending:
active |= pending.pop(pc)
if not active.any():
# jump to the nearest label someone waits at
targets = sorted(self.labels[l] for l in pending)
# Reconverge at either a forward target or a loop fallthrough.
targets = sorted(pending)
if not targets:
break
pc = targets[0]
@@ -365,10 +365,16 @@ class Block:
if not taking.any():
pc += 1
continue
raise NotImplementedError('divergent backward branch at ' + st.text)
# Lanes finishing a loop wait at its fallthrough while the
# other lanes execute their remaining iterations. Their
# registers and memory writes stay masked until reconvergence.
pending[pc + 1] = pending.get(pc + 1, np.zeros(self.T, bool)) | (active & ~taking)
active = taking.copy()
pc = target
continue
active = active & ~taking
if taking.any():
pending[st.args[0]] = pending.get(st.args[0], np.zeros(self.T, bool)) | taking
pending[target] = pending.get(target, np.zeros(self.T, bool)) | taking
pc += 1
continue
if mask.any() or st.op.startswith(('mma', 'shfl', 'movmatrix', 'bar')):
+9 -1
View File
@@ -23,6 +23,10 @@ import swin_model as sm # noqa: E402
LAYERS = {'enc1': (64, 2, 96, 0), 'enc2': (96, 4, 128, 0), 'enc3_tube': (128, 4, 0, 0), 'dec2': (96, 4, 0, 128),
'dec1': (64, 2, 0, 96)}
# Preserve the existing Linux oracle by default; Windows strict replay enables
# the audited 310.9 f16 patch-merge bound before final e4m3 quantisation.
CLAMP_PATCH_MERGE = False
def blocks(grid, n, seed=1):
gx, gy = grid[0], grid[1]
@@ -47,7 +51,11 @@ def model_block(P, layer, bx, by):
Wg = me.E4M3[P.wbuf[sm.woff_table(PM0 + g * 128 * C, 512, 64 * C, 4 * C, 32)]]
bias = P.f16vec(PM0 + 4 * C * NPM + 64 * g, 32)
cols.append(me.mma_chain(A, Wg, C0=np.broadcast_to(bias, (16, 32)).copy()))
merged = me.q8(sm.pair_to_nat(np.concatenate(cols, axis=1)))
merged = sm.pair_to_nat(np.concatenate(cols, axis=1))
if CLAMP_PATCH_MERGE:
limit = me.f16(2 * np.pi)
merged = np.clip(merged, -limit, limit)
merged = me.q8(merged)
return out, merged