Generating each token from a large model requires a full forward pass, and passes are sequential -- token N+1 can't start until token N is done. Speculative decoding speeds this up by having a small, fast "draft" model guess several tokens ahead, then having the large "target" model verify all of them in a single pass instead of generating them one at a time.
Write simulate_speculative_decoding(draft_tokens, target_tokens). Count how many leading tokens match between the two (the draft's accepted prefix), then return (accepted, output_tokens) where output_tokens is the accepted prefix plus exactly one more token from target_tokens when one is available beyond what was accepted -- the target model's own correction or, if the whole draft was accepted, its next token generated normally.
No results yet
Run your code to check it against the examples, or submit to run every test.