Skip to content

Compiling on Python 3.14 fails due to redefinition errors #114

@blepping

Description

@blepping

I believe this is a Python 3.14 support issue but that may be incorrect. I am not sure what the proper fix here is, but if you're running into errors like these:

      /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/c++config.h:349:1: error: redefinition of ‘void std::__terminate()’
        349 |   inline void __terminate() _GLIBCXX_USE_NOEXCEPT
            | ^ ~~~~~~~~~
      In file included from /usr/include/c++/15.2.1/cassert:45,
                       from <command-line>:
      /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/c++config.h:349:15: note: ‘void std::__terminate()’ previously defined here
        349 |   inline void __terminate() _GLIBCXX_USE_NOEXCEPT
            |               ^~~~~~~~~~~
      /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/c++config.h:582:1: error: redefinition of ‘constexpr bool
      std::__is_constant_evaluated()’
        582 |   __is_constant_evaluated() _GLIBCXX_NOEXCEPT
            | ^ ~~~~~~~~~~~~~~~~~~~~~
      /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/c++config.h:582:3: note: ‘constexpr bool std::__is_constant_evaluated()’ previously
      defined here
        582 |   __is_constant_evaluated() _GLIBCXX_NOEXCEPT
            |   ^~~~~~~~~~~~~~~~~~~~~~~
      /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/c++config.h:652:1: error: redefinition of ‘void std::__glibcxx_assert_fail()’
        652 |   __glibcxx_assert_fail()
            | ^ ~~~~~~~~~~~~~~~~~~~
      /usr/include/c++/15.2.1/x86_64-pc-linux-gnu/bits/c++config.h:652:3: note: ‘void std::__glibcxx_assert_fail()’ previously defined here
        652 |   __glibcxx_assert_fail()
            |   ^~~~~~~~~~~~~~~~~~~~~
      ninja: build stopped: subcommand failed.

Commenting out the include of cassert in setup.py allowed me to successfully install the package.

Ref:

"-Xcompiler", "-include,cassert", # fix error occurs when compiling for SM90+ with newer CUDA toolkits

I ran into this issue on ArchLinux which recently updated to Python 3.14. Also using the most recent CUDA (13.1 I think).

edit: Once you get past that issue, you're going to run into Triton compile failures due to Triton trying to use ast.Num which no longer exists in Python 3.14. The caveman fix is to hack code_generator.py in Triton (the error should show you the path to this, somewhere in the venv) to use ast.Constant instead.

If you really want to get it working with your current Triton install (the issue may be fixed in nightly Triton versions) you can try this hack. Note: This shouldn't break anything but you're on your own when you start editing files inside random packages, especially if it's based on advice from random anonymous people on the internet.

Add this line after the imports:

ast_Num = getattr(ast, "Num", ast.Constant)

So the top of code_generator.py should roughly look like this:

from .errors import (CompilationError, CompileTimeAssertionFailure, UnsupportedLanguageConstruct)

ast_Num = getattr(ast, "Num", ast.Constant)

def check_identifier_legality(name, type):

Then change the two places where ast.Num appear to ast_Num.

            lb = iter_args[0] if len(iter_args) > 1 else self.visit(ast_Num(0))
            ub = iter_args[1] if len(iter_args) > 1 else self.visit(node.iter.args[0])
            step = iter_args[2] if len(iter_args) > 2 else self.visit(ast_Num(1))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions