From 8475369bce3928b83afe90e9d692b159178e6419 Mon Sep 17 00:00:00 2001 From: Stanislav Minakov Date: Fri, 28 Feb 2025 15:22:18 -0800 Subject: [PATCH] Revert "Revert "Revert "Remove program cache checks""" This reverts commit 351edafb47bfc8e5ffb6352c01c7d3b628b1d9b0. --- tests/tt_eager/ops/test_eltwise_binary_op.cpp | 4 ++++ tests/tt_eager/ops/test_eltwise_unary_op.cpp | 3 +++ tt-train/tests/model/nano_gpt_test.cpp | 8 ++++++++ tt-train/tests/ttnn_fixed/dropout_op_test.cpp | 3 +++ 4 files changed, 18 insertions(+) diff --git a/tests/tt_eager/ops/test_eltwise_binary_op.cpp b/tests/tt_eager/ops/test_eltwise_binary_op.cpp index aa8df37484b..32769454b8e 100644 --- a/tests/tt_eager/ops/test_eltwise_binary_op.cpp +++ b/tests/tt_eager/ops/test_eltwise_binary_op.cpp @@ -118,8 +118,12 @@ int main() { run_binary_ops(); + TT_FATAL(device->num_program_cache_entries() == 3, "There are {} entries", device->num_program_cache_entries()); + device->disable_and_clear_program_cache(); + TT_FATAL(device->num_program_cache_entries() == 0, "Error"); + TT_FATAL(tt::tt_metal::CloseDevice(device), "Error"); return 0; diff --git a/tests/tt_eager/ops/test_eltwise_unary_op.cpp b/tests/tt_eager/ops/test_eltwise_unary_op.cpp index cb1ddaee737..17839c2f228 100644 --- a/tests/tt_eager/ops/test_eltwise_unary_op.cpp +++ b/tests/tt_eager/ops/test_eltwise_unary_op.cpp @@ -273,7 +273,10 @@ void test_program_cache() { device->enable_program_cache(); run_tests(); + TT_FATAL(device->num_program_cache_entries() == 4, "There are {} entries", device->num_program_cache_entries()); + device->disable_and_clear_program_cache(); + TT_FATAL(device->num_program_cache_entries() == 0, "Error"); TT_FATAL(tt::tt_metal::CloseDevice(device), "Error"); } diff --git a/tt-train/tests/model/nano_gpt_test.cpp b/tt-train/tests/model/nano_gpt_test.cpp index 922e016e865..b0dcf77742c 100644 --- a/tt-train/tests/model/nano_gpt_test.cpp +++ b/tt-train/tests/model/nano_gpt_test.cpp @@ -177,6 +177,14 @@ void train_test(bool use_moreh_adamw = false, bool memory_efficient = false) { steps_time.emplace_back((double)duration / 1000.0); } + // verify program cache + auto program_cache_entries = device->num_program_cache_entries(); + if (!use_moreh_adamw) { + EXPECT_EQ(program_cache_entries, 123); + } else { + EXPECT_EQ(program_cache_entries, 102); + } + // verify time per step size_t num_steps_below = 0; const double expected_default_runner_time_ms = 330.0; diff --git a/tt-train/tests/ttnn_fixed/dropout_op_test.cpp b/tt-train/tests/ttnn_fixed/dropout_op_test.cpp index 398d1e09c84..693b1795175 100644 --- a/tt-train/tests/ttnn_fixed/dropout_op_test.cpp +++ b/tt-train/tests/ttnn_fixed/dropout_op_test.cpp @@ -37,10 +37,12 @@ TEST_F(DropoutTest, TestSeed) { xt::xarray xtensor_a = xt::random::rand(shape, -0.5, 0.5); auto xtensor_a_tensor = ttml::core::from_xtensor(xtensor_a, device); + auto num_cache_before = device->num_program_cache_entries(); auto result01 = ttnn::experimental::dropout(xtensor_a_tensor, prob, scale, dropout_seed1); auto result02 = ttnn::experimental::dropout(xtensor_a_tensor, prob, scale, dropout_seed2); auto result11 = ttnn::experimental::dropout(xtensor_a_tensor, prob, scale, dropout_seed1); auto result12 = ttnn::experimental::dropout(xtensor_a_tensor, prob, scale, dropout_seed2); + auto num_cache_after = device->num_program_cache_entries(); auto result01_vec = ttml::core::to_xtensor(result01); auto result02_vec = ttml::core::to_xtensor(result02); @@ -50,6 +52,7 @@ TEST_F(DropoutTest, TestSeed) { EXPECT_TRUE(xt::allclose(result01_vec, result11_vec, /*rtol=*/1e-4, /*atol=*/1e-3)); EXPECT_TRUE(xt::allclose(result02_vec, result12_vec, /*rtol=*/1e-4, /*atol=*/1e-3)); EXPECT_FALSE(xt::allclose(result01_vec, result02_vec, /*rtol=*/1e-4, /*atol=*/1e-3)); + EXPECT_EQ(num_cache_before, num_cache_after - 1); } }