-
Notifications
You must be signed in to change notification settings - Fork 279
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
Failure to convert a torch model(generated by hummingbird) to torchscript #644
Comments
Hi! Yea tracing should definitely work because that is what we do internally when we generate TorchScript. We tried scripting time ago and it was hard to make it work in general. If you know exactly how many inputs do you have, maybe you can path Hummingbird and get rid of all the variable arguments. I will think a little bit more on this and see if there is another solution. |
@interesaaat does this means that "torch" model generated by hummingbird is fundamentally non-scriptable? |
As it is now probably yes. We can trace it, but not script it. I will take a look and see if we can solve this and make models also scriptable. |
Hi @interesaaat, thanks for the confirmation. Would it be possible for you to provide a successful torch->torchscript conversion example through |
Ah this should work out of the box if instead of using ‘torch’ when
converting the model you put ‘torch.jit’.
…On Thu, Oct 27, 2022 at 8:13 PM ShulinChen ***@***.***> wrote:
Hi @interesaaat <https://github.com/interesaaat>, thanks for the
confirmation. Would it be possible for you to provide a successful
torch->torchscript conversion example through trace?
I tried to leverage the provided hummingbird example:
https://github.com/microsoft/hummingbird/blob/main/notebooks/XGB-example.ipynb
, but so far haven't had luck getting tracing to work yet. See the
screenshot on how I tried to do the torch->torchscript conversion.
[image: Screen Shot 2022-10-27 at 11 12 23 PM]
<https://user-images.githubusercontent.com/8204913/198492919-11bb37cb-be3e-4819-b111-533888786383.png>
—
Reply to this email directly, view it on GitHub
<#644 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALWR52Y6VAUMSGJQMCLZBLWFNAFZANCNFSM6AAAAAARPOMPLA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@interesaaat Oh I do know that hummingbird can convert xgb to torchscript directly without issues. However, per what I have mentioned earlier:
A bit more context on my use case. Reason why I first convert XGB to torch is, that way I can stack the hummingbird-converted torch model with another torch model (think model ensemble). I am working on a case to ensemble classical models with DL torch models, by leveraging hummingbird as the bridge to convert xgb to torch, so that they can be combined into 1 torch model. |
I see. I have not tried but maybe if you trace the xgb model first and then trace the traced xgb model together with your other DL model maybe it works? Another option could be to you to debug how we do tracing of the model from within Hummingbird and copy the code externally to trace both the xgb model and your DL model. I think the problem you having with tracing externally is that your are not passing the input correctly. |
Context:
I have a use case which requires me to first train a XGB model, convert it to torch model through hummingbird, and later convert the torch model to torchscript. Note that converting XGB directly to torchscript model is not an option due to my use case. pseudo-code:
Stacktrace:
Things I have tried:
Instead of relying on scripting to convert torch to torchscript, I have also tried tracing with
However this doesn't work for me because model's inputs/outputs have to be Union[Tensor, Tuple[Tensor]] to be traceable.
The text was updated successfully, but these errors were encountered: