Skip to content

Keep interface validation active under python -O - #15

Open
adenzhou1350 wants to merge 1 commit into
deepseek-ai:mainfrom
adenzhou1350:codex/explicit-interface-validation
Open

adenzhou1350 wants to merge 1 commit into
deepseek-ai:mainfrom
adenzhou1350:codex/explicit-interface-validation

Conversation

@adenzhou1350

Copy link
Copy Markdown

Summary

  • replace user-facing assert checks for unsupported begin/hint arguments
    with explicit validation that remains active under python -O
  • reject a preallocated output_idx whose dtype disagrees with
    indices_type, also before output allocation or backend dispatch
  • add a CPU-only regression test that replaces the CUDA extension with a
    minimal fake while exercising the real Python interface with PyTorch tensors

Testing

python tests/test_interface_validation.py
# 4 tests passed

python -O tests/test_interface_validation.py
# 4 tests passed

python -OO tests/test_interface_validation.py
# 4 tests passed

python -m py_compile deep_select/interface.py tests/test_interface_validation.py
python -m ruff check deep_select/interface.py tests/test_interface_validation.py
git diff --check origin/main...HEAD

The same regression test projected onto unmodified commit
0f03b68748b304863fdf0181a11458d04ae533a9 fails all three expected-rejection
cases under python -O: the removable assertions allow the fake backend to
receive unsupported arguments or a mismatched output dtype. Its positive
control still passes. The candidate rejects all three invalid calls before
backend dispatch and sends the valid call to the backend exactly once.

Scope

This is Python interface validation only. It does not change CUDA kernels,
supported argument combinations, numerical behavior, or performance.

Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
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.

1 participant