Skip to content

Add riscv half-precision floating point detection#375

Merged
malfet merged 4 commits intopytorch:mainfrom
ken-unger:riscv-zvfh
Apr 15, 2026
Merged

Add riscv half-precision floating point detection#375
malfet merged 4 commits intopytorch:mainfrom
ken-unger:riscv-zvfh

Conversation

@ken-unger
Copy link
Copy Markdown
Contributor

Add cpuinfo_has_riscv_zfh() and cpuinfo_has_riscv_zvfh for fp16 detection.

The motivation here is to enable this runtime detection support in xnnpack for its rvv fp16 kernels. (xnnpack uses this library)

Copy link
Copy Markdown
Collaborator

@fbarchard fbarchard left a comment

Choose a reason for hiding this comment

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

LG. can you confirm this is vector arithmetics and is there a different detect for conversion?
another isa that would be great to detect is the 8 bit dot product

@ken-unger
Copy link
Copy Markdown
Contributor Author

ken-unger commented Mar 4, 2026 via email

@fbarchard
Copy link
Copy Markdown
Collaborator

Perfect. For XNNPack running on SiFive X280 its supposed to have zfh/zvfh, but the qemu I use doesnt support fp16, and cpuinfo didnt detect them.
x280 also has int8 dotproduct .. eg.
vqdot.[vv,vx]
Both would be useful for writing good microkernels for xnnpack. Its not clear its worth supporting zvfhmin - thats for lower end cpus like SiFive P650

@ken-unger
Copy link
Copy Markdown
Contributor Author

Is there a maintainer who could review and merge (if accepted) this PR? Thank you.

@fbarchard
Copy link
Copy Markdown
Collaborator

As we are waiting on this to land, and then roll into XNNPack, I've added similar code in hardware-config.c for XNNPack.
google/XNNPACK#9892

It should be removed in favor of cpuinfo when possible.

@malfet
Copy link
Copy Markdown
Contributor

malfet commented Apr 15, 2026

@pytorchbot rebase

@malfet malfet merged commit d05fbcd into pytorch:main Apr 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants