Skip to content

Conversation

@masahi
Copy link
Member

@masahi masahi commented Oct 4, 2022

This is a followup to #12865. We have some tests that depend on a dot product instruction of the target architecture, such as VNNI (cascadelake) and ARM sdot/udot. These tests are currently skipped on CI, but to properly test them on an instance that does support such instructions, I'm introducing requires_arm_dot and requires_cascadelake decorator.

@tkonolige @driazati

@masahi masahi marked this pull request as ready for review October 5, 2022 06:42
@masahi masahi force-pushed the cpu-feature-detect branch from 4299b08 to 8e93a57 Compare October 5, 2022 06:42
@masahi masahi force-pushed the cpu-feature-detect branch from 8e93a57 to 52bdb86 Compare October 5, 2022 09:32
arch = platform.machine()
# Only linux is supported for now.
if arch == "x86_64" and sys.platform.startswith("linux"):
return "avx512_vnni" in open("/proc/cpuinfo", "r").read()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bunch of different extensions to vnni. Do we use any of those extensions? If so, we might need another check for them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the output of cpuinfo, avx512_vnni is the only relevant extension. There are 8 bit and 16 bit input variants, and we only use the former.

requires_arm_dot = Feature("arm_dot", "ARM dot product", run_time_check=_arm_dot_supported)


requires_cascadelake = Feature("cascadelake", "x86 CascadeLake", run_time_check=_has_vnni)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zen4 supports vnni also. Maybe we need another check to make sure the platform is intel.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting... I'll just rename this to requires_vnni, then. There shouldn't be any difference in Intel vs AMD vnni.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests use a cascade lake target though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, yes. I feel that having both requires_cascadelake and requires_zen4 is redundant. Enabling vnni for zen4 would require minor change in topi x86. So when we make such change, we can parameterize the target string in the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, even if we parameterize the target string to have both -mcpu=cascadelake and -mcpu=zen4, we can't run both targets on the same environment... I should stick to requires_cascadelake, then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a check for intel based on the output from cpuinfo. Only linux is supported for now.

Copy link
Member

@driazati driazati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if AWS has machines that support vnni or sdot/udot? We can add them to CI pretty easily if so

masahi and others added 4 commits October 6, 2022 04:53
Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>
Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>
@masahi
Copy link
Member Author

masahi commented Oct 5, 2022

Do you know if AWS has machines that support vnni or sdot/udot

I know that our aarch64 instance supports udot/sdot, so they are tested now. For vnni, we need cascadelake or newer instance, and you've told me recently that our CI job does run on Intel(R) Xeon(R) Platinum 8259CL CPU https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-12857/6/pipeline/60/#step-72-log-65.

if line.startswith("hw.optional.arm.FEAT_DotProd"):
return bool(int(line.split(":", 1)[1]))
elif sys.platform.startswith("linux"):
return True
Copy link
Member Author

@masahi masahi Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a linux aarch64 at hand, so I cannot add the right check here. This is ok for our aarch64 CI since it supports sdot/udot, but it is broken for rasp etc.

I tried return "dot" in open("/proc/cpuinfo", "r").read() but the test was skipped in CI.

@masahi masahi merged commit 7fc35da into apache:main Oct 6, 2022
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…apache#12980)

* introduce requires_arm_dot

* introduce requires_cascadelake

* lint

* requires_cascadelake -> requires_vnni

* Update tests/python/integration/test_meta_schedule_auto_tensorize.py

Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>

* Update python/tvm/testing/utils.py

Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>

* Revert "requires_cascadelake -> requires_vnni"

This reverts commit 6931ca2.

* check for intel in requires_cascadelake

* black

* fix

Co-authored-by: driazati <9407960+driazati@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants