fastai / swiftai

Swift for TensorFlow's high-level API, modeled after fastai
Apache License 2.0
457 stars 51 forks source link

Swift for tensorflow seems dead #22

Open dwt opened 3 years ago

dwt commented 3 years ago

Is there already a path forward for this technology, or is it back to python for now?

philipturner commented 2 years ago

Is there already a path forward for this technology

Yes, there is. Swift for TensorFlow continues to be developed under the S4TF organization. The organization is named with the S4TF acronym to avoid any conflict with Apple's trademark for Swift or Google's trademark for TensorFlow 😄

I do have one question, though. Will FastAI be willing to acknowledge s4tf/s4tf as the successor to tensorflow/swift-apis and accept new pull requests to fastai/swiftai? Or should the S4TF organization maintain a fork of the repository? It seems most appropriate to limit S4TF to forking repositories made by tensorflow.

The new repository isn't yet 100% ready to compile as a standalone package. There is still a lot of work to do regarding documenting how to compile it, and hosting the CTensorFlow/X10 2.9 binaries in the "releases" section. Currently, only TF 2.4 binaries exist and they aren't easy to locate.

CC: @saeta @sgugger

jph00 commented 2 years ago

We'd be delighted to support any way we can :)

Just be sure to at-mention me on any issues/PRs/etc since that's how I get notified.

philipturner commented 2 years ago

This is amazing! Thank you so much!

philipturner commented 2 years ago

@jph00

SwiftAI's code base is extremely small (unlike s4tf/models), so it should be easy to get up to speed. But I'm not that familiar with how this repository works. My understanding is that you have a series of Jupyter notebooks for your FastAI course (where are lessons 13 and 14 as stated on the README?). Then, a script transforms the notebooks into Swift files for a general-purpose Swift package.

There are some limitations which may or may not change how you do things. Swift-Colab only supports Colab, and dropped support for Docker. Someone is trying to add Docker support back in, but I don't think that work will be upstreamed soon. When it is upstreamed, I want JupyterLab support as well. Docker is only compatible with Nvidia GPUs for the average person (ROCm doesn't run on consumer GPUs), but I want other GPU platforms to have equal support. For now, is it possible to execute your scripts inside Colab or from the command line?

Second, S4TF takes multiple minutes to compile. Please read through Swift for TensorFlow integration on the README for an explanation. In the Swift Tutorials section, there is a clever workaround for skipping the long build time. S4TF is no longer a system library, so you have to depend on it via SwiftPM. If a notebook depends on multiple libraries that recursively depend on S4TF, you have to "wait 3 minutes" multiple times even with the clever workaround.

I have a solution for this planned for Swift-Colab v2.3*: linking external Swift packages as if they were system libraries. That optimization should be applied to SwiftAI when it's available, as an alternative build option in Package.swift. See https://github.com/s4tf/s4tf/pull/17 for an example of using multiple build options in a package manifest. But for now, we can only depend on S4TF via a SwiftPM dependency, and have to deal with any recompilation bottlenecks that occur.

*This planned release is blocking work on s4tf/models (formerly tensorflow/swift-models). In the last official tutorial from S4TF, they download swift-models as an external dependency. This will trigger a double compilation of S4TF until Swift-Colab v2.3 is released. But for SwiftAI's tutorial notebooks, no such bottleneck should occur. And if one does, SwiftAI is active and I can address it (unlike Google's notebooks).

Also, S4TF is quite stable now, while the README of SwiftAI gives a different impression. I'm embracing backward compability because so few people use S4TF now, and any breakage of support could make even less people use it. https://github.com/fastai/swiftai/issues/57 will be an exception to this rule.