NVIDIA / NVIDIA/cutlass

[BUG] Compile error from including `"cute/tensor.hpp"` when building with MSVC with `/permissive-` option

Open
#3,065 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

? - Needs Triage bug CUTLASS C++ inactive-30d inactive-90d
Dominant language
C++
Stars
10.5k
Forks
2.1k
Avg merge
3d 11h
Merged PRs (30d)
7

Description

Which component has the problem?

CUTLASS C++

Bug Report

Describe the bug
When compiling for C++20 with MSVC and including "cute/tensor.hpp", I observed the following compile error:

D:\source\cutlass\include\cute\stride.hpp(299,46): error C3545: 'Ints': parameter pack expects a non-type template argument [D:\test\cute_cpp_test\build\cute_cpp_test_program.vcxproj]
  (compiling source file '../main.cc')
      D:\source\cutlass\include\cute\stride.hpp(299,46):
      the template instantiation context (the oldest one first) is
          D:\source\cutlass\include\cute\atom\mma_traits.hpp(70,8):
          while compiling class template partial specialization 'cute::MMA_Traits<cute::UniversalFMA<D,A,B,C>,>'
          D:\source\cutlass\include\cute\atom\mma_traits.hpp(86,35):
          while processing the default template argument of 'cute::Layout '
          D:\source\cutlass\include\cute\layout.hpp(98,51):
          see reference to alias template instantiation 'cute::LayoutLeft::Apply<Shape>' being compiled
          with
          [
              Shape=cute::tuple<cute::_1,cute::_1>
          ]
          D:\source\cutlass\include\cute\stride.hpp(369,26):
          see reference to function template instantiation 'auto cute::compact_major<cute::LayoutLeft,Shape,cute::C<1>,0x0>(const Shape &,const Current &)' being compiled
          with
          [
              Shape=cute::tuple<cute::_1,cute::_1>,
              Current=cute::C<1>
          ]
          D:\source\cutlass\include\cute\stride.hpp(357,27):
          see reference to function template instantiation 'auto cute::detail::compact<cute::LayoutLeft,Shape,Current>(const Shape &,const Current &)' being compiled
          with
          [
              Shape=cute::tuple<cute::_1,cute::_1>,
              Current=cute::C<1>
          ]

D:\source\cutlass\include\cute\atom\mma_traits.hpp(86,19): error C2976: 'cute::Layout': too few template arguments [D:\test\cute_cpp_test\build\cute_cpp_test_program.vcxproj]
  (compiling source file '../main.cc')
      D:\source\cutlass\include\cute\layout.hpp(99,8):
      see declaration of 'cute::Layout'

D:\source\cutlass\include\cute\atom\mma_traits_sm61.hpp(51,19): error C2976: 'cute::Layout': too few template arguments [D:\test\cute_cpp_test\build\cute_cpp_test_program.vcxproj]
  (compiling source file '../main.cc')
      D:\source\cutlass\include\cute\layout.hpp(99,8):
      see declaration of 'cute::Layout'

D:\source\cutlass\include\cute\atom\mma_traits_sm61.hpp(68,19): error C2976: 'cute::Layout': too few template arguments [D:\test\cute_cpp_test\build\cute_cpp_test_program.vcxproj]
  (compiling source file '../main.cc')
      D:\source\cutlass\include\cute\layout.hpp(99,8):
      see declaration of 'cute::Layout'

D:\source\cutlass\include\cute\atom\copy_traits_sm100.hpp(53,21): error C2976: 'cute::Layout': too few template arguments [D:\test\cute_cpp_test\build\cute_cpp_test_program.vcxproj]
  (compiling source file '../main.cc')
      D:\source\cutlass\include\cute\layout.hpp(99,8):
      see declaration of 'cute::Layout'

There is also a similar error when compiling for C++17 with MSVC with the /permissive- option.

Steps/Code to reproduce bug

Create the following files:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.28)

project(cute_cpp_test CXX)

set(USE_CXX_20 OFF)

if (USE_CXX_20)
    # C++20 does not work
    set(CMAKE_CXX_STANDARD 20)
else()
    # C++17 and /permissive- also does not work
    set(CMAKE_CXX_STANDARD 17)
    add_compile_options("/permissive-")
endif()

add_executable(cute_cpp_test_program ${CMAKE_CURRENT_SOURCE_DIR}/main.cc)

set(CUTLASS_INCLUDE_DIR "D:/source/cutlass/include")
set(CUDA_INCLUDE_DIR "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4/include")

target_include_directories(cute_cpp_test_program PRIVATE ${CUTLASS_INCLUDE_DIR} ${CUDA_INCLUDE_DIR})

main.cc:

#include "cute/tensor.hpp"

int main() {
    return 0;
}

From the directory containing those files:

cmake -B ./build -S . -G "Visual Studio 18 2026"
cmake --build ./build --config Debug

Expected behavior
The code builds successfully.

Environment details (please complete the following information):

  • Environment location: Local Windows 11 Machine
  • Compiler: MSVC 19.50.35724.0
  • CUTLASS commit: 3476ddb7bd6ca4161a0169103ceaa20ce0eb891f

Additional context
I encountered this issue while trying to update an existing codebase to C++20.

The docs here seem to imply that CUTLASS should be usable from C++20 code.

Applications should list /include within their include paths. They must be compiled as C++17 or greater.

Upon further testing based on the suggestion here, it appears that this is also an issue for C++17.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided CMakeLists.txt and main.cc using MSVC, C++17 with /permissive-, and C++20. Start in include/cute/stride.hpp and follow the reported instantiation through include/cute/layout.hpp and include/cute/atom/mma_traits.hpp. Done means including cute/tensor.hpp compiles successfully in both configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.