Skip to content

Cortex-M: lower transcendental unary operators through the activation LUT - #22155

Merged
rascani merged 1 commit into
pytorch:mainfrom
rascani:cortex-m-activation-lut
Aug 26, 2026
Merged

Cortex-M: lower transcendental unary operators through the activation LUT#22155
rascani merged 1 commit into
pytorch:mainfrom
rascani:cortex-m-activation-lut

Conversation

@rascani

@rascani rascani commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

cortex_m::quantized_activation is a 256-entry int8 table with the qparams folded in. Only sigmoid, tanh, silu and gelu were registered; this adds log, log2, log10, log1p, sqrt and rsqrt, functional and in-place.

Not exp: its codomain is unbounded, so an output scale covering the calibrated maximum leaves almost no resolution elsewhere -- over [-8, 8] the table holds two distinct levels across x in [-2, 2].

Poles saturate, and the undefined region beyond a pole continues the boundary value, so log below zero reads -128 and rsqrt below zero reads 127. Emitting the output zero point there would sit a mid-range value below the rail and break monotonicity. That case is reachable rather than theoretical: a shared quantization spec can widen an operand's grid across zero even where the tensor never goes.

The tables are evaluated through torch rather than math, which raises where these functions are undefined instead of returning the -inf or nan the table needs.

Silero VAD's magnitude sqrt now lowers, so its expected counts move with this.

Authored with Claude Code.

… LUT

cortex_m::quantized_activation is a 256-entry int8 table with the qparams folded
in. Only sigmoid, tanh, silu and gelu were registered; this adds log, log2,
log10, log1p, sqrt and rsqrt, functional and in-place.

Not exp: its codomain is unbounded, so an output scale covering the calibrated
maximum leaves almost no resolution elsewhere -- over [-8, 8] the table holds two
distinct levels across x in [-2, 2].

Poles saturate, and the undefined region beyond a pole continues the boundary
value, so log below zero reads -128 and rsqrt below zero reads 127. Emitting the
output zero point there would sit a mid-range value below the rail and break
monotonicity. That case is reachable rather than theoretical: a shared
quantization spec can widen an operand's grid across zero even where the tensor
never goes.

The tables are evaluated through torch rather than math, which raises where these
functions are undefined instead of returning the -inf or nan the table needs.

Silero VAD's magnitude sqrt now lowers, so its expected counts move with this.

Authored with Claude Code.
@pytorch-bot

pytorch-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22155

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 3dd9bb3 with merge base baafd7e (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@rascani
rascani requested a review from AdrianLundell August 25, 2026 18:31
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 25, 2026
@rascani
rascani requested a review from psiddh August 25, 2026 18:31
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@rascani
rascani merged commit 784b5c8 into pytorch:main Aug 26, 2026
198 of 200 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants