[Enh] More readable DslError traceback#703
Open
sjfeng1999 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the readability of FlyDSL compile-time errors by introducing a structured DSLCompileError with source-location chains and installing an exception hook to present a filtered, user-focused Python traceback by default.
Changes:
- Add
python/flydsl/compiler/diagnostics.pywithDSLCompileError, MLIR diagnostic collection, and an opt-out (sys.excepthook) formatter. - Replace legacy MLIR diagnostic handling in
jit_function.pywith the new diagnostics utilities and wrap MLIR verification failures asDSLCompileError. - Add a debug env toggle (
FLYDSL_DEBUG_SHOW_STACKTRACE) and install the excepthook from@flyc.jit/@flyc.kernelpaths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/flydsl/utils/env.py | Adds show_stacktrace debug option to control whether to show raw tracebacks. |
| python/flydsl/compiler/kernel_function.py | Installs the DSL excepthook when kernel wrappers are created. |
| python/flydsl/compiler/jit_function.py | Switches to the new diagnostics collection + error type; wraps verification failures. |
| python/flydsl/compiler/diagnostics.py | New module implementing diagnostic records, MLIR location flattening, and traceback filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+56
to
+61
| if loc.is_a_file(): | ||
| filename, line = loc.filename, loc.start_line | ||
| if not filename or filename.startswith("<") or not line: | ||
| return [] # synthetic source we cannot point a user at | ||
| end_col = getattr(loc, "end_col", 0) or 0 | ||
| return [SourceFrame(filename, line, getattr(loc, "start_col", 0) or 0, end_col or None)] |
Comment on lines
+86
to
+90
| class DSLCompileError(RuntimeError): | ||
| """Raised when MLIR verification or an MLIR pass pipeline fails.""" | ||
|
|
||
| def __init__(self, message: str, *, diagnostics: Optional[list] = None): | ||
| self.diagnostics = diagnostics or [] |
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.
Motivation
close #671
Technical Details
Test Plan
Test Result
Submission Checklist