ChatRWKV icon indicating copy to clipboard operation
ChatRWKV copied to clipboard

Update pip package RWKV.model and v2/chat.py to support LoRA

Open RafaRed opened this issue 2 years ago • 4 comments

Update pip package RWKV.model and v2/chat.py to support LoRA based on Blealtan/RWKV-LM-LoRA implementation.

Notice that pip package need to be uploaded again with the new changes to work.

RafaRed avatar Apr 05 '23 17:04 RafaRed

Won't this break everything that uses the rwkv PIP package? It's trying to access attributes on lora. Why not have it as a keyword argument that defaults to None, that way existing code can keep working.

Also, what happens if the model is "preconverted"? I'm assuming it won't work correctly if that part has already occurred, so probably would want to add checks for whether it's a preconverted model before doing the lora part.

KerfuffleV2 avatar Apr 06 '23 20:04 KerfuffleV2

@KerfuffleV2 you are right about attributes, Need to change then to optional. About the preconverted I don't know, did not perform any tests about it yet.

RafaRed avatar Apr 08 '23 14:04 RafaRed

About the preconverted I don't know, did not perform any tests about it yet.

I'm almost certain it couldn't work. Those tensors may be in a different format like u8. They will also have some additional fields like mx, my, rx, ry (maximums, minimums related to quantization).

So it may be possible to support that but I'm pretty positive it would need special handling. Probably the easiest approach at first is to just raise an exception if Lora is specified and the model file has been preconverted.

KerfuffleV2 avatar Apr 09 '23 08:04 KerfuffleV2

IMO the LoRA merging should go before the conversion since there are too many things happening during converting the model (including the xy quantizing, etc.). +1 on disallowing LoRA when pre-converted model is specified.

Blealtan avatar Apr 09 '23 14:04 Blealtan