Open
Conversation
KartikP
approved these changes
Apr 9, 2026
Contributor
KartikP
left a comment
There was a problem hiding this comment.
LGTM! Lots of tests, but comprehensive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
preallocate_memoryhook andscore_benchmarkhelper toBenchmarkProblem
Neural benchmarks can run for 6-7 hours and crash with an OOM error at the very end
when trying to allocate the full activation array. There was no way to detect this early.
Changes
brainscore_core/benchmarks/__init__.pyBenchmark.preallocate_memory(candidate)— a no-op by default. Domain-specificsubclasses (e.g.
NeuralBenchmarkin brainscore_vision) can override this to run apre-flight memory check before scoring begins.
score_benchmark(benchmark, candidate)— the recommended call site instead ofbenchmark(candidate)directly. Callspreallocate_memoryfirst, then scores.tests/test_plugin_management/test_benchmarks.py— new unit test file (13 tests)covering the no-op default, call ordering, MemoryError propagation, and env var bypass.
Design notes
preallocate_memoryis a no-op, so all existing benchmarks and pluginsare completely unaffected.
score_benchmarkis the hook point — domain libraries call this instead ofbenchmark(candidate)and get the check for free.brainscore_vision, not here. Core only defines the interface.
preallocate_memorywhenready — no further core changes needed.
Companion PR (vision)
brainscore_vision will add the probe implementation in
benchmark_helpers/memory.pyandwires
NeuralBenchmark.preallocate_memoryto call it. This core PR must be merged andreleased before the vision PR can be merged.