Code Monkey home page Code Monkey logo

rwkv-onnx's Introduction

rwkv-onnx

A converter and basic tester for rwkv V5 onnx

supports

  • fp16, fp32
  • onnx opsversions 15/17/18
  • file sizes > 2GB
  • cuda, cpu, tensorRT, mps

Note: converter requires protobuf 3.20.0

Install with pip install protobuf==3.20.0

rwkv-onnx's People

Contributors

harrisonvanderbyl avatar

Stargazers

 avatar STYLIANOS IORDANIS avatar  avatar Bai Feng avatar  avatar  avatar  avatar Jonny Li avatar db avatar Matthieu / Tinycoaching avatar Lockinwize Lolite avatar MaPl avatar Mario Garcia avatar  avatar Vitaly Zadorozhny avatar  avatar Ulysses avatar Nikolaus Schlemm avatar Jeff Carpenter avatar  avatar 张铁明 avatar Hugefiver avatar  avatar Roger GOU avatar Daxiong avatar Jesus Zazueta avatar Oleksii Halahan avatar percent73 avatar Jarrett Ye avatar  avatar Bernhard J. Conzelmann avatar Ziming Huang avatar gowithwind avatar  avatar  avatar czc avatar Maks avatar  avatar Sofian Mejjoute avatar Zafar Ansari avatar

Watchers

Vitaly Zadorozhny avatar  avatar

rwkv-onnx's Issues

how to convert rwkv-5 model?

i used the convert.py to convert the rwkv-5 model ,when i used the test.py to test if it was successful,i failed.

[?] Select model: 
 > RWKV_24_2048_32_15.onnx

['AzureExecutionProvider', 'CPUExecutionProvider']
[?] Select execution providers(use space bar to select checkboxes): 
 > [ ] AzureExecutionProvider
   [ ] CPUExecutionProvider

[]
2024-05-18 15:30:52.673417593 [W:onnxruntime:, graph.cc:3593 CleanUnusedInitializersAndNodeArgs] Removing initializer 'PreTrainedTensor_4'. It is not used by any node and should be removed from the model.
2024-05-18 15:30:52.673432693 [W:onnxruntime:, graph.cc:3593 CleanUnusedInitializersAndNodeArgs] Removing initializer 'PreTrainedTensor_1'. It is not used by any node and should be removed from the model.
2024-05-18 15:30:52.673435491 [W:onnxruntime:, graph.cc:3593 CleanUnusedInitializersAndNodeArgs] Removing initializer 'PreTrainedTensor_0'. It is not used by any node and should be removed from the model.
tensor(float) 2048 24
(48, 2048)
(24, 40, 64, 64)
/.local/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
  0%|                                                    | 0/19 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "rwkv-onnx/ds/../test.py", line 120, in <module>
    logits, state, state2 = model.forward(token,state, state2)
  File "rwkv-onnx/ds/../test.py", line 66, in forward
    outputs = sess.run(output_names, inputs)
  File "/.conda/envs/py10/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 220, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: instatewkv9 for the following indices
 index: 0 Got: 40 Expected: 32
 Please fix either the inputs/outputs or the model.

The convert.py may not fit the rwkv-4-world-169m.

I have tried to convert the weight file which i download from https://huggingface.co/RWKV/rwkv-4-world-169m with convert.py. I found the following problems.

  • All of the keys of weight file begin with 'rwkv.' compared to convert.py.
  • The .att. in convert.py should be replaced with .attention..
  • The value of rwkv.blocks.0.attention.time_decay is a 1d tensor. The headsnume and headsize in convert.py can't unpacke from w[f"rwkv.blocks.0.attention.time_decay"].shape

I don't know how to fix the third problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.