Repository navigation
fix(inference): a GPU decode step that fails mid-generation is an error - #796
Merged
Merged
Conversation
When the backend returned nothing for a decode step, or a step produced no candidate tokens (how a failed command buffer is reported), the decode loop stopped and returned the tokens it had. The caller built the result with error: None, so a generation cut short by a GPU fault was reported as a complete one. The loop now returns the reason with its outcome, and the result carries it as an error alongside the tokens produced before the failure. The mock GPU backend can be told to fail after a number of steps.
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.
A GPU decode step that fails mid-generation is an error
What was wrong
The fused GPU decode loop has two exits for a step that went wrong: the backend returned nothing for the step, or the step produced no candidate tokens (which is how the backend reports a failed command buffer). Both did
break, and the loop returned the tokens it had.generate_streamingthen built theGenerateResultwitherror: None. A generation cut short by a GPU fault came back as a complete, successful one, just shorter.What changes
DecodeLoopOutcomecarrieserror: Option<GenerateError>, set at both exits with the step number and how many tokens the loop had produced.generate_streamingputs it on the result, alongside the tokens generated before the failure. A loop that ends atmax_tokensor an end-of-sequence token still has no error.MockGpuBackend::failing_after(steps)makes the mock'sdecode_tokenanswerNoneafter a number of successful steps, so this path is testable.Evidence
a_gpu_decode_step_that_fails_mid_generation_is_reportedruns the publicgeneratewith the mock: a backend that never fails producesmax_tokenstokens and no error (the control); one that fails after two steps produces fewer tokens and must carry an error. With main's decode loop and caller (df20de1e) and the new mock, the test fails at "a generation cut short by a failed step must carry an error". With the fix it passes, as does a second test on the loop directly.Full
larql-inferencesuite: 1,974 passed, 0 failed.cargo fmt --checkandcargo clippy -p larql-inference --lib --tests --benches --no-deps -D warningsclean.Not covered