-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
tracker: generate
composability refactor
#30810
Comments
Adding the WIP label, so you don't get pinged by the stale bot 🤖 |
Could you elaborate on the "prefill" component? My impression is that this step converts the prompt into a KV cache, i.e. "pre-filling" the KV component for the tokens that are fixed. If that's correct, this component could probably serve double duty (as an exit point from the |
IMHO, upsteam of (part of?) the "generate outputs" step in the decoding loop should be a templated |
Correct, it can be made a public function with that additional purpose. The difference between the prefill for
That's a good idea, adding it to the diagram! Thank you for the suggestions 💛 |
@gante maybe you could create sub-issues to track progress on dependent sub tasks and centralize visibility for any in-progress work? |
@tylerweitzman after this plan is complete, streaming should yield all model outputs (and not just the tokens). The tricky part is timeline, as this competes with other projects 🤗 I'm currently working on #28981 and #32685, which have a higher priority |
@tylerweitzman workaround available here: #29545 |
generate
+ composability = more use cases with minimal rewritesAs I write this issue,
generate
is mostly a sequential monolith. Many internal blocks were carved into functions over the last two years, but navigating there as a beginner is still messy. It is also very challenging to adaptgenerate
to different tasks and/or modalities, forcing us to overwrite the entire generate function (e.g. RAG, MusicGen). All these aspects make using, documenting, maintaining, and testinggenerate
a challenge.This issue is a tracker for the refactor of
generate
, where we aim to build the structure outlined in this board. Key ideas for this refactor:👉 All models can use the base
generate
API👉 Reduce if/else blocks
👉 Reduce the barriers to entry for new decoding methods/modalities/use cases
👉 Reduce per-model overwrites when possible
👉 Add unit tests
👉 Add documentation regarding the structure of
generate
Tasks
input_ids[:, -1:]
), so we don't compute variables regarding the latest token twice;use_cache=True
and cache length < input length - 1;_expand_inputs_for_generation
needs to be changed (it copied inputs before prefill, we will need to copy prefill outputs)yield
/yield from
instead ofreturn
pipeline
position_ids
.LogitsWarper
in this step (it's a copy ofLogitsProcessor
)generate
[From this point onwards the tasks are only a sketch, need more detailed planning when we get there]
prepare_inputs_for_generation
, VLMs also have their special preprocessing steps, ...)prepare_inputs_for_generation
?generate
from models that have a custom implementationThe text was updated successfully, but these errors were encountered: