From 9a67850beb1ae42936ff960295f5066344a12465 Mon Sep 17 00:00:00 2001 From: Jade-Cho Date: Fri, 6 Nov 2026 16:24:28 +0900 Subject: [PATCH] [GPU] Generate a new RandomUniform sequence on every inference RandomUniform on GPU returned the same values on every infer call: - mark_if_constant folded random_uniform with constant inputs at compile time - seeds were JIT constants and the Philox state never advanced - ShapeOf -> RandomUniform was marked as a shape_of subgraph and skipped when the input shape did not change Exclude random_uniform from constant propagation and shape_of subgraphs, pass seed and Philox state as runtime kernel arguments and advance the state after every execution in the same way as the CPU plugin. --- .../mark_shape_of_subgraphs.cpp | 6 + .../src/graph/impls/ocl/random_uniform.cpp | 18 +++ .../src/graph/include/random_uniform_inst.h | 16 +++ src/plugins/intel_gpu/src/graph/program.cpp | 5 +- .../intel_gpu/src/graph/random_uniform.cpp | 22 +++ .../cl_kernels/random_uniform_ref.cl | 13 +- .../random_uniform_kernel_ref.cpp | 21 +-- .../intel_gpu/tests/functional/sources.cmake | 1 + .../subgraph_tests/random_uniform_infer.cpp | 129 ++++++++++++++++++ .../passes/mark_shape_of_subgraphs_test.cpp | 45 ++++++ .../test_cases/random_uniform_gpu_test.cpp | 92 +++++++++++++ 11 files changed, 353 insertions(+), 15 deletions(-) create mode 100644 src/plugins/intel_gpu/tests/functional/subgraph_tests/random_uniform_infer.cpp diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp index 376401e50e78..82e0a01bd2f4 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp @@ -15,6 +15,7 @@ #include "pass_manager.h" #include "fully_connected_inst.h" #include "gemm_inst.h" +#include "random_uniform_inst.h" #include "intel_gpu/graph/program.hpp" @@ -87,6 +88,11 @@ bool mark_shape_of_subgraphs::can_mark_node(const program_node& node) { return false; } + // RandomUniform output changes on every inference, while shape_of subgraphs are skipped when input shapes do not change + if (node.is_type()) { + return false; + } + // CPU implementation does not support float data types for mask and mixed types for data inputs, so check them // before including it into shape_of sub-graph if (node.is_type