diff --git a/mlx/primitives.cpp b/mlx/primitives.cpp index fd3bda37..9767cd60 100644 --- a/mlx/primitives.cpp +++ b/mlx/primitives.cpp @@ -3717,7 +3717,7 @@ std::pair, std::vector> RandomBits::vmap( bool RandomBits::is_equivalent(const Primitive& other) const { const RandomBits& r_other = static_cast(other); - return shape_ == r_other.shape_; + return shape_ == r_other.shape_ && width_ == r_other.width_; } std::vector Real::vjp( diff --git a/python/tests/test_blas.py b/python/tests/test_blas.py index 469d2407..3221a75d 100644 --- a/python/tests/test_blas.py +++ b/python/tests/test_blas.py @@ -297,6 +297,7 @@ class TestBlas(mlx_tests.MLXTestCase): self.assertTrue(np.allclose(out_mlx, out_npy, atol=1e-5)) def test_matrix_vector(self): + mx.random.seed(0) for dtype in self.dtypes: with self.subTest(dtype=dtype): np_dtype = getattr(np, dtype) diff --git a/tests/compile_tests.cpp b/tests/compile_tests.cpp index e65cfc76..d2146f3b 100644 --- a/tests/compile_tests.cpp +++ b/tests/compile_tests.cpp @@ -803,3 +803,16 @@ TEST_CASE("test compile with no-ops") { auto out = compile(fun)({in})[0]; CHECK_EQ(out.inputs()[0].id(), in.id()); } + +TEST_CASE("test compile random bits") { + auto fun = [](const std::vector& inputs) { + auto key = inputs[0]; + auto a = random::bits({32, 32}, 4, key); + auto b = random::bits({32, 32}, 2, key); + return std::vector{a + b}; + }; + auto in = random::key(0); + auto expected = fun({in})[0]; + auto out = compile(fun)({in})[0]; + CHECK(array_equal(out, expected).item()); +}