Skip to content
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

Tests for particle diffusion #2209

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

jlubo
Copy link
Collaborator

@jlubo jlubo commented Aug 15, 2023

Python tests are added to ensure the working of the diffusion of arbitrary particles in setups with 1-3 segments (cf. issues #2084 and #2145).

Besides showing that the diffusion seems to work if segments have the same radius, the tests that are added here also point to the fact that the diffusion across segments of different radius is still erroneous. Therefore, I left the tests for different radii commented until #2145 has been resolved.

@thorstenhater
Copy link
Contributor

Hey @jlubo,

thanks for adding this. Could you run black . and push the results? That'll make the Linter
check pass.

@thorstenhater
Copy link
Contributor

And flake8 . :D

@jlubo
Copy link
Collaborator Author

jlubo commented Aug 16, 2023

Okay, black now passes (I had previously used an older version, seems that they changed something). Yeah, now flake8 is complaining... I'll try to fix that, too :)

Copy link
Contributor

@thorstenhater thorstenhater left a comment

Choose a reason for hiding this comment

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

Hey,
made some comments for improvements, rest looks great, thanks.

.gitignore Outdated
@@ -105,3 +105,6 @@ _skbuild

# generated by test scripts
results

# environment setting script
set_arbor_env*
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this file come from? If it's common (like editor/build system/... temporaries) I have no problem with adding it, but we had clashes before and so I am rather conservative.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a file that I usually use to set the Arbor environment, I guess it can't be considered common :D

test/unit/diffusion/neuron_with_diffusion.mod Show resolved Hide resolved
@@ -39,6 +39,6 @@ In subfolders `unit`/`unit_distributed`:

## Naming convention

- modules: `test_xxxs` (ending with `s` since module can consist of multiple classes)
- class(es): `TestXxxs` (ending with `s` since class can consist of multiple test functions)
- modules: `test_xxxs` (if suitable, ending with `s` since module can consist of multiple classes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- modules: `test_xxxs` (if suitable, ending with `s` since module can consist of multiple classes)
- modules: `test_xxxs` (if applicable use the plural as modules can comprise multiple tests)

- modules: `test_xxxs` (ending with `s` since module can consist of multiple classes)
- class(es): `TestXxxs` (ending with `s` since class can consist of multiple test functions)
- modules: `test_xxxs` (if suitable, ending with `s` since module can consist of multiple classes)
- class(es): `TestXxxs` (if suitable, ending with `s` since class can consist of multiple test functions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same idea here

python/test/unit/test_diffusion.py Show resolved Hide resolved
cat # use the provided catalogue of diffusion mechanisms
)
self.the_props.set_ion("s", 1, 0, 0, 0) # use diffusive particles "s"
self.inc_0 = inc_0 # increase in particle amount at 0.1 s (in 1e-18 mol)
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a list of [(t, synapse, amount)] instead of these three hardcoded injections seems like it could make things
more general and even clearer to understand.

python/test/unit/test_diffusion.py Outdated Show resolved Hide resolved
@jlubo jlubo force-pushed the tests_for_particle_diffusion branch from 74a8f99 to 2c1e802 Compare August 24, 2023 14:04
@jlubo
Copy link
Collaborator Author

jlubo commented Aug 24, 2023

Hey, made some comments for improvements, rest looks great, thanks.

Thanks @thorstenhater! I've revised the code according to the comments.

ext/fmt Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend git fetch --all && git merge origin/master && git submodule sync ... changing submodules in a feature PR is likely not what you want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I must have missed that they were in.

ext/pugixml Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@jlubo jlubo force-pushed the tests_for_particle_diffusion branch from 25fe938 to 7f77d60 Compare August 25, 2023 17:52
thorstenhater
thorstenhater previously approved these changes Aug 25, 2023
Copy link
Contributor

@thorstenhater thorstenhater left a comment

Choose a reason for hiding this comment

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

Thank you very much!

@thorstenhater
Copy link
Contributor

cscs-ci run daint-gpu

@thorstenhater
Copy link
Contributor

thorstenhater commented Aug 29, 2023

Uh-oh

subprocess.CalledProcessError: Command 'make' returned non-zero exit status 2.
 Error:
/tmp/tmpqgxm6fo0/build/generated/diffusion/neuron_with_diffusion_gpu.cu(59): warning #177-D: function "arb::diffusion_catalogue::<unnamed>::multiply" was declared but never referenced
/tmp/tmpqgxm6fo0/build/generated/diffusion/synapse_with_diffusion_gpu.cu(74): error: identifier "n_" is undefined
/tmp/tmpqgxm6fo0/build/generated/diffusion/synapse_with_diffusion_gpu.cu(55): warning #177-D: function "arb::diffusion_catalogue::<unnamed>::multiply" was declared but never referenced
1 error detected in the compilation of "/tmp/tmpqgxm6fo0/build/generated/diffusion/synapse_with_diffusion_gpu.cu".
make[2]: *** [CMakeFiles/diffusion-catalogue.dir/build.make:183: CMakeFiles/diffusion-catalogue.dir/generated/diffusion/synapse_with_diffusion_gpu.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/diffusion-catalogue.dir/all] Error 2

@boeschf could you take a look? I suspect the recent changes to event delivery clash with the diffusion handling:

    if (ii_ < (end_ - begin_)) {
        const auto tid_ = (begin_ + ii_)->mech_index;
        if ((ii_ > 0) && ((begin_ + (ii_ - 1))->mech_index == tid_)) return;
        for (auto i_ = begin_ + ii_; i_ < end_; ++i_) {
            if (i_->mech_index != tid_) break;
            [[maybe_unused]] auto weight = i_->weight;
            unsigned lane_mask_ = arb::gpu::ballot(0xffffffff, tid_<n_);

this was emitted by modcc for the NET_RECV. Note the missing n_, which I assume should be
end_ - begin_ here?

@jlubo
Copy link
Collaborator Author

jlubo commented Oct 7, 2023

The different-radii and different-length tests are now uncommented. They should succeed if they are run with this new fix in the diffusion solver: thorstenhater@7577092

@thorstenhater
Copy link
Contributor

Hey @jlubo,

could you leave them disabled, I'll add them to the to-be-made PR for the fixes.

…ent_radii' again (for as long as the related fix is not merged)
@jlubo
Copy link
Collaborator Author

jlubo commented Oct 10, 2023

Done :)

@thorstenhater
Copy link
Contributor

I'll fix the GPU problem in my follow-up #2226

Copy link
Contributor

@thorstenhater thorstenhater left a comment

Choose a reason for hiding this comment

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

Nice! See also downstream #2226. Two questions:

  1. It seems like lots of special casing for the different setups (num_sgs=1,2,3). Do you think it would be cleaner to split these into different tests altogether?
  2. Question also inline: Can't we always compute the equilibrium concentration?

@jlubo
Copy link
Collaborator Author

jlubo commented Oct 14, 2023

1. It seems like lots of special casing for the different setups (num_sgs=1,2,3). Do you think it would be cleaner to split these into different tests altogether?

I agree, I've now split the function get_morph_and_decor() into into individual functions for 1, 2, and 3 segments.

2. Question also inline: Can't we always compute the equilibrium concentration?

Yes we can! I've introduced a more general computation of CV volumes making this possible now.

@boeschf
Copy link
Contributor

boeschf commented Oct 23, 2023

cscs-ci run daint-gpu

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.

None yet

3 participants