-
Notifications
You must be signed in to change notification settings - Fork 22.2k
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
LogCumsumExp #26411
Comments
I would like to work on this. |
@opheliagame see #20240 (comment) for |
HI @agadetsky , I created a PR #26832 for this issues. But I am not sure If I am doing it right in the implementation part, I stop just before the line mask = torch.tril(torch.ones(last_dim_size, last_dim_size)).unsqueeze(0) in python implementation. It would be great if you can review THTensor_(logcumsumexp) in THTensormoreMath.cpp. I want to make sure I am going in right direction. Many thanks! |
Hi, Yes I could try work on it. |
@agadetsky what do you use to loop over multi-dimensional tensor in C++, I am trying to compute the convert value of the tensor to 1s and 0s |
@michiboo unfortunately I am not familiar with pytorch C++ implementation. |
@michiboo Hi, are you still working on this issue? |
I will try to submit a PR for this by the weekend, if not needed urgently. PS: @agadetsky I can't seem to assign myself the issue 😅 |
@pandeykartikey thank you, waiting for your PR |
@pandeykartikey you can use implemented cummax for stable implementation of logcumsumexp |
@agadetsky Wouldn't that create issues while building a feature because It can undergo drastic changes in implementation as it is being reviewed right now? |
@pandeykartikey better to ask someone else, atm I don't know, but I think that without cummax it is harder to implement logcumsumexp properly |
@pandeykartikey hi! do you have any progress? |
@pandeykartikey cummax is merged now (#30881), is it possible to implement logcumsumexp for you using cummax? |
Hi @agadetsky, I am almost done with the implementation. Only the backprop and tests are left. But I am having trouble figuring out the backprop algorithm. Can you help me with that? |
@pandeykartikey what's the status on this ? Still open ? |
@whoiscris yes, maybe @anjali411 will finish it soon here #32876 |
up, #32876 still needs to be finished |
🚀 Feature
Add numerically stable cumulative logsumexp function. Also we have associated PR on
cummax
that is needed for numerically stable implementation (#20240).Motivation
This is useful when computing sum of probabilities and have different applications.
Pitch
Torch has
cumsum
andcumprod
so I suggestlogcumsumexp
to be added.Alternatives
Current workaround for me and for people that need it can be written as follows (it is quite fast, only overhead for converting between numpy/torch):
UPDATE: code above is not always numerically stable. Still most numerically stable, but slow way to compute
logcumsumexp
is use for-loop:The text was updated successfully, but these errors were encountered: