tlc-pack / relax

Apache License 2.0
193 stars 58 forks source link

[Tracking Issue] Relax Training M0 #413

Open Ubospica opened 1 year ago

Ubospica commented 1 year ago

There has been increased interest from the community in using TVM for training. Relax, the next generation graph level IR of TVM, also faces the demand of training model.

We are building a training workflow on Relax, including:

The training APIs can serve many needs. You will be able to:

This work is mainly done by @SiriusNEO and @Ubospica, with the help from @tqchen @junrushao @MasterJH5574 @Hzfengsy @spectrometerHBH et al.

Further introduction of our work:

A jupyter notebook tutorial of the training APIs can be found here.

Detailed explanation of the AD pass, and its limitations can be found here.

Currently a large part of our work has been merged into the mlc repo. Now our work is tracked at this issue.

The APIs are still changing. We will update the tutorial within a period of time after the API is modified.

slyubomirsky commented 1 year ago

Discussion from the Feb. 7, 2023 community meeting after this work was presented:

slyubomirsky commented 1 year ago

I would be curious to hear about the plans for further developing AD in Relax. We should be able to support all of the language's features by building up the "tape" within Relax (this could be accomplished through PackedFuncs).

We could consider using the approach in Relay's general-purpose AD pass, where the "tape" is built up using a closure: https://github.com/apache/tvm/blob/main/src/relay/transforms/higher_order_gradient.cc (I think we should aim to make AD as general as we can, as this would allow us to target all manner of diverse models for training).

Edit: One issue with using PackedFuncs to represent the tape would be that the data structure and the updates would be opaque to the language. This would be fine for a first pass on a prototype, but would really prevent us from doing optimizations on it. This could be a good impetus to develop proper data structures for Relax, so that might be something to consider.