fix: preserve error codes through BLS error paths - #454
Open
Swigler wants to merge 4 commits into
Open
Conversation
The BLS error code was always lost and replaced with INTERNAL because: 1. ResponseBatch had no error_code field - batch-level errors could only carry a message string, so the code was hardcoded to INTERNAL when reading them back. 2. THROW_IF_TRITON_ERROR discarded error codes - it extracted the message but threw PythonBackendException(message) without the code, so any path going through this macro lost the original error type. Fix: - Add error_code field to ResponseBatch struct - Add error code support to PythonBackendException (stored as int to keep the header lightweight) - Update THROW_IF_TRITON_ERROR to preserve the error code - Propagate error_code through all batch error write/read paths: ExecuteBLSRequest, SendBLSDecoupledResponse, ProcessRequests, ProcessBLSResponseDecoupled, and InferRequest::Exec Fixes: triton-inference-server/server#7804 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The initial fix covered the primary ResponseBatch path but four secondary paths still dropped error codes to INTERNAL: - CreateTritonErrorFromException: hardcoded INTERNAL, now reads the code from PythonBackendException - RequestExecutor::Infer re-throw: wrapped message without code, now passes ErrorCode() through - Stub::ProcessRequests execute catch: never wrote error_code to ResponseBatch, now captures and writes it - InferRequest::Exec outer catch: one-arg PbError, now passes the code from the caught exception Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add test models and client script that verify error codes are preserved when Python models are chained via BLS, covering the bug reported in triton-inference-server/server#7804. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR preserves Triton error codes as exceptions and batch-level failures cross the BLS and shared-memory boundaries.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant M as Calling Python model
participant S as Python stub
participant B as Backend BLS executor
participant T as Target model
M->>S: exec()
S->>B: BLS request via shared memory
B->>T: Submit inference
T-->>B: Error response with Triton code
B-->>S: ResponseBatch with message and error_code
S-->>M: InferenceResponse with preserved TritonError code
Reviews (2): Last reviewed commit: "fix: preserve INTERNAL fallback for unco..." | Re-trigger Greptile |
When a PythonBackendException without an explicit error code was caught and rethrown in RequestExecutor::Infer, the two-arg constructor marked the default code (0/UNKNOWN) as explicitly present. This caused CreateTritonErrorFromException to use UNKNOWN instead of falling back to INTERNAL for setup/validation failures. Now only passes the error code through if the original exception actually carried one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Fixes triton-inference-server/server#7804
When Python models are chained via BLS, error codes (e.g.
NOT_FOUND,UNSUPPORTED) were lost and always becameINTERNAL. This PR preserves the original error code through all BLS error paths.Root cause
Three structural issues caused error codes to be dropped:
THROW_IF_TRITON_ERRORmacro — extracted the error message but discarded the error code when throwingPythonBackendExceptionResponseBatchstruct — had noerror_codefield, so batch-level errors were hardcoded toTRITONSERVER_ERROR_INTERNALExecuteBLSRequest,SendBLSDecoupledResponse,InferResponseComplete, and several other paths,PbErrorwas created without the error code from the caught exceptionChanges
src/pb_exception.hintto avoidtritonserver.hdependency)src/pb_utils.herror_codefield toResponseBatch; updateTHROW_IF_TRITON_ERRORto capture error codesrc/python_be.ccerror_codefromResponseBatchinstead of hardcoding INTERNAL; propagate inExecuteBLSRequestandSendBLSDecoupledResponsecatch blocks; initialize inPrepareResponseBatchsrc/request_executor.ccCreateTritonErrorFromExceptionandInfer()re-throwsrc/infer_request.ccerror_codefromResponseBatchtoPbErrorinExec(); preserve in outer catchsrc/pb_stub.ccProcessRequestscatch; write toResponseBatch; pass inProcessBLSResponseDecoupledTest
Added
examples/bls_error_code/with two test models and a client script:InferenceResponsewith a specificTritonErrorcodeerror_sourcevia BLS and reports the received codeTested on Triton 2.50.0 (r24.09) with an A100 GPU on RunPod:
Patched:
Stock (unpatched):
Test plan
🤖 Generated with Claude Code