RWKV / rwkv.cpp

INT4/INT5/INT8 and FP16 inference on CPU for RWKV language model
MIT License
1.41k stars 95 forks source link

fix: use ValueError instead of `assert` on argument checks #164

Closed chenpan321 closed 7 months ago

chenpan321 commented 7 months ago

This pull request fixes a small issue on script python/merge_lora_into_ggml.py.

Program should always fail if arch_version or data format does not satisfy the preconditions in the program. However, the file merge_lora_into_ggml.py uses assert statements, sometimes being ignored under high optimization level. We uses if-statements here, where those preconditions would always execute, whether the environment enable assert stateuements or not.

Ref: https://stackoverflow.com/questions/61826628/what-is-the-advantage-if-any-of-using-assert-over-an-if-else-condition . Here, our checks are still in effect when -O flag is enabled, so if __debug__: (implied in assert statements) is not necessary.