Skip to content

[Enh] More readable DslError traceback#703

Open
sjfeng1999 wants to merge 1 commit into
mainfrom
pr/enh-dsl-error-tracing
Open

[Enh] More readable DslError traceback#703
sjfeng1999 wants to merge 1 commit into
mainfrom
pr/enh-dsl-error-tracing

Conversation

@sjfeng1999

@sjfeng1999 sjfeng1999 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Motivation

close #671

Technical Details

Test Plan

Test Result

Submission Checklist

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py with DSLCompileError, MLIR diagnostic collection, and an opt-out (sys.excepthook) formatter.
  • Replace legacy MLIR diagnostic handling in jit_function.py with the new diagnostics utilities and wrap MLIR verification failures as DSLCompileError.
  • Add a debug env toggle (FLYDSL_DEBUG_SHOW_STACKTRACE) and install the excepthook from @flyc.jit / @flyc.kernel paths.

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 []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render JIT compile/verify errors as Python-native tracebacks

2 participants