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

Restore ability to get logits from generation? #588

Closed
moyix opened this issue Mar 14, 2022 · 7 comments · Fixed by #637
Closed

Restore ability to get logits from generation? #588

moyix opened this issue Mar 14, 2022 · 7 comments · Fixed by #637
Assignees
Labels
feature request New feature or request help wanted This issue needs assistance

Comments

@moyix
Copy link

moyix commented Mar 14, 2022

It's often useful when generating samples to be able to get the logits / probabilities of the generated tokens (e.g. for ranking suggestions). It looks like this used to be available but was removed by 7aed133. It would be great if this functionality could be ported to the most recent version of the code.

I attempted to hack it back in, but must have messed something up because it made evaluation ~3.5x slower; I assume I accidentally introduced some GPU-CPU copies but unfortunately I don't really understand the Megatron/Deepspeed code well enough to see how to fix it. That branch is here: https://github.com/moyix/gpt-neox/tree/return_logits

Edit: fixed the link to my attempt at implementation, not sure how that happened

@moyix moyix added the feature request New feature or request label Mar 14, 2022
@StellaAthena StellaAthena added the help wanted This issue needs assistance label Mar 16, 2022
@moyix
Copy link
Author

moyix commented Mar 18, 2022

Okay, I think I managed to get it working (at least for my use case). I think the problem previously was that I was trying to save all 52K logits for every token. This version just saves the logit for the token that was actually chosen (actually it saves the normalized log-probability of the token, which is what I really wanted — but it's easy enough to undo that if raw logits are desired):

main...moyix:logit_try2

Happy to make this into a PR if desired!

@StellaAthena
Copy link
Member

@moyix Have you looked at this code? It’s not currently exposed by generate.py but looks like it has the desired functionality. Maybe we can clean up the generate.py interface and introduce this as an option?

@moyix
Copy link
Author

moyix commented Apr 5, 2022

I hadn't seen that! I will try to take a look and see if I can expose it in generate.py.

@StellaAthena
Copy link
Member

@moyix Any updates on this?

@Kyle1668
Copy link
Contributor

I can take this on if no one else is working on this.

@StellaAthena
Copy link
Member

@Kyle1668 please do :)

@Kyle1668
Copy link
Contributor

Great! Feel free to assign me the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request help wanted This issue needs assistance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants