Skip to content

[BUG] Using CuTe DSL in REPL crashes Python #3413

Description

@janekb04

Which component has the problem?

CuTe DSL

Bug Report

Describe the bug
Trying to use CuTe DSL in the Python REPL causes an [Internal Error] and crashes the interpreter.

Steps/Code to reproduce bug

$ CUTE_DSL_SHOW_STACKTRACE=1 python3
Python 3.12.3 (main, Jun 19 2026, 12:46:00) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cutlass import cute
>>> @cute.jit
... def run(f):
...     f()
...
>>> run(lambda: 0); print("ran")
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl/dsl_packages/cutlass/base_dsl/ast_preprocessor.py", line 764, in transform_function
    lines, start_line = inspect.getsourcelines(function_pointer)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/inspect.py", line 1260, in getsourcelines
    lines, lnum = findsource(object)
                  ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/inspect.py", line 1089, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl/dsl_packages/cutlass/base_dsl/dsl.py", line 866, in jit_wrapper
    BaseDSL._preprocess_and_replace_code(func)
  File "/usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl/dsl_packages/cutlass/base_dsl/dsl.py", line 833, in _preprocess_and_replace_code
    fcn_ptr = func._dsl_object.run_preprocessor(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl/dsl_packages/cutlass/base_dsl/dsl.py", line 2372, in run_preprocessor
    return self._run_preprocessor_impl(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl/dsl_packages/cutlass/base_dsl/dsl.py", line 2388, in _run_preprocessor_impl
    transformed_ast = preprocessor_session.transform(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl/dsl_packages/cutlass/base_dsl/ast_preprocessor.py", line 1016, in transform
    transformed_tree = self.transform_function(
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl/dsl_packages/cutlass/base_dsl/ast_preprocessor.py", line 790, in transform_function
    raise DSLRuntimeError(
cutlass.base_dsl.common.DSLRuntimeError:
[Internal Error] The compiler hit a problem it could not trace back to your code.
This is a bug in the DSL, not a mistake in your kernel.

Detail: Failed to parse function run

What to do:
  Please report this with the snippet above and your kernel.
  Re-run with CUTE_DSL_SHOW_STACKTRACE=1 to include the full technical detail.

====================================================================================================
$ 

Expected behavior
I would expect either a successful run or a clear error message, whichever is the intended behavior in this case. In either case, Python shouldn't crash.

Environment details (please complete the following information):

  • Environment location: [Docker]

Additional context
No additional context.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions