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

Elide logits if the logits pointer parameter is NULL #107

Merged
merged 2 commits into from Jun 27, 2023

Conversation

LoganDark
Copy link
Contributor

@LoganDark LoganDark commented Jun 25, 2023

There is no need to calculate logits when it is not necessary, so perform some trickery to avoid calculating that part of the cgraph if logits is not actually going to be used.

Depends on #103

Discussed on #106 (comment)

rwkv.cpp Show resolved Hide resolved
@saharNooby
Copy link
Collaborator

Please add info about possibility of skipping logits calculation into documentation in rwkv.h. The commit description is already well written, and can be copy-pasted into the doc.

I would also suggest implementing it in PyTorch wrapper; but this is optional, especially given that the wrapper will be rewritten soon.

This speeds up sequence mode evaluations by up to 20% if you ingest
a large prompt and then only retrieve the logits at the very end.

Note that you must pass a NULL pointer to the logits parameter in
order to take advantage of this optimization.
@saharNooby saharNooby merged commit 84634c0 into RWKV:master Jun 27, 2023
12 checks passed
@LoganDark LoganDark deleted the logits-elision branch June 27, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants