[WIP] refactor: unifying return status of different backend implementation #1141
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.
📌 Description
We currently support kernel implementations from multiple backends (Cutlass, TRT-LLM-Gen, etc.), each of which uses its own return codes or error types. Handling these inconsistently with separate macros (
CUTLASS_CHECK
,TLLM_CHECK
, etc.) has become chaotic.In This PR, we
Status
class that can wrap and implicitly convert from various backend error types (cudaError_t
,cutlass::Status
, etc.).FLASHINFER_CALL
.Future API conventions
include/
will return aStatus
instead of using C++ exceptions.FLASHINFER_CALL
.Status
Status
error codes usingFLASHINFER_ERROR("message")
.csrc/
), parse the returnedStatus
and rethrow as C++ exceptions usingTORCH_CHECK
.This centralizes error handling, makes it easy to add new backends, and aligns FlashInfer with HPC-library practices while still supporting exception-based checks at the Python/C++ interface.
🔍 Related Issues
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commit
by runningpip install pre-commit
(or used your preferred method).pre-commit install
.pre-commit run --all-files
and fixed any reported issues.🧪 Tests
unittest
, etc.).Reviewer Notes