Skip to content

[FEATURE REQUEST] dot test coverage and fixtures #19

@LoserCheems

Description

@LoserCheems

Problem statement

The dot kernel currently has no dedicated tests under tests/. While copy and swap are covered by test_copy.py and test_swap.py, there is no test_dot.py to verify that all backends compute $z = x^\top y$ correctly.

Without dot tests:

  • regressions in any backend implementation may go unnoticed,
  • CI cannot guarantee numerical equivalence between backends and the Python reference,
  • the README BLAS table cannot mark the Test column for dot as complete.

Proposed solution

Add a dedicated pytest module for dot that follows the style of existing kernel tests and validates all backends.

Concretely:

  • Introduce tests/test_dot.py alongside the existing tests.
  • For each backend (Python, PyTorch, Triton, CuTe when available), compare results against the Python dot reference for multiple input sizes and dtypes.
  • Cover edge cases such as zero-length vectors, large values, and orthogonal vectors where the dot product is close to zero.

Alternatives considered

Ad-hoc or manual testing is not sufficient because it:

  • is easy to skip during development,
  • does not integrate with CI,
  • lacks consistent regression coverage.

Implementation details

  • Add tests/test_dot.py using pytest patterns already used in the project.
  • Reuse any shared helpers for generating random vectors and comparing outputs.
  • Parameterize tests over vector length, dtype, and value ranges.
  • Gracefully skip backend-specific tests when a backend is not available or not yet implemented.

Use case

The dot tests will:

  • validate correctness for all backend implementations of dot,
  • support contributors in implementing and optimizing dot product kernels,
  • reinforce the project’s emphasis on numerical equivalence across backends.

Related work

  • Existing tests: tests/test_copy.py, tests/test_swap.py.
  • BLAS dot test suites in other numerical libraries.

Additional context

This issue is part of filling in the dot row of the README BLAS table, specifically the Test column.

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