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

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

Merged
merged 2 commits into from Feb 25, 2024

Conversation

chenpan321
Copy link
Contributor

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.

chenpan321 and others added 2 commits February 24, 2024 15:28
Program should always fail if arch_version or program 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.

Signed-off-by: Pan Chen <chenpan321@qq.com>
Copy link
Collaborator

@saharNooby saharNooby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a revelation for me! I did not know that Python is allowed to disable assertions.

This means we need to rewrite all Python code in rwkv.cpp to get rid of assertions and replace them with ifs. Probably later.

@saharNooby saharNooby merged commit 2a8735e into RWKV:master Feb 25, 2024
13 of 14 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants