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

Is there a way to export using torch.jit.script ? #41

Open
jprobichaud opened this issue Jul 19, 2024 · 1 comment
Open

Is there a way to export using torch.jit.script ? #41

jprobichaud opened this issue Jul 19, 2024 · 1 comment

Comments

@jprobichaud
Copy link

Thanks for this great repository!

I was wondering if there a way to export using torchscript? I tried a simple approach with torch.jit.script(model), but I get:

RuntimeError: 
Module 'RWKV_Block' has no attribute 'att_group_norm' :
  File "/data/workspaces/jp/LLMs/RWKV_Pytorch/src/model.py", line 229
        # 展平x并应用组归一化和门控
        if self.onnx_opset >= 18:
            x = self.att_group_norm(x.flatten(start_dim=1)) * g
                ~~~~~~~~~~~~~~~~~~~ <--- HERE
        else:
            x = x.flatten(start_dim=1) 
'RWKV_Block.time_mixing' is being compiled since it was called from 'RWKV_Block.forward'
  File "/data/workspaces/jp/LLMs/RWKV_Pytorch/src/model.py", line 319
        """
        if self.onnx_opset >= 17:
            x = x + self.time_mixing(self.ln1(x), state, i)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
            x = x + self.channel_mixing(self.ln2(x), state, i)
        else:

@uniartisan
Copy link
Collaborator

uniartisan commented Jul 20, 2024

Hey, we are moving to https://github.com/TorchRWKV/TorchRWKV6

To solve your problem, you can simply checkout to dev channel and add

import os
os.environ["RWKV_JIT_ON"] = "1"

to your code before you init your model.

demo.zip

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

No branches or pull requests

2 participants