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

Add rf and rf_iz neurons to lava #378

Merged
merged 34 commits into from
Nov 7, 2022

Conversation

Michaeljurado42
Copy link
Contributor

@Michaeljurado42 Michaeljurado42 commented Sep 27, 2022

Issue Number:

Objective of pull request: Add rf and rf_iz neurons to lava

Pull request checklist

Your PR fulfills the following requirements:

  • Issue created that explains the change and why it's needed
  • Tests are part of the PR (for bug fixes / features)
  • Docs reviewed and added / updated if needed (for bug fixes / features)
  • PR conforms to Coding Conventions
  • PR applys BSD 3-clause or LGPL2.1+ Licenses to all code files
  • Lint (flakeheaven lint src/lava tests/) and (bandit -r src/lava/.) pass locally
  • Build tests (pytest) passes locally

Pull request type

Please check your PR type:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation changes
  • Other (please describe):

What is the current behavior?

-No support for rf neurons in lava

What is the new behavior?

-There should be a floating point and loihi bit accurate implementation of rf neurons in lava. This implementation should match the lava-dl rf neuron implementations.

Does this introduce a breaking change?

  • Yes
  • No

Supplemental information

This issue is a result of an ongoing discussion in which I ask whether or not rf neurons will be added to lava.

Please see proof of concept example here

@Michaeljurado42
Copy link
Contributor Author

Michaeljurado42 commented Sep 27, 2022

I have been running into the following error when I try to run flakeheaven lint src/lava tests/:
`Traceback (most recent call last):
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\plugins\manager.py", line 161, in load_plugin
self._load()
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\plugins\manager.py", line 138, in load
self.plugin = self.entry_point.load()
File "C:\Users\mjurado3\AppData\Local\Programs\Python\Python310\lib\importlib\metadata_init
.py", line 171, in load
module = import_module(match.group('module'))
File "C:\Users\mjurado3\AppData\Local\Programs\Python\Python310\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in load_unlocked
File "", line 883, in exec_module
File "", line 241, in call_with_frames_removed
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8_bandit.py", line 7, in
from bandit.core.config import BanditConfig
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\bandit_init
.py", line 7, in
from bandit.core import config # noqa
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\bandit\core_init
.py", line 5, in
from bandit.core import config # noqa
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\bandit\core\config.py", line 10, in
from bandit.core import extension_loader
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\bandit\core\extension_loader.py", line 109, in
MANAGER = Manager()
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\bandit\core\extension_loader.py", line 21, in init
self.load_formatters(formatters_namespace)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\bandit\core\extension_loader.py", line 26, in load_formatters
self.formatters_mgr = extension.ExtensionManager(
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\stevedore\extension.py", line 133, in init
extensions = self._load_plugins(invoke_on_load,
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\stevedore\extension.py", line 218, in _load_plugins
for ep in self.list_entry_points():
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\stevedore\extension.py", line 207, in list_entry_points
eps = list(_cache.get_group_all(self.namespace))
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\stevedore_cache.py", line 173, in get_group_all
data = self._get_data_for_path(path)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\stevedore_cache.py", line 149, in _get_data_for_path
digest, path_values = _hash_settings_for_path(path)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\stevedore_cache.py", line 79, in _hash_settings_for_path
mtime = _get_mtime(entry)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\stevedore_cache.py", line 56, in _get_mtime
s = os.stat(name)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\Users\mjurado3\workspace\lava>'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\mjurado3\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\mjurado3\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\mjurado3\workspace\lava_dev\lava.venv\Scripts\flakeheaven.exe_main
.py", line 7, in
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flakeheaven_cli.py", line 40, in entrypoint
exit_code, msg = main(argv)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flakeheaven_cli.py", line 32, in main
return COMMANDScommand_name
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flakeheaven\commands_lint.py", line 12, in lint_command
app.run(argv)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\main\application.py", line 375, in run
self._run(argv)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\main\application.py", line 363, in _run
self.initialize(argv)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\main\application.py", line 343, in initialize
self.find_plugins(config_finder)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flakeheaven_patched_app.py", line 166, in find_plugins
self.check_plugins.load_plugins()
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\plugins\manager.py", line 422, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flakeheaven_patched_plugins.py", line 51, in map
yield func(plugin, *args, **kwargs)
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\plugins\manager.py", line 420, in load_plugin
return plugin.load_plugin()
File "C:\Users\mjurado3\workspace\lava.venv\lib\site-packages\flake8\plugins\manager.py", line 168, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "S" due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\Users\mjurado3\workspace\lava>'.`

Does this command only work on linux?

@PhilippPlank
Copy link
Contributor

It seems not to work with Windows. You can look at the linting issues here: https://github.com/lava-nc/lava/actions/runs/3204188629/jobs/5235186915

Copy link
Contributor

@bamsumit bamsumit left a comment

Choose a reason for hiding this comment

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

Hi @Michaeljurado24, thanks for the PR. I have commented on my thoughts on the code and suggested some changes.

src/lava/proc/rf/process.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
src/lava/proc/rf/process.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
src/lava/proc/rf/models.py Outdated Show resolved Hide resolved
@bamsumit
Copy link
Contributor

bamsumit commented Oct 7, 2022

BTW @Michaeljurado24, can you email me, I think it's better we have a 1:1 meeting.

@Michaeljurado42
Copy link
Contributor Author

BTW @Michaeljurado24, can you email me, I think it's better we have a 1:1 meeting.

Sure thing. I could not find your email so I sent you a 'connect' request on LinkedIn with my email so we can collaborate more closely on this

@Michaeljurado42 Michaeljurado42 marked this pull request as ready for review October 24, 2022 21:29
@Michaeljurado42
Copy link
Contributor Author

I am not exactly sure why the RF neuron no decay test is failing for Ubuntu rn since i tried it on a Ubuntu machine and it passed... I have a suspicion it is caused by a slight floating point difference and will look into it.

@Michaeljurado42
Copy link
Contributor Author

I saw that @bamsumit accepted the PR 4 days ago.
Does that mean that "Run CI / Unit Test Code + Coverage (ubuntu-latest) (pull_request) Failing after 9m" is okay? On every machine I have tried it on it has passed which makes it sort of hard to figure out what to change for that one test.

@PhilippPlank
Copy link
Contributor

I saw that @bamsumit accepted the PR 4 days ago. Does that mean that "Run CI / Unit Test Code + Coverage (ubuntu-latest) (pull_request) Failing after 9m" is okay? On every machine I have tried it on it has passed which makes it sort of hard to figure out what to change for that one test.

An approval just means that the feature and the code quality is okay. All unit tests must still pass, before we can merge the PR. I restarted the unit tests.

@PhilippPlank PhilippPlank added the 1-feature New feature request label Nov 4, 2022
@PhilippPlank PhilippPlank added this to the Release v0.6 milestone Nov 4, 2022
Copy link
Contributor

@PhilippPlank PhilippPlank left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you for your contribution.

@PhilippPlank PhilippPlank merged commit 3bd7106 into lava-nc:main Nov 7, 2022
@Michaeljurado42 Michaeljurado42 deleted the rf_neurons branch November 7, 2022 11:53
@Michaeljurado42
Copy link
Contributor Author

Looks good. Thank you for your contribution.

Thank you all as well for the help and for answering both my logistical and technical questions.

@PhilippPlank PhilippPlank linked an issue Nov 21, 2022 that may be closed by this pull request
8 tasks
monkin77 pushed a commit to monkin77/thesis-lava that referenced this pull request Jul 12, 2024
* Added code for floating point rf and rf_iz neurons. Need to move toward fixed point

* Fixed RF process.

* Added fixed point for rf neurons. Floating point rf behavior looks weird

* Added modified rf activation for floating point

* fixed fixed_pt rf_iz neuron

* moved location of scale threshold function to be in line with lif

* moving scale_threshold back to abstract rf model class since rf_iz uses the same method

* added state_exp. Removed most of the deepcopies. Removed some defaults. Fixed formatting

* removed accidental print statement

* Refactored rf and rf_iz class to look like sdn. Added comments and test code for rf floating point process model

* Cleaned up test_resonator_process.py

* Added fixed point unit tests for rf and rf_iz

* Lava implementation of RF neurons matches lava-dl. RF unit test currently hanging after merge from main

* Removed temporary testing files. Fixed liniting errors

* Fixed typo

* Clarified comments

* increase specificity of unit tests

* Added comments and cleaned up test code. Added additional fixed point test for rf neurons

* Rf unit test fails to spike due to floating point error on some machines. Fixed the error

* Increase magnitude of input to rf float no decay unit test to encourage spiking

* Made floating point rf test possibly more robust to floating point errors

* fixed linting errors

* Removed useless abs() op in unit test. Added small enhacement to make unit test more robust

* Slight change to test float no decay to test for periodic spiking

* Add abs value to statement checking for proper spike periodicity for rf neurons

* Simplify unit test and see if it passes run ci

Co-authored-by: Jurado <[email protected]>
Co-authored-by: PhilippPlank <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add rf and rf_iz neurons to lava
3 participants