Skip to content

[QDP] centralized Python tests and default to single-process pytest to avoid CUDA OOM#1147

Open
viiccwen wants to merge 5 commits intoapache:mainfrom
viiccwen:centralized-qdp-python-testing
Open

[QDP] centralized Python tests and default to single-process pytest to avoid CUDA OOM#1147
viiccwen wants to merge 5 commits intoapache:mainfrom
viiccwen:centralized-qdp-python-testing

Conversation

@viiccwen
Copy link
Contributor

@viiccwen viiccwen commented Mar 8, 2026

Related Issues

closes #1146

Changes

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Test
  • CI/CD pipeline
  • Other

Why

This PR moves QDP Python tests into the top-level testing/qdp_python/ tree, switches the default Python test run to single-process (no -n auto), documents optional use of -n auto / -n N for faster runs, and fixes ty diagnostics for the affected tests.

How

Test layout

  • Moved qdp/qdp-python/tests/test_dlpack_validation.pytesting/qdp_python/test_dlpack_validation.py
  • Moved qdp/qdp-python/tests/test_quantum_data_loader.pytesting/qdp_python/test_quantum_data_loader.py

All Python tests are now under testing/ and discovered by root pytest with testpaths = ["testing"].

Makefile

  • test_python now runs:
    uv run pytest --cov --cov-report=term-missing --cov-report=html:htmlcov
    (single process; coverage sources from [tool.coverage.run] in pyproject when set).

Documentation

  • docs/qdp/testing.md
    • Added "Python tests" section: how to run (make test_python or uv run pytest ...).
    • Clarified that tests run in a single process by default to avoid GPU memory pressure.
    • Documented optional speed-up with -n auto or -n N when compute/GPU allow.
  • qdp/DEVELOPMENT.md
    • Updated QDP Python test path from qdp/qdp-python/tests to testing/qdp_python.

Type-checking (ty)

  • pyproject.toml
    • Added qumat_qdp and qumat_qdp.* to allowed-unresolved-imports so the optional qumat_qdp.loader import does not cause unresolved-import errors.
  • testing/qdp_python/test_quantum_data_loader.py
    • Introduced loader_cls fixture that skips when QuantumDataLoader is not available and returns the class (for type narrowing).
    • Replaced all QuantumDataLoader(...) usages with loader_cls(...) and removed redundant assert QuantumDataLoader is not None.
    • Dropped unnecessary # type: ignore on the import fallback.
  • testing/qumat/test_parameter_binding.py
    • Assigned get_backend_config(backend_name) to a variable, added assert cfg is not None, then used cfg.copy() to satisfy ty (possibly-missing-attribute on optional dict).

Other

  • uv.lock
    • Reflects current dependency resolution (e.g. qumat-qdp editable); any change shown is from lock refresh.

Checklist

  • Added or updated unit tests for all changes
  • Added or updated documentation for all changes

Copy link
Member

@ryankert01 ryankert01 left a comment

Choose a reason for hiding this comment

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

Thanks for the fast fix! Some comments

@ryankert01
Copy link
Member

I looked into it and discovered the peak memory is around 10gb! It runs blazingly fast on a gpu server(A6000).

@rich7420
Copy link
Contributor

@viiccwen take a look about conflicts

@viiccwen viiccwen force-pushed the centralized-qdp-python-testing branch 2 times, most recently from 20c5405 to 034a1ac Compare March 12, 2026 12:17
Copy link
Member

@ryankert01 ryankert01 left a comment

Choose a reason for hiding this comment

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

need resolve the conflicts

@viiccwen viiccwen force-pushed the centralized-qdp-python-testing branch from 034a1ac to 989944e Compare March 14, 2026 08:00
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.

[Feature] centralized Python tests and default to single-process pytest to avoid CUDA OOM

3 participants