From 80aeb2093db655329774eff7b32fb6e417b8b40b Mon Sep 17 00:00:00 2001 From: Digital Drosophila Archive Date: Wed, 30 Sep 2026 21:06:22 +0800 Subject: [PATCH] Bind runtime array closure to exact frozen worker inputs --- .../normal-conditioning-v1/normal_prepare.py | 15 +++++++++++---- .../normal-conditioning-v1/test_normal_runner.py | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/models/male-cns-lif/normal-conditioning-v1/normal_prepare.py b/models/male-cns-lif/normal-conditioning-v1/normal_prepare.py index 08ec612..53f9970 100644 --- a/models/male-cns-lif/normal-conditioning-v1/normal_prepare.py +++ b/models/male-cns-lif/normal-conditioning-v1/normal_prepare.py @@ -30,6 +30,15 @@ H_ANCHORS = { 'manifests/manifest.json':'d1f187f164f7775a1a02fff259c8f5e31ae035929d808c3876cfc0013d19c73c', } +# Exact arrays consumed by the pinned isolated worker, not every reference file +# colocated in its graph/APL directories. Tests compare these to that worker. +GRAPH_FILES = ('nodes.npy', 'edge_id.npy', 'src.npy', 'dst.npy', 'signed_raw.npy', 'ptr.npy', 'weights.npy') +APL_FILES = ('input_matrix.npy', 'output_matrix.npy', 'kc_globals.npy', 'apl_globals.npy') + +def runtime_array_paths(template): + return {str(Path(template['graph_dir'])/name) for name in GRAPH_FILES} | { + str(Path(template['apl_bundle_dir'])/name) for name in APL_FILES} | {template['coefficients_path']} + def readout_populations(population_file): import numpy as np import pyarrow.parquet as pq @@ -148,10 +157,8 @@ def prepare(): save_npz(EXP/'inputs/static/readout-populations.npz',populations) save(EXP/'inputs/static/readout-population-binding.json',pop_audit) # Actual consumed neural dependency closure, all inherited byte pins. - required=set() - for role in ('graph_dir','apl_bundle_dir'): - required.update(str(p) for p in Path(template[role]).iterdir() if p.suffix=='.npy') - required.add(template['coefficients_path']) + required=runtime_array_paths(template) + require(required <= pinned.keys(), 'Consumed runtime arrays missing inherited pins: '+str(sorted(required-pinned.keys()))) original_sources={p:s for p,s in epoch['frozen_inputs'].items() if p.startswith(str(ROOT/'models/male-cns-lif/') ) and ('author-' in p or 'apl-timing-lab-v1/' in p)} runtime={p:pinned[p] for p in required} diff --git a/models/male-cns-lif/normal-conditioning-v1/test_normal_runner.py b/models/male-cns-lif/normal-conditioning-v1/test_normal_runner.py index 0fbe9e8..311baf3 100644 --- a/models/male-cns-lif/normal-conditioning-v1/test_normal_runner.py +++ b/models/male-cns-lif/normal-conditioning-v1/test_normal_runner.py @@ -11,6 +11,7 @@ from unittest.mock import patch import numpy as np import normal_runner as R +import normal_prepare as P def load_readonly(name, path): @@ -40,6 +41,21 @@ def task(arm='paired', *, requested=True, kind='train', dan='PAM15', number=1): class RunnerTests(unittest.TestCase): + def test_runtime_array_closure_matches_original_worker_not_directory_glob(self): + self.assertEqual(P.GRAPH_FILES,WORKER.GRAPH_FILES) + self.assertEqual(P.APL_FILES,WORKER.APL_FILES) + with tempfile.TemporaryDirectory() as folder: + root=Path(folder);graph=root/'graph';apl=root/'apl' + graph.mkdir();apl.mkdir() + # Additional reference arrays are neither consumed nor required. + for name in ('apl_out_ids.npy','input_raw.npy','output_raw.npy','pn_globals.npy'): + (apl/name).touch() + template=dict(graph_dir=str(graph),apl_bundle_dir=str(apl),coefficients_path=str(root/'coeff.json')) + paths=P.runtime_array_paths(template) + expected={str(graph/name) for name in WORKER.GRAPH_FILES} | { + str(apl/name) for name in WORKER.APL_FILES} | {template['coefficients_path']} + self.assertEqual(paths,expected);self.assertEqual(len(paths),12) + def setUp(self): temporary=tempfile.TemporaryDirectory();self.addCleanup(temporary.cleanup) self.root=Path(temporary.name).resolve()