Compiler for fast floating-point approximations
Project description
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 + (-12104085.0 * x))
v1 = v0.type(torch.int32).view(torch.float32)
return (x / (1.0 + v1))
Flags explained:
-e $exprprovides the input expression to approximate-approx=expapproximates exponentiation (loganddivcan be added as well, thoughdivsupport is experimental)-tune=[-6,6]performs gradient-descent based constant tuning on the domain $[-6,6]$-o torchprints 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/.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ffcc-0.1.2.tar.gz.
File metadata
- Download URL: ffcc-0.1.2.tar.gz
- Upload date:
- Size: 87.8 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5897354c49524d12763989347fb4b5ae3bb79ba8120f61f63c1906e2b1f65a6
|
|
| MD5 |
cfcdcdca3ddcb3515ede366113f21f53
|
|
| BLAKE2b-256 |
dc9df3a9f7c5eda60846428974fd14c6a709ebaae11f8d52268bad08ccd71b22
|
File details
Details for the file ffcc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ffcc-0.1.2-py3-none-any.whl
- Upload date:
- Size: 63.8 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df1fee73605ddbebec3ea848ba7417caa0bf22c581f1fafbec4c8162006a627e
|
|
| MD5 |
fe5174accc3184fff17e97fccee0a0ff
|
|
| BLAKE2b-256 |
67d65bf1bbf8960922e85f5390615a9c79103bcc300eb44ce849c456398357ea
|