Skip to content

Fix soft vs hard merge issue in analyzer #4025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2025
Merged

Conversation

zm711
Copy link
Member

@zm711 zm711 commented Jul 2, 2025

Currently the code doesn't actually care if you are doing a soft or hard merge, it verifies the sparsity overlap for all units whether soft or hard and then errors even on hard merge if there is not an overlap. Confirmed by a labmate who ran

merged_analyzer = analyzer.merge_units(
    new_merges,
    merging_mode='hard'
    sparsity_overlap = 0.75
)

and got an error
image

To be honest I don't understand the merging mechanism well enough to know just setting sparsity to None for a hard merge is desired so I'm submitting this as a reminder that we should probably fix this before the next version. Sorry I don't really know how to make a MRE for this.

so help writing a test would be great.

@zm711 zm711 marked this pull request as ready for review July 2, 2025 18:06
@zm711 zm711 added bug Something isn't working core Changes to core module labels Jul 2, 2025
Comment on lines 980 to 982
else:
sparsity = None
break
Copy link
Member Author

Choose a reason for hiding this comment

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

To make sure people read carefully this is my main question? is this what a "hard" merge should do for sparsity?

@alejoe91 alejoe91 added this to the 0.103.0 milestone Jul 3, 2025
@samuelgarcia
Copy link
Member

@yger can you help on this ?

@@ -960,20 +960,22 @@ def _save_or_select_or_merge(
mergeable, masks = self.are_units_mergeable(
merge_unit_groups,
sparsity_overlap=sparsity_overlap,
merging_mode=merging_mode,
Copy link
Member

Choose a reason for hiding this comment

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

@zm711 this should fix it. The implementation of this function is as follows:

  • if "soft": return intersection of sparsity and check mergeability
  • if "hard": return union and set mergeable to True

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn’t sure if in hard mode we wanted to test to see if soft was possible and switch to soft if possible and then only do hard if required.

@alejoe91
Copy link
Member

alejoe91 commented Jul 4, 2025

@zm711 can you test if my last ocmmit fixed it? :)

@zm711
Copy link
Member Author

zm711 commented Jul 4, 2025

As it is a holiday here the person who discovered this in lab won’t be around. I can test on Monday with the dataset that triggered this.

@alejoe91
Copy link
Member

alejoe91 commented Jul 4, 2025

As it is a holiday here the person who discovered this in lab won’t be around. I can test on Monday with the dataset that triggered this.

Oh right! Happy Independence Day and stop looking at the screen! Otherwise @samuelgarcia will need to intervene

@zm711
Copy link
Member Author

zm711 commented Jul 7, 2025

Tested and worked.

@alejoe91 alejoe91 merged commit 3770338 into SpikeInterface:main Jul 14, 2025
15 checks passed
@zm711 zm711 deleted the merge_bug branch July 14, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core Changes to core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants