This documentation provides guidelines for running tests and contributing new tests to the TileGym framework.
To run functionality tests:
pytest your_test_name -k test_op -v --log-cli-level=INFOTo ensure compatibility with our testing framework, please follow these guidelines:
- Test classes should start with
Test_, e.g.,Test_RoPE,Test_Matmul - Implement test methods with appropriate names:
test_op- For functional correctness tests
- Inherit from
common.PyTestCase - Implement a
referencemethod for PyTorch baseline implementation - Use
@pytest.mark.parametrizefor test case variations - If you specify the value of parameter in
@pytest.mark.parametrize, function should not contain default value
class Test_YourFeature(common.PyTestCase):
@staticmethod
def reference(x, ...):
# Reference implementation using PyTorch
return torch_result
@pytest.mark.parametrize("param1,param2,...", [
(value1, value2, ...),
(value3, value4, ...),
])
def test_op(self, param1, param2, ...):
# Test for functional correctness
self.assertCorrectness(
tilegym.ops.your_op,
self.reference,
{'arg1': value1, 'arg2': value2, ...},
rtol=1e-2,
atol=1e-2,
)- Use
self.assertCorrectness()to compare TileGym implementation with reference - For gradient checking, provide the
gradientparameter toassertCorrectness - Set appropriate tolerance values (
rtol,atol) based on numeric precision needs