Compare commits

..
2 Commits
Author SHA1 Message Date
chrnxandClaude Opus 5 503c374968 docs: correct the omega comment -- it claimed something now measured false
core.py said omega "wants tuning against the domain's length scale". Measured in
experiments/results/omega.md: the optimum sits at 2-4 while the domain bandwidth
varies 4.7x, and omega=8 is an optimisation cliff regardless of the domain. What
the domain changes is the penalty for being under-banded, not where the optimum
is.

The default of 10.0 is outside that plateau and every chess number was produced
at it. Left alone rather than silently changed: those results are comparisons at
a fixed omega and remain fair, and one synthetic teacher family is not grounds to
move a library default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCydQraDSoZ9WoTm2v23Eb
2026-09-07 17:45:03 -05:00
chrnxandClaude Opus 5 3ef8868ffa test: assert the two RP properties that need no experiment
One parameter set serves any entity count, and entity order carries no meaning.
Both are properties of the construction rather than results, and both are what
distinguishes the RP from a fixed-weight layer -- which is not worse at variable
N, it is undefined there.

Permutation equivariance was already asserted at the RP level; the Organism
keys memory by entity id, which is a second place order could leak, so it gets
its own test. Checked against a broken RP (an index-dependent term in the pooled
message): both permutation tests fail there and no others do.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCydQraDSoZ9WoTm2v23Eb
2026-09-07 17:02:38 -05:00
2 changed files with 46 additions and 3 deletions

No files matched your search

+11 -3
View File
@@ -16,9 +16,17 @@ class AffectiveCPPN(nn.Module):
super().__init__() super().__init__()
self.l1 = nn.Linear(coord_dim + n_edge_types + context_dim, hidden) self.l1 = nn.Linear(coord_dim + n_edge_types + context_dim, hidden)
self.l2 = nn.Linear(hidden, out_dim) self.l2 = nn.Linear(hidden, out_dim)
# omega scales the sine pre-activation and sets the kernel bandwidth; it is # omega scales the sine pre-activation and sets the kernel bandwidth. This was
# a calibration knob that wants tuning against the domain's length scale # documented as "a calibration knob that wants tuning against the domain's length
# (the particles domain's sigma). l1 deliberately keeps PyTorch's default init. # scale"; experiments/results/omega.md measured that and it is FALSE over the range
# tested -- the best omega sits at 2-4 for a domain bandwidth varying 4.7x, and 8 is
# an optimisation cliff for every domain tried. What the domain changes is the
# penalty for being under-banded, not where the optimum is.
# The default of 10.0 is OUTSIDE that plateau and every chess result was produced at
# it. It is left alone rather than silently changed: those results are comparisons at
# a fixed omega and stay fair, and one synthetic teacher family is not enough to move
# a library default. Pass omega explicitly, and measure it for a new domain.
# l1 deliberately keeps PyTorch's default init.
self.omega = omega self.omega = omega
def forward(self, r: Tensor, edge_onehot: Tensor, context: Tensor) -> Tensor: def forward(self, r: Tensor, edge_onehot: Tensor, context: Tensor) -> Tensor:
+35
View File
@@ -179,3 +179,38 @@ def test_detach_memory_cuts_graph():
_, mem = org(attrs, r, ids, (0.0, 0.0), {}) _, mem = org(attrs, r, ids, (0.0, 0.0), {})
assert all(m.requires_grad for m in mem.values()) assert all(m.requires_grad for m in mem.values())
assert not any(m.requires_grad for m in detach_memory(mem).values()) assert not any(m.requires_grad for m in detach_memory(mem).values())
# --- Property card rows: what the RP is, asserted rather than assumed. -------------------
# These two are not experiments and must never become them. They state properties that hold
# by construction, and exist so a future change cannot remove one silently. Both were checked
# against a deliberately broken RP (see results/rp_properties.md) and both failed there.
def test_rp_same_parameters_any_n():
"""One parameter set serves any entity count. A fixed-weight layer over N entities is
not worse here, it is undefined: its input dimension is N (or N^2) and has to be chosen."""
rp = RelationalPerceptron(D_ATTR, K, E, C, hidden_dim=H)
before = [p.clone() for p in rp.parameters()]
for n in (2, 7, 32):
attrs, coords = torch.randn(n, D_ATTR), torch.rand(n, K)
edge = torch.zeros(n, n, E); edge[..., 0] = 1.0
h = rp(attrs, flat_diff(coords), edge, torch.ones(n, n), torch.tensor([0.1, 0.2]))
assert h.shape == (n, H)
assert all(torch.equal(a, b) for a, b in zip(before, rp.parameters())) # no shape adapted
def test_organism_permutation_equivariance_with_memory():
"""The RP-level test uses positional tensors; the Organism keys memory by entity id, which
is a second place the order could leak in."""
org = make_org(memory=True)
attrs, coords, _, _, _ = make_inputs()
r, ids = flat_diff(coords), list(range(N))
mem = {i: torch.randn(H) for i in ids}
y0, m0 = org(attrs, r, ids, (0.0, 0.0), mem)
perm = torch.randperm(N)
ids_p = [ids[k] for k in perm.tolist()]
y1, m1 = org(attrs[perm], flat_diff(coords[perm]), ids_p, (0.0, 0.0), mem)
assert torch.allclose(y0[perm], y1, atol=1e-5)
assert all(torch.allclose(m0[i], m1[i], atol=1e-5) for i in ids)