feat: Add two-step generation API (forward_pass + relevance_pass) and forward-only-generation task#13
Open
neerajaryaai wants to merge 5 commits intodlb_v2from
Open
feat: Add two-step generation API (forward_pass + relevance_pass) and forward-only-generation task#13neerajaryaai wants to merge 5 commits intodlb_v2from
neerajaryaai wants to merge 5 commits intodlb_v2from
Conversation
…lize_dlbacktrace() configurable
…ly-generation for clarity
…d multi-token generation and explanation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR introduces a new
forward-only-generationtask type torun_task()that enables fast token generation without computing relevance scores. This is useful when users only need generated tokens and want to minimize memory usage and latency.It also adds a two-step API (
forward_pass()+relevance_pass()) that decouples multi-token generation from relevance computation, giving users full control over when and which tokens to explain.Changes
New Feature:
forward-only-generationTask"forward-only-generation"torun_task()methodeos_token_idparameternode_iobetween generation steps to reduce memory footprintImproved Visualization API
showandinline_formatparameters tovisualize_dlbacktrace()methodNew Feature: Two-Step
forward_pass()+relevance_pass()APIforward_pass()— Runs autoregressive generation for N tokens, storing per-stepnode_iosnapshots efficiently:input_values,output_values,layer_hyperparams); shallow-copies immutable graph metadatagc.collect()between stepsgenerated_token_ids,complete_sequence, andnum_stepsrelevance_pass()— Computes relevance for selected tokens from a priorforward_pass():self.node_io_trace(populated byforward_pass())token_indicesto explain specific steps (e.g.,[0, 4, 9]) or all steps (None){'step_index', 'token_id', 'relevance'}dictsclear_traces()— Frees all stored snapshots, relevance data, and GPU cacheUsage Examples