Add support for non-incremental decoding + unit test #973
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
As documented in #959, enabling the key-value cache for a model in generation was giving reasonable results whereas passing in a model without key-value cache enabled produced junk.
The cause: Although we originally supported incremental decoding and non-incremental decoding, this was lost in a refactor somewhere. The result was that the generate function was always ONLY passing in a single token at a time for context, therefore without a key-value cache to keep those values in memory, it was essentially producing random output.
Didn't we have a test for this?: We technically had a test for the decoder here but this only compares a single forward pass. Values won't diverge until we get into the area where the key-value cache is used. So we had to add a test for this scenario in generation.
Changelog
Test plan