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

Semantic pointer names may consume all RAM when iterating/recursing #244

Closed
arvoelke opened this issue Apr 29, 2020 · 2 comments · Fixed by #246
Closed

Semantic pointer names may consume all RAM when iterating/recursing #244

arvoelke opened this issue Apr 29, 2020 · 2 comments · Fixed by #246
Milestone

Comments

@arvoelke
Copy link
Contributor

arvoelke commented Apr 29, 2020

Self-binding to a depth of 20-30 can easily consume all of the available RAM (the example here is 33MB but in my application it was consuming 38GB of RAM). Specifically, iteratively/recursively building up a semantic pointer may cause its name to grow exponentially in length. I accidentally 'crashed' my desktop a few times trying to figure out what was going on here. Minimal example:

import nengo_spa
import numpy as np

n_iter = 20  # warning: don't set this any higher

sp = nengo_spa.SemanticPointer(np.ones(8), name="X").unitary()
for i in range(n_iter):
    sp += sp * 0.123456789
 
print("%dMB - %s..." % (len(sp.name) / (1024**2), sp.name[:128]))
33MB - (((((((((((((((((((((X).unitary())+(((X).unitary())*(0.123456789)))+((((X).unitary())+(((X).unitary())*(0.123456789)))*(0.123456...
@jgosmann
Copy link
Collaborator

My first instinct is to limit the length of the generated name. It's solely to give the Semantic Pointer a human recognizable name, but that function is lost at a certain length anyways.

@arvoelke
Copy link
Contributor Author

arvoelke commented May 1, 2020

Great, I've suggested PR #246 to truncate the names.

arvoelke added a commit that referenced this issue May 29, 2020
Fixes #244. 1 KB was chosen somewhat arbitrarily, but it seems long enough to capture the majority of use cases where someone might want to read the name, while being a cheap amount of memory relative to the resource requirements of the semantic pointer itself and how it will be used.
arvoelke added a commit that referenced this issue May 29, 2020
Fixes #244. 1 KB seems long enough to capture the majority of use cases
where someone might want to read the name, while being a cheap amount
of memory relative to the resource requirements of the semantic pointer
itself and how it will be used.
@jgosmann jgosmann added this to the 1.0.2 milestone Jun 10, 2020
jgosmann pushed a commit that referenced this issue Jun 14, 2020
Fixes #244. 1 KB seems long enough to capture the majority of use cases
where someone might want to read the name, while being a cheap amount
of memory relative to the resource requirements of the semantic pointer
itself and how it will be used.
jgosmann pushed a commit that referenced this issue Jun 14, 2020
Fixes #244. 1 KB seems long enough to capture the majority of use cases
where someone might want to read the name, while being a cheap amount
of memory relative to the resource requirements of the semantic pointer
itself and how it will be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants