Skip to content

Scale only the waveforms amplitude_scalings reads - #4759

Merged
alejoe91 merged 2 commits into
SpikeInterface:mainfrom
JESUSROYETH:perf-amplitude-scalings-cutout-scaling
Sep 4, 2026
Merged

alejoe91 merged 2 commits into
SpikeInterface:mainfrom
JESUSROYETH:perf-amplitude-scalings-cutout-scaling

Conversation

@JESUSROYETH

@JESUSROYETH JESUSROYETH commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

AmplitudeScalingNode.compute scales every trace sample in a chunk before reading only the short, sparse windows around each spike. This PR moves the same scaling expression after each cut-out, including the collision path, so the temporary now scales with the samples and channels used by the regression instead of the whole chunk. The new fit_collision arguments are appended to keep existing positional calls compatible.

Benchmarks

Binary-backed generated recordings, 384 channels at 30 kHz, GCP c3-standard-22, BLAS threads pinned to 1, fresh processes and interleaved arms. Times are median (range), with five runs per arm except the 11-extension pipeline, which uses three.

pipeline before after change peak RSS
valid_unit_periods, 100 units 13.946 s (13.916–13.985) 12.476 s (12.413–12.550) −10.5% 522 → 389 MiB
valid_unit_periods, 200 units 99.453 s (98.571–100.084) 91.841 s (91.159–92.288) −7.7% 569 → 436 MiB
11 postprocessing extensions, 200 units 128.353 s (127.821–130.792) 120.195 s (119.215–120.645) −6.4% 1,713 → 1,713 MiB

The memory saving disappears in the wider pipeline because waveforms sets its high-water mark.

Validation

The amplitude_scalings bytes have the same SHA-256 before and after in 128 comparisons covering float32/int16/float64/uint16 recordings, absent/uniform/per-channel gains, collisions on/off, n_jobs=1/4, two NumPy/SciPy combinations and a two-segment recording.

  • pytest src/spikeinterface/postprocessing/tests -q: 97 passed, 40 skipped
  • bin/spikeinterface_lint.sh --check: clean

Tested on Linux with generated data written to binary first; no real capture was used.

@alejoe91 alejoe91 added postprocessing Related to postprocessing module performance Performance issues/improvements labels Sep 4, 2026
@alejoe91

alejoe91 commented Sep 4, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution! I have a comment on the code.

In general, can you try to reduce the PR message to something we can read in a reasonable amount of time?

@JESUSROYETH

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @alejoe91! I removed the helper and the additional tests, and shortened the PR body too. I will keep this in mind for the next PRs.

@alejoe91 alejoe91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks for trimming down the PR description too

@alejoe91
alejoe91 merged commit db256d7 into SpikeInterface:main Sep 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance issues/improvements postprocessing Related to postprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants