Skip to content

[METAX] InfiniTensor Build error: unable to deduce 'const auto' from mcMalloc in runtime_.h #597

Description

@bitzyz

When InfiniTensor compiling with WITH_METAX=1, the build fails with:
error: unable to deduce 'const auto' from 'mcMalloc'

This occurs in src/cuda/metax/runtime_.h when the header is included by source files
compiled with g++ (not mxcc).

Root Cause

The current implementation directly assigns function pointers:

static constexpr auto Malloc = mcMalloc;

This causes type deduction issues when the header is included in files compiled
by the standard host compiler (g++), as it cannot properly deduce the function
pointer type in this context.

Expected Behavior

Compare with src/cuda/moore/runtime_.h, which uses lambda wrappers:

  static constexpr auto Malloc = [](auto&&... args) {
    return musaMalloc(std::forward<decltype(args)>(args)...);                                            
  };                                                                                                     

This approach avoids the type deduction problem since the lambda's type is
directly generated by the compiler.

Suggested Fix

Replace direct function pointer assignments with lambda wrappers for consistency
with the Moore backend implementation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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