Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement clever joint truncations pattern matcher #13

Open
hsmajlovic opened this issue Dec 21, 2023 · 0 comments
Open

Implement clever joint truncations pattern matcher #13

hsmajlovic opened this issue Dec 21, 2023 · 0 comments
Labels
compiler Compiler-related item enhancement New feature or request research Research-related item

Comments

@hsmajlovic
Copy link
Member

It would be nice if the compiler could figure out that only one truncation is necessary for F instead of for each intermediate multiplication separately: F = A * B + C * D

Example from DTI code:

vW_prev = vW[l].copy()
>>>
# vW[l] = vW[l] * MOMENTUM - dW[l] * LEARN_RATE
# vW[l] = vW[l].trunc(mpc.fp)
# temp = vW[l] * (MOMENTUM + 1) - vW_prev * MOMENTUM
# temp = temp.trunc(mpc.fp)
# W[l] = W[l] + temp
>>> should be
vW[l] = vW[l] * MOMENTUM - dW[l] * LEARN_RATE
W[l] = W[l] + vW[l] * (MOMENTUM + 1) - vW_prev * MOMENTUM

vb_prev = vb[l].copy()
>>>
# vb[l] = vb[l] * MOMENTUM - db[l] * LEARN_RATE
# vb[l] = vb[l].trunc(mpc.fp)
# temp_v = vb[l] * (MOMENTUM + 1) - vb_prev * MOMENTUM
# temp_v = temp_v.trunc(mpc.fp)
# b[l] = b[l] + temp_v
>>> should be
vb[l] = vb[l] * MOMENTUM - db[l] * LEARN_RATE
b[l] = b[l] + vb[l] * (MOMENTUM + 1) - vb_prev * MOMENTUM
@hsmajlovic hsmajlovic added enhancement New feature or request compiler Compiler-related item research Research-related item labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Compiler-related item enhancement New feature or request research Research-related item
Projects
None yet
Development

No branches or pull requests

1 participant