Skip to content

Conversation

@planetf1
Copy link
Contributor

@planetf1 planetf1 commented Feb 2, 2026

Test Infrastructure Improvements

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

Fixes test infrastructure issues preventing tests from running on systems without required backends. Tests were failing at collection time due to backend initialization at import and missing markers.

Fixes #396

Changes:

  • Fixed tests calling start_session() at class/module definition time (moved to fixtures)
  • Added missing ollama and llm markers to tests using default backend
  • Added missing ollama marker to guardian safety examples (guardian.py, guardian_huggingface.py)
  • Marked flaky test_kv with xfail(strict=False) - model safety refusal despite context
  • Marked broken docs/examples/aLora/101_example.py with skip marker
  • Skipped docs/examples/mify/rich_document_advanced.py - CXXABI_1.3.15 not found on HPC systems with old glibc
    • Environment-specific issue, not a code bug
    • Example fails to import due to conda environment using system libstdc++.so.6 (too old)
    • Skipped to prevent test failures on affected systems
  • Documented NVIDIA MPS solution for GPU test sharing - added comprehensive guide in test/README.md
    • Explains "Parent Trap" issue: pytest parent holds CUDA context, blocking subprocesses in EXCLUSIVE_PROCESS mode
    • Solution 1 (Recommended): Enable NVIDIA MPS via job scheduler flag (e.g., mps=yes for LSF)
      • Allows multiple processes to share GPU without code changes
      • Verified on IBM HPC: 34/34 tests passed, 0 "CUDA device busy" errors, 5:46 runtime (Job 434111)
      • Note: MPS must be enabled per-job; it's not a repository setting
    • Solution 2 (Fallback): Run tests sequentially when MPS unavailable
    • MPS solves GPU sharing at driver level - no application code changes needed

Results: 34/34 HuggingFace tests pass on HPC with MPS enabled. Tests properly skip when backends unavailable.

Verification:

  • Full mypy check passes (245 source files, 0 errors)
  • All pre-commit hooks pass (ruff format, ruff lint, mypy, uv-lock, codespell)
  • HPC tests verified: 34/34 tests pass with MPS enabled

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code as added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@mergify
Copy link

mergify bot commented Feb 2, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

@planetf1 planetf1 changed the title test: optimize GPU cleanup to module scope test: ensure all hf tests run (cuda) Feb 3, 2026
@planetf1 planetf1 requested a review from jakelorocco February 3, 2026 16:02
@planetf1
Copy link
Contributor Author

planetf1 commented Feb 3, 2026

This PR will now allow the running of the hf tests on a well-provisioned environment.

Rebased ~hour ago - appreciate any review comments, after which I can squash and rebase to clean up commit log & run a final test.

@planetf1 planetf1 marked this pull request as ready for review February 3, 2026 16:03
@planetf1 planetf1 force-pushed the largetests branch 8 times, most recently from 3876742 to 938cc89 Compare February 3, 2026 19:28
- Add @pytest.mark.ollama to tests requiring Ollama backend
- Update test/README.md with comprehensive marker documentation
- Update .gitignore for logs/ and pytest output files
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.

bug: Correct categorization and detection for heavier tests

2 participants