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

Implemented FastKAN in TinyGrad #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

mdaiter
Copy link

@mdaiter mdaiter commented Sep 18, 2024

Hey hey!

Nice work with FastKAN. I got this running on Metal in TinyGrad, if it's of any interest. Really cool results, and very fast.

The only thing that's still a bit wonky / broken is plotting. I can take it out, if it helps merge it.

Best

@mdaiter
Copy link
Author

mdaiter commented Sep 18, 2024

Also:

from tinygrad import TinyJit
with Context(BEAM=2):
    fklayer = FastKANLayer(100, 100)
    x = Tensor.randn(8, 100)
    rbf = RadialBasisFunction()
    def fklayer_step():
        fklayer(x, use_layernorm=False)
    def fklayer_sum_backwards_test():
        fklayer(x).sum().backward()
    def rbf_test():
        rbf(x)
    %timeit -r10 -n1000 TinyJit(fklayer_step)
    %timeit -r10 -n1000 TinyJit(fklayer_sum_backwards_test)
    %timeit -r10 -n1000 TinyJit(rbf_test)

Results:

345 ns ± 157 ns per loop (mean ± std. dev. of 10 runs, 1,000 loops each)
304 ns ± 24.4 ns per loop (mean ± std. dev. of 10 runs, 1,000 loops each)
334 ns ± 43 ns per loop (mean ± std. dev. of 10 runs, 1,000 loops each)

^ran on Macbook Air with a M2 processor, stupidly fast :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant