Skip to content

Conversation

@med-ayssar
Copy link
Contributor

@med-ayssar med-ayssar commented Jul 20, 2025

Fix for #3532
The main issue occurs when CompressedSpikes is disabled — the wrong connection gets deleted. The following image illustrates the problem."

Issues:

  • With compressed-spikes off, std::lower_bound was being applied on unsorted vector.

  • With compressed-spikes off, and regardless of (1), disconnecting a connection was not implemented correctly, because the query on the snode_id and tnode_id delivers a wrong lcid.

  • While testing, I discovered that disconnecting a connection, it changes the entry in the sourceTable, and when working with a sorted sourceTable (compressed-spikes=true), we might get an undefined behaviour

connections

@med-ayssar med-ayssar changed the title Fix issue: #3532: Disconnect given compressedSpikes Fix issue: #3532: Disconnect issue with CompressedSpikes:ON/Off Jul 20, 2025
@gtrensch gtrensch added T: Bug Wrong statements in the code or documentation S: Normal Handle this with default priority labels Jul 25, 2025
@gtrensch gtrensch added this to Kernel Jul 25, 2025
@github-project-automation github-project-automation bot moved this to In progress in Kernel Jul 25, 2025
@heplesser heplesser added S: High Should be handled next I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) and removed S: Normal Handle this with default priority labels Aug 7, 2025
@heplesser
Copy link
Contributor

@med-ayssar Thanks for your detective work and the PR! I will look at it in detail asap.

Copy link
Contributor

@heplesser heplesser left a comment

Choose a reason for hiding this comment

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

@med-ayssar Thanks for the PR! I am not entirely sure I follow the logic around nth_equal(), see comments below.

I also wonder if, for the uncompressed case, we should not take a different approach. In that case, I believe, we simply need to run through all connections of a given synapse type linearly and disconnect the first one for which source and target match, and which has not yet been disconnected. I guess that means parallel iteration through source and target tables. The split into find_first_source() and find_first_target() does not make sense in that case.

We also need some tests, including tests where there are multiple connections between the same source-target pair and we delete one at a time.

@github-project-automation github-project-automation bot moved this from In progress to PRs pending approval in Kernel Aug 8, 2025
@med-ayssar
Copy link
Contributor Author

@heplesser: Is it possible to setup a meeting to discuss this? Any time after 17:30 should work for me.

@heplesser heplesser linked an issue Nov 25, 2025 that may be closed by this pull request
Copy link
Contributor

@heplesser heplesser left a comment

Choose a reason for hiding this comment

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

Hi @med-ayssar! Thanks, this looks very good now. I will shortly send you a small PR which removes a few unused imports and an unused method, and adds/improves doxygen comments. Once that is merged, I will approve.

@heplesser heplesser removed the request for review from JanVogelsang November 25, 2025 13:39
Remove unused imports/methods and improve doxygen documentation
Copy link
Contributor

@heplesser heplesser left a comment

Choose a reason for hiding this comment

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

@med-ayssar Thanks, all fine now from my side.

@heplesser
Copy link
Contributor

heplesser commented Dec 1, 2025

@cjotade Thank you for your review! e-prop synapses hold a pointer to an optimizer object (could be simple gradient descent or an Adam optimizer). This optimizer needs to be destroyed when the synapse is deleted. The old code contained a bug that would lead to NEST trying to destroy the optimizer twice, and trying to delete an already deleted object leads to a runtime error. The changes make sure that the optimizer is deleted exactly once. And the change is in this PR because I discovered this problem when testing disconnection with all our synpase types, including eprop synapses.

@cjotade
Copy link

cjotade commented Dec 1, 2025

I see, thanks for the clarification!

Adding test thats check if num_connections is 0 after all_to_all disconnection
Copy link
Contributor

@heplesser heplesser left a comment

Choose a reason for hiding this comment

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

Adding empty lines to fulfill coding standards.

@heplesser
Copy link
Contributor

@cjotade With your test now merged, could you re-check and then approve explicitly if you think the PR is ready to be merged?

@heplesser heplesser requested a review from cjotade December 2, 2025 20:50
Copy link

@cjotade cjotade left a comment

Choose a reason for hiding this comment

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

Everything correct from my side, I think that the PR is ready to be merged. Thanks!

@heplesser heplesser changed the title Fix issue: #3532: Disconnect issue with CompressedSpikes:ON/Off Fix issue: #3532: Disconnect correctly with CompressedSpikes:ON/Off Dec 3, 2025
@heplesser heplesser merged commit dfc4d3e into nest:master Dec 3, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from PRs pending approval to Done in Kernel Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: High Should be handled next T: Bug Wrong statements in the code or documentation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

disconnect() does not work reliably without compressed spikes

6 participants