-
Notifications
You must be signed in to change notification settings - Fork 15
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
Model Freezing #113
Comments
Copying @ElliottKasoar's original comment from #81
|
I think generally we need to understand its behaviour a little better before answering most of this definitively, but my initial thoughts:
My feeling is there are probably enough caveats/complications that unfrozen would be best as the default, so more or less anything a user throws at the library can work. Ideally we'd probably then strongly encourage users looking to optimise inference to freeze their models, either via pt2ts, which is what I mostly used, or our interface (C++ docs are limited, and I'm not sure I tested that at all). Having the option built into FTorch seems like a useful thing to add though. There definitely seems to be some strange behaviour e.g. trying to change the model device (see discussion/linked issue here and note at the end of this), the errors I had using the model with forpy, the numerical differences etc. Some of those issues may be related, and none so far seem to be too challenging:
So arguably most of what we need do is confirm and document these potential issues. Once we have a handle on the limitations, I think generally we should be able to say that there's no reason not to freeze the model for inference. |
@ElliottKasoar Originally commented in #103:
No changes are currently included, and less directly applicable to the main FTorch library, although there are still interactions e.g. freezing the model can allow InferenceMode to be enabled when loading the model.
Freezing is currently the "default" when tracing in pt2ts.py, but not for scripting, despite potentially improving performance.
Freezing appears to (sometimes) introduce numerical errors when saving the reloading (differences ~10^-6), and can seem to lead to issues loading with Forpy too.
Questions for @ElliottKasoar:
The text was updated successfully, but these errors were encountered: