Skip to content

Add number_synapses_in_replay and number_spikes_in_replay to Simulation - #780

Merged
eleftherioszisis merged 2 commits into
mainfrom
add-simulation-replay-counts
Nov 27, 2026
Merged

eleftherioszisis merged 2 commits into
mainfrom
add-simulation-replay-counts

Conversation

@eleftherioszisis

@eleftherioszisis eleftherioszisis commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds two counts to Simulation, next to number_synapses (#775): number_synapses_in_replay and number_spikes_in_replay. obi-one records them when it generates a simulation and uses them to size the simulation's resources (openbraininstitute/obi-one#1241).

Replay costs neurodamus memory in two ways that number_synapses does not show:

  • number_synapses_in_replay: the synapses onto the simulated cells whose source neuron spikes in a replay input (estimated at generation). Each replayed connection holds its own spike train and NetCon, about 2 KB, split over the nodes.
  • number_spikes_in_replay: the spikes of all the replay inputs. Every MPI rank reads all the spike files while it sets the replay up, about 41 bytes per spike per rank, so it is paid on every node whatever their number. 13.4M spikes take about 100 GB of each 192-rank node.

Measurements and the memory model: openbraininstitute/prod-circuit-simulation#265.

Changes

  • Simulation.number_synapses_in_replay and Simulation.number_spikes_in_replay: BigInteger, not null, server default 0, meaning not counted. Optional on create, returned on read, settable on update.
  • Migration 766ed86f8c63: adds both columns; the existing simulations get 0. No trigger change (the "Update triggers" revision was empty).
  • scripts/export/build_database_archive.sh: the new database version.
  • Tests: the existing number_synapses tests now cover the three counts (read, create without them, model default, invalid values, update).

Compatibility

Both fields are optional with a default, as number_synapses. entitysdk 0.22 reads Simulation responses that have fields it does not know (checked on staging, which returns number_synapses already), so deploying this before entitysdk has the fields breaks no client. obi-one only writes the counts once entitysdk's Simulation has them.

Checks

  • make lint (ruff, pyright): clean.
  • alembic check: no pending operations; downgrade and upgrade of the new revision run.
  • Full test suite: 1566 passed.

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
pytest 98.76% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/db/model.py 99.01% <100.00%> (+<0.01%) ⬆️
app/schemas/simulation.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replay costs neurodamus memory in two ways that number_synapses does not show: every replayed
connection holds its own spike train and NetCon (split over the nodes), and every MPI rank reads all
the replay spike files (paid on every node, whatever the number of nodes). obi-one will record both
counts when it generates the simulation, next to number_synapses, to size its resources.

Both columns are BigInteger, not null, with a server default of 0, which means not counted: the
existing simulations get 0, and clients that do not know the fields keep working.

Refs openbraininstitute/prod-circuit-simulation#265
@eleftherioszisis
eleftherioszisis force-pushed the add-simulation-replay-counts branch from d64c1be to 2a8e356 Compare November 27, 2026 13:52
@eleftherioszisis eleftherioszisis changed the title Add number_replayed_synapses and number_replay_spikes to Simulation Add number_synapses_in_replay and number_spikes_in_replay to Simulation Nov 27, 2026
@eleftherioszisis
eleftherioszisis merged commit 0f84250 into main Nov 27, 2026
2 checks passed
@eleftherioszisis
eleftherioszisis deleted the add-simulation-replay-counts branch November 27, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants