-
Notifications
You must be signed in to change notification settings - Fork 114
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
spiders_reader on long sentences crashes #156
Comments
@kinianlo Hi, In general, I think it's better to avoid any hidden manipulation at the tensor network level, since physical changes of this form can alter dramatically training. Perhaps a better solution here would be a spider-specific tensor ansatz which arranges the spiders reader output e.g. as follows, producing a chain of 3-legged spiders.
|
@dimkart Yes I agree messing things at the tensornetwork level would be dangerous.
|
Yes, it's much easier to do this at the reader level. In fact, LinearReader gives you this functionality out-of-the-box: spider_chain_reader = LinearReader(Spider(AtomicType.SENTENCE, 2, 1)) I guess adding an extra option to SpidersReader is OK, but it would be cleaner to just add the above line at the end of |
Symptom
The use of
spiders_reader
on long sentences leads to excessive time and memory useexample
The following example uses
spiders_reader
on a sentence with 14 words, each given a 4-dimensional vector. The spider computes the element wise product between these vectors. On a modern computer this should be done in milliseconds. Instead, the following took more than 2 seconds.It crashes (due to memory) if I increase the dimension from 4 to 5 on my machine.
This is my guess of what's going on:
the spider with (14+1) legs got converted to a rank-15
CopyNode
intensornetwork
whose data is a dense array of size 2^15 during.to_tn()
.Perhaps there should a safeguard which splits the large
CopyNode
into smaller ones. Similar to this in discopy:https://github.com/discopy/discopy/blob/006c3966a1906edfbd4b1ac1bfe943e1a709c0e0/discopy/frobenius.py#L380.
The text was updated successfully, but these errors were encountered: