Skip to content

tests: enable bfloat16 support for npy and safetensors#3270

Closed
shivansh023023 wants to merge 1 commit intoml-explore:mainfrom
shivansh023023:fix/bfloat16-test-parity
Closed

tests: enable bfloat16 support for npy and safetensors#3270
shivansh023023 wants to merge 1 commit intoml-explore:mainfrom
shivansh023023:fix/bfloat16-test-parity

Conversation

@shivansh023023
Copy link
Copy Markdown

Proposed changes

This PR addresses the missing bfloat16 testing parity for NPY, NPZ, and Safetensors formats by resolving an existing TODO in python/tests/test_load.py.

Changes included:

  • Implemented a _to_np_dtype helper to correctly map bfloat16 to np.float32 during numpy conversions, allowing test arrays to be properly initialized and validated.
  • Added "bfloat16" to the list of tested dtypes in test_save_and_load, test_save_and_load_fs, and test_savez_and_loadz.
  • Note: bfloat16 remains intentionally excluded from test_save_and_load_gguf, as the C++ backend does not yet support it for the GGUF format.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed) (Not applicable)

@zcbenz zcbenz closed this Mar 17, 2026
@zcbenz
Copy link
Copy Markdown
Collaborator

zcbenz commented Mar 17, 2026

Tests not passing, code not doing exactly what it claims, not understanding why we didn't have it in the first place.

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.

2 participants