Skip to main content

Fast Math Program Synthesis Tool:

Tool for generating fast approximations of floating point math by (ab)using the floating point representation.

This tool was produced for the ICML paper "Faster Activation Functions at the Edge for Post-Training Speedups" link.

Usage:

Basic usage (ffcc tool):

$ ffcc -e "silu(x) = x / (1 + exp(-x))" --approx=exp --tune=[-6,6] -o torch

This should give you, after some tuning time, the following torch module:

import torch
from torch import nn, Tensor


class FastSilu(nn.Module):
        def forward(self, x: Tensor) -> Tensor:
                v0 = (1064873152.0 + (-12104086.0 * x))
                v1 = v0.type(torch.int32).view(torch.float32)
                return (x / (1.0 + v1))

Flags explained:

  • -e $expr provides the input expression to approximate
  • -approx=exp approximates exponentiation (log and div can be added as well, though div support is experimental)
  • -tune=[-6,6] performs gradient-descent based constant tuning on the domain $[-6,6]$
  • -o torch prints the resulting code as a pytorch module

Development Environment:

There's a flake.nix file for all nixos users.

The python dependencies are managed through uv. Setting everything up usually involves running a combination of uv venv; uv sync --all-extras; source .venv/bin/activate.

To run tests, use lit tests/filecheck, there are no pytests yet.

There is an ffcc-opt tool available for testing.

License:

ffcc - fast float compiler - Copyright (C) 2025 Anton Lydike

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Metadata

Release files for ffcc 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ffcc 0.1.3
File Size Uploaded Provenance
ffcc-0.1.3.tar.gz 90.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ffcc 0.1.3
File Interpreter ABI Platform
ffcc-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 154.0 kB

Release files / ffcc-0.1.3.tar.gz

Download URL ffcc-0.1.3.tar.gz
Size 90.2 kB
Tags Source
SHA-256 checksum
How to use checksums
00c058228e26061ef7369207a4dec29e50d5cce40cd8413d50bfaa0aaac9992e
BLAKE2b-256 checksum
How to use checksums
ae76372c0426bc49582dab7c91b945482e68ccb22f5f6648f660f00f37cdf01f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ffcc-0.1.3-py3-none-any.whl

Download URL ffcc-0.1.3-py3-none-any.whl
Size 63.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49ea54c5564ceb286d0c95801bdcbe04a300d53df6ffeadd83b465bdbc4e5281
BLAKE2b-256 checksum
How to use checksums
8c5a72e5cfced27994f15921ee2194719b3690673ad0f512123fdc03de81657d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ffcc 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page