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
Refactor files, emulator, api #159
Conversation
I was just thinking about how this structure might change if/when we want to have multi-compartment neurons. In this case, maybe we want a |
I'm cool with deferring it until model build to reduce the number of changes here.
|
Based on our naming for compartments, probes, etc., NeuronGroup would fit best in a file called |
We could name it |
b4b3c8a
to
9f027a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor comments, definitely like these changes a really nice improvement to the organization 👌
aa8c4a8
to
f5d797c
Compare
Rebased this to master (saved the previous history in |
d39a002
to
6a14875
Compare
Note: all emulator tests passing, but there is still one test failure on hardware ( |
All tests passing now on hardware and emulator. |
cc1ca2b
to
3e212c7
Compare
This is all rebased to master, and I think all comments are addressed. Hopefully all the tests pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a bunch of inline comments, some of which might need some discussion, so possibly we should make a call for that?
Another thing that comes to mind in general is that it's not clear to me the distinction and hierarchy of CompartmentGroup
and NeuronGroup
. Which contains the other? I know we already discussed the name NeuronGroup
, but maybe we should revisit that in the meeting as well.
For CompartmentGroup vs NeuronGroup: a CompartmentGroup is a member of a NeuronGroup. Right now, the number of neurons is the same as the number of compartments, but the idea is that when we have multi-compartment neurons, you'd create a neuron group and say e.g. I want 100 neurons of type AlphaNeuron. If AlphaNeuron has three compartments, then the CompartmentGroup will have 300 compartments that implement the 100 neurons. For some reason, I can't "reply" to some of the inline comments, so I will here. Re: renaming LoihiSimulator: The nice thing about |
20ba2f6
to
07a7a36
Compare
We discussed a few ways to organize files yesterday, all with some pros/cons. It's easier to compare the options if we can see the final source tree, so here are those options. Option 1: Loihi-oriented 😄Couldn't think of a good name, but this is the current state of this PR. File names are roughly based on class names, which are tied to how the chip works. In this and subsequent file listings, I've omitted test files and Here I've annotated with the # of lines of code, as we know this from the current branch. In subsequent options, I'll estimate the number of lines of code given what I assume will go in each file.
Option 2: Nengo-oriented 🎉This is roughly what I was thinking about as a possible Nengo-oriented file structure when I was reviewing the PR last week.
Option 3: File suffixes, Nengo-oriented ❤️This could also be prefixes, but I think suffixes are preferred. This is similar to how NengoDL is organized. Here, I combine some of the top-level files into the
There might also be an option 3b or 4 that is a variant of this option that keeps Vote with emoji reactions if this all makes sense, otherwise comment away! |
Option 5: Loihi-oriented with folder 🚀Like option 1, but moves some files into an
|
The thing that I find confusing about Option 5 is what differentiates things in the Since we have two for option 3, are there specific things that you don't like about it that we can change @hunse? |
I too was struggling with what exactly goes in the
It's the Loihi API that developers use to write models for the chip. Not all APIs have to be user-facing, in my opinion, but I can understand how just calling it The biggest thing I don't like about option 3 is it hides this mid-level Loihi API (or whatever you want to call it). To me, this is the core around which I also don't like that option 3 doesn't have a builder folder. This differs from It's also just different from the way I naturally group things. I tend to group objects at the same level of a hierarchy together, even if they're serving different functions. Option 3 groups things more functionally (e.g. everything related to connections together) grouping across levels in the hierarchy. There's no clear right or wrong, it's just not the way I tend to group things in my mind. |
The reason I changed away from Also, Not saying that these abstractions are perfect and 100% clear, just explaining my motivations for moving away from the
Yeah I realized after I switched it that it used to be The output part of it is a bit tricky since we don't really have explicit things to shuttle data off the chip. I think that we should, it would make the backend splitter / passthrough stuff more clear, but since we haven't done it yet putting it
Me too, seems easier to remember that all are singular vs some singular, some plural.
My concerns were more around the other files, I'm fine going back to a builder folder for the suffixed files 🤷♂️ So unless @drasmuss has strong objections let's do that. |
I think you have more associations with the word "segment" than I do. What about |
I think moving things back into the builder folder makes sense, since now those files only contain the No strong opinion on |
I mean, I didn't before I switched things and thought about it a bit, so it's not like a prior association I had. I tried to explain my reasoning so we'd all come to a shared understanding about things. If my thought process doesn't give you similar associations with segment, then we should think of something better, I just have trouble coming up with something else.
The main problem here, aside from what Dan pointed out, is that it would go in |
Also spending some time using it helps, it's hard to think about abstractly... using |
I think that your reasoning makes sense. All I'm saying is for somebody coming to the project, this isn't going to be immediately obvious. No matter what the name is, we're going to have to explain what it is, what it does, what's in it. What about |
I like Could you make those changes @hunse? |
Ok, I think I've made all the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small inline comment, but I'll fix that when I squash/fixup the history.
@drasmuss can you approve if this looks good to you (or if you're cool with whatevs).
07a0db9
to
46ac027
Compare
Implementing Option 3 as discussed in #159 (comment)
46ac027
to
4518528
Compare
Implementing Option 3 as discussed in #159 (comment)
385e3f7
to
ada3a34
Compare
These lines are often long by virtue of long email addresses, which we do not want to line break because they are automatically parsed by some tools.
ada3a34
to
77a84dc
Compare
Major organizational changes ---------------------------- - Made `builder`, `emulator`, and `hardware` folders to clean up the root directory and make clear what is hardware-specific. Renamed `loihi_api.py` and `loihi_interface.py` and moved them to the hardware folder. - Moved classes related to Loihi inputs from loihi_cx.py to inputs.py - Renamed CxSimulator -> EmulatorInterface - Renamed LoihiSimulator -> HardwareInterface - Renamed CxAxons -> Axon - Renamed CxGroup -> Compartment - Renamed CxProbe -> Probe - Renamed CxSpikeInput -> SpikeInput - Renamed CxSynapses -> Synapse - Renamed hardware.api.SpikeInput -> LoihiSpikeInput - Made a new LoihiInput base class that SpikeInput inherits from. In the future, we plan to investigate other ways of providing input to a Loihi model. - Added LoihiBlock - This is a new abstraction above the level of Axon, Compartment, Probe, and Synapse that serves as the main container for a "block" of the Loihi system (i.e., a chunk, region, slice, or segment). - Backend developers should think of the Loihi system (Loihi model) as a collection of LoihiBlocks and LoihiInputs. - A LoihiBlock can have elements across multiple cores/chips. - A LoihiBlock contains one Compartment instance, and any number of Axon, Probe and Synapse instances. Major refactoring ----------------- - Combined CxModel into Model - Split the EmulatorInterface class into state components for Compartment, Synapses, Axons, Probes. - Moved discretize and validation methods in Loihi classes to `discretize.py` and `validate.py` files. Makes the Loihi classes (in `block.py`) easier to read, and reduces the number of imports needed when discretizing is done in different places. - Renamed `Synapses.tracing` to `.learning` for clarity. - Removed unused group attribute from Axon/Synapse. - Removed unused location attribute from Compartment. - Synapse validation now calls SynapseFmt validation. Other changes ------------- - Removed "cx" from some, but not all, variable/function names. - Fixed `test_uv_overflow`. Co-authored-by: Trevor Bekolay <tbekolay@gmail.com> Co-authored-by: Daniel Rasmussen <daniel.rasmussen@appliedbrainresearch.com>
Rather than having redundant copies of Nengo code.
77a84dc
to
46d7d07
Compare
Replacement for #30. Currently based on #139, #124, #132.
The main file moving around has been done in the first commit. I tried to change as little as possible with the code (other than fixing imports), so if we do have to rebase this, it should be a simple matter of copying the changes to the right place.
TODO:
discretize
functioniteritems
? I feel like the performance benefit is very very minimal unless we've got huge dictionaries, and of course the benefit would only be for Python 2 (Python 3 is already fast).test_model.py
. It currently only has one test (the noise test) in it. This test also needs to be fixed so that it asserts something (currently only a visual test).Discussion: