-
Notifications
You must be signed in to change notification settings - Fork 75
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
SP local inhibition optimization #783
Conversation
test update
is now UInt bla_() const small fixes in code cleanup
store cached neighbors in map, rather than vector. makes code easier to read.
as not needed, we compute this from hood.size()
now mapAllNeighbors() supports also the non-wrapping variant. ALso made const
return active columns as result
into common Neighborhood. Simplified code, all functionality still available with toggle wrap=true.
into one. Small performance loss, cleaner code.
which can save a check in hot-loop in SP (as center is excluded).
for local inh, "test 4" was not run at all.
access. optimization.
looks like float rounding err
was the problem here.
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.
@dkeeney when you have time, could I have first review, please?
The neighborhood logic may be a bit more complicated in SP now, but the speedup for SP.local_inhibition is very significant. Also I hope the logic is a bit better separated (SP, Topology) in this PR. I'll do some more small cleanup touches to the SP.cpp
Real32 initActiveDutyCycles3[] = {0.1f, 0.3f, 0.02f, 0.04f, 0.7f, 0.12f}; | ||
Real initBoostFactors3[] = {0, 0, 0, 0, 0, 0}; | ||
vector<Real32> trueBoostFactors3 = {1.25441f, 0.840857f, 1.47207f, | ||
1.41435f, 0.377822f, 1.20523f}; | ||
const vector<Real32> trueBoostFactors3 = {1.28586f, 0.795669f, 1.40094f, |
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.
I'm not 100% sure why the result values changed, but as long as it stays fixed over all CI, it shouldn't be a problem
Real32 initActiveDutyCycles4[] = {0.1f, 0.3f, 0.02f, 0.04f, 0.7f, 0.12f}; | ||
Real32 initBoostFactors4[] = {0, 0, 0, 0, 0, 0}; | ||
vector<Real32> trueBoostFactors4 = {1.94773f, 0.263597f, 4.33476f, | ||
3.549f, 0.00482795f, 1.59467f}; | ||
vector<Real32> trueBoostFactors4 = {54.598148, 7.38906, 121.51038, |
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.
the bug here (in a newly enabled test) was comparing in float
which resulted in rounding errors.
to include only the "without center" hood variant.
from Real, as spotted in Windows build.
src/test/unit/engine/RESTapiTest.cpp
Outdated
@@ -156,7 +156,8 @@ TEST_F(RESTapiTest, helloWorld) { | |||
EXPECT_STREQ(vm["result"].c_str(), "Hello World!") << "Response to GET /hi request"; | |||
} | |||
|
|||
TEST_F(RESTapiTest, example) { | |||
|
|||
TEST_F(DISABLED_RESTapiTest, example) { //FIXME started segfaulting in CI Debug |
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.
@dkeeney @Zbysekz do you have an idea why this would start failing, please?
The Debug CI simply segfaults (while?) running this test:
https://github.com/htm-community/htm.core/pull/783/checks?check_run_id=1080429326#step:5:525
I made no changes that should directly affect any functionality of NetworkAPI or RESTAPI, but something in SP might change.
I'm now testing w/o this test if it's the only thing.
OK, locally I reproduce the same error:
[ OK ] RESTapiTest.helloWorld (505 ms)
[ RUN ] RESTapiTest.example
Traceback (most recent call last):
File "../../setup.py", line 448, in <module>
"htm-bindings-check = htm.bindings.check:checkMain",
File "/home/mmm/.conda/envs/htmcore/lib/python3.7/site-packages/setuptools/__init__.py", line 161, in setup
return distutils.core.setup(**attrs)
File "/home/mmm/.conda/envs/htmcore/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/mmm/.conda/envs/htmcore/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/mmm/.conda/envs/htmcore/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/mmm/.conda/envs/htmcore/lib/python3.7/site-packages/setuptools/command/test.py", line 238, in run
self.run_tests()
File "../../setup.py", line 172, in run_tests
subprocess.check_call([cpp_tests])
File "/home/mmm/.conda/envs/htmcore/lib/python3.7/subprocess.py", line 328, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/mnt/store/devel/HTM/htm-community/nupic.cpp/build/Release/bin/unit_tests']' died with <Signals.SIGSEGV: 11>.
Does not say much :(, is there anything in bindings that should be altered too?
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.
I can confirm that it crashes in debug only, release is OK.
It crashes right here
It is because client->Get(message)
returned null_ptr
. What i briefly saw inside http lib, null_ptr
is possible in some case to return.
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.
thank you for looking into it! 👍
I can confirm that it crashes in debug only, release is OK.
strange it manifests only now. do you think it's something with httplib compiled in debug? (same as we don't do Py bindings in deb.), ie. should we just skip the test in Debug?
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.
hmm i am trying to understand this simple example from the lib
https://github.com/yhirose/cpp-httplib/blob/master/example/simplecli.cc i don't know res.error() could work. res is shared ptr. It throws
error: ‘class std::shared_ptr<httplib::Response>’ has no member named ‘error’
on me
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.
to get some error description, why the Get() returns null
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.
But then why it doesn't fail in master at the start of this branch right? CI was not changed right?
CI wasn't changed. I just checked the diff to master, this PR only touches internals of SP local inhibition (SP.inhibitColumnsLocal_()
, Topology.hpp
). Not even SP's "public API" was changed.
Maybe it just revealed some leakage in this library... from github it seems that they are making bugfixes. I will try newest version of that lib
cool, that'll be nice. If you'd just make a new PR, as it should pass master, and I'll then get it merged here.
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.
The bug in RESTapi must be something unrelated. It should not be too hard to find.
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.
I'd suggest we see if the update to cpp-httplib (there seems to be a lot of news) magically fixes our problem. If not, I'd just enable the test in Release and we can keep a separate issue for solving the Debug segfault later. If that sounds ok?
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.
ok yes. I already compile it,
and update to latest didn't solve it..
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.
Followup issue in httplib please in #884
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.
I have to assume you know the algorithm but from what you say it sounds like a reasonable approach. I don't see any glaring errors. You included a unit test for the new parts.
I approve this change.
Any thoughts @dkeeney on the problem with the httplib Get() function returning null? (mentioned above) |
as it crashes cpp-httplib in Debug. Should be unrelated to this PR, tracked in #884
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.
approving again. The RESTapi problem should be a separate PR.
Thank you for approvals, I'm happy local inhibition is quite usable now, thanks to community contribition from the original author. |
Yes this is nice :) Do you know why he is off the business? |
now idea.. submitted 2 PRs we worked on, and in a couple of days the profile completely disappeared off github. |
Followup to #776 (replaces, author @kineyev away from github)
This PR further improves SP speed in local inhibition in case of wrapAround=True neighbourhoods.
Main ideas:
See #776 for details and comments.