Skip to content

[GPU] Generate a new RandomUniform sequence on every inference - #39568

Open
jade-cho wants to merge 1 commit into
openvinotoolkit:masterfrom
jade-cho:cvs-199309
Open

jade-cho wants to merge 1 commit into
openvinotoolkit:masterfrom
jade-cho:cvs-199309

Conversation

@jade-cho

@jade-cho jade-cho commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Description of the issue(symptom, root-cause, how it was resolved)

  • Symptom: GPU RandomUniform returns the same values on every inference (CPU: new values per call).
  • Root cause: the op is constant-folded at compile time, the kernel has no Philox state (seeds are JIT constants), and ShapeOf -> RandomUniform is skipped as a shape_of subgraph.
  • Fix: exclude it from constant propagation and shape_of subgraphs. Pass seed/state as runtime kernel args and advance the state per execution like the CPU plugin.

The code and line that caused this issue (if it is not changed directly)

  • intel_gpu/src/graph/program.cpp: program::mark_if_constant()
  • intel_gpu/src/kernel_selector/kernels/random_uniform/random_uniform_kernel_ref.cpp: GetJitConstants() (GLOBAL_SEED / OP_SEED as JIT constants)
  • intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp: can_mark_node() -> skipped in primitive_inst::prepare_primitive()

Reproduction step and snapshot (if applicable. Do not attach for customer model)

  • Model: x + RandomUniform([1,50,32], 0, 1) (or torch.rand / torch.randn_like converted to OV), compiled on GPU, 5 infers on one request
  • Before: 1/5 distinct outputs. After: 5/5 distinct outputs, same as CPU

Problematic graph

  • Static: Const(shape), Const(min), Const(max) -> RandomUniform -> Add(x). RandomUniform is removed by propagate_constants.
  • Dynamic: Parameter -> ShapeOf -> RandomUniform -> .... RandomUniform runs only on the 1st inference.

Checklist

  • Is it a proper fix? (not a workaround)
  • Did you include test case for this fix, if necessary?
    • unit: random_uniform_gpu_state_test, mark_shape_of_subgraphs.random_uniform_no_mark
    • func: smoke_RandomUniformInfer, smoke_RandomUniformDynamicInferGPUTest
    • All 8 new cases fail without the fix and pass with it.
  • Did you review existing test that can be extended to cover this scenario? Which test did you review?
    • smoke_BasicRandomUniform and random_uniform_gpu_test run a single inference only, so they cannot catch repeated-call issues. Added state tests in random_uniform_gpu_test.cpp, and extended mark_shape_of_subgraphs_test.cpp.

Tickets:

AI Assistance:

  • AI assistance used: yes
  • AI helped with analysis, code and tests. Validated by local build, unit/func tests and the ticket reproducer on Arc B70 and UHD 770.

@jade-cho
jade-cho requested review from a team as code owners November 6, 2026 07:26
@github-actions github-actions Bot added the category: GPU OpenVINO GPU plugin label Nov 6, 2026
@mlukasze
mlukasze removed the request for review from a team November 6, 2026 07:33
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: GPU OpenVINO GPU plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant