Bind runtime array closure to exact frozen worker inputs
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user