Giter Site home page Giter Site logo

Comments (7)

fbarchard avatar fbarchard commented on June 16, 2024

Note that the following code, to check for linux kernel support, does not work in chromium sandbox?

#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__)
#define ARCH_REQ_XCOMP_PERM 0x1023
#define XFEATURE_XTILEDATA 18
/* SetTileDataUse() - Invoke syscall to set ARCH_SET_STATE_USE */
static bool SetTileDataUse(void) {
  if (syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA)) {
    return false;
  }
  return true;
}
#endif

Is there another way to test for OS support?

from cpuinfo.

mingfeima avatar mingfeima commented on June 16, 2024

Note that the following code, to check for linux kernel support, does not work in chromium sandbox?

#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__)
#define ARCH_REQ_XCOMP_PERM 0x1023
#define XFEATURE_XTILEDATA 18
/* SetTileDataUse() - Invoke syscall to set ARCH_SET_STATE_USE */
static bool SetTileDataUse(void) {
  if (syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA)) {
    return false;
  }
  return true;
}
#endif

Is there another way to test for OS support?

@malfet Does this repo has a CI to test the PRs?

from cpuinfo.

mingfeima avatar mingfeima commented on June 16, 2024

#231

from cpuinfo.

fbarchard avatar fbarchard commented on June 16, 2024

There are a couple more issues with amx detect, but I'm not sure they are in the scope of pytorch/cpuinfo

detect os support for amx on windows, linux etc.
detect/enable amx within chromium sandbox (can't do syscall)
enable amx. the syscall is currently required before using amx.

But I assume the reason amx is disabled by default is it has a high cost to thread switches, so it would be good to enable amx once we actually know we'll be using it
So it would be good to decouple AMX detection from enabling it.

unclear if it is intentional, but the amx intrinsics header is only on for 64 bit, not 32 bit x86.
But from what I can tell, the cpu and compiler (with assembly) can do amx in 32 bit OS's

I think these may be beyond the scope of cpuinfo and/or not entirely solvable? So this issue can be closed

from cpuinfo.

mingfeima avatar mingfeima commented on June 16, 2024

@fbarchard I think enabling AMX is not in the scope of pytorch/cpuinfo. The thing is we are using some detection method from onednn in pytorch which is not aligned with other functionalities (which are using cpuinfo). And we received requests to remove the onednn amx detection, and replace with cpuinfo amx detection.

As you have just mentioned, enabling AMX will require a syscall, e.g. syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA) right now.

The detection and enabling should be decoupled as you said. Currently in pytorch, amx will be ONLY used inside onednn so you don't have to worry about the initialization. But we are trying to use amx intrinsics in some particular CPU kernels, one good example will be the int4packed_gemm which is used weight only quantization in LLM. And it will be something like:

if (cpuinfo_x86_has_amx_bf16()) {
   if (syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA)) {
      TORCH_CHECK(false, "Failed to enable AMX on CPU.");
       return;
   }
   int4packed_gemm_amx(...);
} else {
  // fallback to avx512f
  int4packed_gemm_avx512(...);
}

from cpuinfo.

bbharti avatar bbharti commented on June 16, 2024

@mingfeima I will suggest we add enabling AMX to pytorch/cpuinfo. If an app is not using OneDNN, it will be helpful to all those apps and user base. Tying it just to OneDNN is not right approach. May be I didnt understand your response.

from cpuinfo.

mingfeima avatar mingfeima commented on June 16, 2024

@mingfeima I will suggest we add enabling AMX to pytorch/cpuinfo. If an app is not using OneDNN, it will be helpful to all those apps and user base. Tying it just to OneDNN is not right approach. May be I didnt understand your response.

sure, that's just the our original plan:) we will replace all the platforms checks currently implementing through onednn to cpuinfo.

from cpuinfo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.