Skip to content

requirements/test-cpu.txt omits safetensors: documented CPU install aborts pytest collection #2

Open

Description

@mmjerge

requirements/test-cpu.txt does not include safetensors, but a test module imports it at top level, so the documented install produces a collection error rather than a skip — no tests run at all.

Reproduction

Fresh clone at v0.2.2 (12ce733), clean venv, Python 3.13:

$ python3 -m pip install -r requirements/test-cpu.txt
$ python3 -m pip install -e .
$ python3 -m pytest -q
_______________ ERROR collecting tests/test_glm52_online_grpo.py _______________
ImportError while importing test module '.../tests/test_glm52_online_grpo.py'.
tests/test_glm52_online_grpo.py:8: in <module>
    from safetensors.torch import save_file
E   ModuleNotFoundError: No module named 'safetensors'
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 warning, 1 error in 3.84s

requirements/test-cpu.txt resolves to pytest, PyYAML (via test.txt) and torch==2.7.1+cpu. The CPU torch wheel does not pull in safetensors.

tests/test_glm52_online_grpo.py imports it unguarded at line 8, and again at line 469 (from safetensors import safe_open). Because it is a module-level import, pytest aborts the entire session on collection instead of skipping the one file.

Other optional dependencies are guarded correctly — tests/test_dapo_data_audit.py:167 skips cleanly when pyarrow is unavailable — which suggests this one is an oversight.

Fix

Adding safetensors to requirements/test.txt resolves it; after installing it, the suite collects and runs (1395 passing here). Alternatively, a pytest.importorskip("safetensors") guard would match the pyarrow pattern if the dependency is meant to stay optional.

Minor, related: torch emits UserWarning: Failed to initialize NumPy: No module named 'numpy' under the same install. Harmless for the tests that run, but numpy may be worth pinning alongside.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions