Bind synthetic edge cases and GPU comparisons to original CPU oracle

This commit is contained in:
Digital Drosophila Archive
2026-10-01 14:34:22 +08:00
parent 2191deef54
commit 906e6f17c0
3 changed files with 213 additions and 7 deletions
@@ -97,9 +97,16 @@ def load_fixtures(manifests):
common_identity = identity
assert common_identity == identity, 'Full KC/mask/base identity differs across fixtures'
assert len(a['kc']) == 4064 and len(a['candidate_edge_id']) == 14232
source_pins = read(npz.parent / 'reference-sources.json')
for info in source_pins.values():
assert sha(info['path']) == info['sha256'], 'Reference source changed'
sources_path = npz.parent / 'reference-sources.json'
assert sha(sources_path) == m['files'][sources_path.relative_to(root).as_posix()]['sha256']
source_pins = read(sources_path)
expected_sources = dict(
conditioning_update_source='96efff678cff910654eb08e86f1a17789e4e5589e340345f419c7027a7d547e2',
eligibility_bridge_source='174fb8d14619189e74b095e77a6db18b14c93046dc431c0b55710a5aa2dd2e61',
phase4j_source='abb4574da85f00bd9ef61024c65993ef81d42651ff8d8d63c15dd69c6222471e')
assert set(source_pins) == set(expected_sources)
for role, info in source_pins.items():
assert info['sha256'] == expected_sources[role] and sha(info['path']) == info['sha256'], 'Reference source changed'
# Extract constants from the authenticated original bridge, without import/exec.
import ast
bridge = source_pins['eligibility_bridge_source']
@@ -118,6 +125,33 @@ def load_fixtures(manifests):
assert fixtures
return fixtures, common_identity
def check_rejections(manifests, backend, rule):
reports = []
for path in manifests:
for case in read(path).get('invalid_cases', []):
root = path.parent
npz, command = contained(root, case['npz']), contained(root, case['command'])
assert sha(npz) == case['npz_sha256'] and sha(command) == case['command_sha256']
with np.load(npz, allow_pickle=False) as z:
a = {k: z[k].copy() for k in z.files}
c = read(command)
commands = [] if c['us_tick'] is None else [c['us_tick']]
stage = 'prepare'
try:
prepared = prepare_events(a['step'], a['neuron_idx'], a['kc'], c['steps'], commands,
n_neurons=c['n_neurons'])
stage = 'run'
backend.run(prepared, a['candidate_sources'], a['candidate_compartments'],
c['compartment'], a['delta_before'], a['base_candidate'],
d=c['d_command'], frozen=c['frozen'], **rule)
except ValueError as error:
assert stage == case['stage'], 'Rejected at a different validation boundary'
reports.append(dict(case_name=case['case_name'], rejected=True,
stage=stage, expected_exception=case['expected_exception'], message=str(error)))
else:
raise AssertionError('Candidate accepted invalid case: ' + case['case_name'])
return reports
def main(args):
assert os.environ.get('CUDA_VISIBLE_DEVICES') == args.uuid, 'Use one explicit physical UUID per process'
assert args.output.is_absolute() and not args.output.exists()
@@ -193,11 +227,14 @@ def main(args):
median_ms=1000 * report['summaries']['replay_wall_including_preparation_and_comparison_seconds']['median'])), flush=True)
# Recheck original exported files at the end, not just at read time.
load_fixtures(args.manifest)
rejections = check_rejections(args.manifest, backend, fixtures[0]['rule'])
save(args.output / 'invalid-input-rejections.json', rejections)
result = dict(status='PASS-ELIGIBILITY-UPDATE-REPLAY-EQUIVALENCE', fixtures=len(reports),
device=device, candidate_commit=commit, all_fixture_repeats_bitwise_exact=True,
observed_cuda_pool_reserved_peak_bytes=peak_reserved, gpu_after=gpu_snapshot(args.uuid),
queues_after=idle_queues(), wall_seconds=time.perf_counter()-started,
original_experiment_resumed=False, brain_simulation_tested=False,
rejected_invalid_cases=len(rejections),
full_training_speedup_measured=False, learning_success_claimed=False,
coverage_limit='available prefix + fixed synthetic edge cases, not all registered conditions',
files={p.name: sha(p) for p in sorted(args.output.iterdir()) if p.is_file()})