Skip to content

[GPU] use stable seed hash algorithm for different platforms#36018

Open
yuanxion wants to merge 3 commits into
openvinotoolkit:masterfrom
yuanxion:fix-uhd-testcases-seed-generator
Open

[GPU] use stable seed hash algorithm for different platforms#36018
yuanxion wants to merge 3 commits into
openvinotoolkit:masterfrom
yuanxion:fix-uhd-testcases-seed-generator

Conversation

@yuanxion
Copy link
Copy Markdown
Contributor

@yuanxion yuanxion commented May 21, 2026

Details:

Reduce platform-dependent randomness in GPU test data generation by making testcase-name-based seed generation stable for GPU tests.

Description of the issue

Symptom

4 fully_connected compressed_int4_scale testcases passed on Ubuntu 22.04 with UHD 770, but failed on Windows 11 with UHD 770.

Root cause

The testcase seed was derived from std::hash<std::string>, which is platform-dependent and may produce different values across different standard library implementations.

As a result, the same testcase name could map to different seed values on Ubuntu and Windows. That caused the affected testcases to generate different random inputs on different platforms, which led to inconsistent results.

How to fix it

Reduce the platform-dependent part in testcase-name-based seed generation:

  • use a stable string-to-seed function based on FNV-1a
  • replace the previous std::hash<std::string> std::string-based seed derivation in GPU test random data generation

This change reduces cross-platform differences caused by testcase-name-based seed generation and improves reproducibility of the affected tests.

The code and line that caused this issue

void set_seed(const std::string& seed) {
auto seed_hash = std::hash<std::string>{}(seed);
set_seed(static_cast<uint32_t>(seed_hash));
}
void set_seed(const uint32_t seed) {
generator = std::default_random_engine{seed};
}

Reproduction step and snapshot

./ov_gpu_unit_tests --gtest_filter='fully_connected_gpu_tests.compressed_int4_scale*'

Problematic graph

N/A

Checklist

  • Is it a proper fix? (not a workaround)
  • Did you include test case for this fix, if necessary?
  • Did you review existing test that can be extended to cover this scenario? Which test did you review?

Tickets:

AI Assistance:

  • AI assistance used: yes
  • AI help to root cause and human check to confirm

@yuanxion yuanxion requested review from a team as code owners May 21, 2026 02:11
@github-actions github-actions Bot added the category: GPU OpenVINO GPU plugin label May 21, 2026
@yuanxion yuanxion requested a review from Copilot May 21, 2026 02:12

This comment was marked as outdated.

@yuanxion yuanxion marked this pull request as draft May 21, 2026 02:27
@yuanxion yuanxion force-pushed the fix-uhd-testcases-seed-generator branch from 4cf726d to 54226d1 Compare May 21, 2026 08:18
@yuanxion yuanxion requested a review from Copilot May 21, 2026 08:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/plugins/intel_gpu/tests/common/random_generator.hpp:47

  • [MEDIUM] PR title/description suggests stable random generation across platforms, but random_generator still relies on std::default_random_engine, whose algorithm is implementation-defined and can differ between libstdc++/libc++/MSVC. Even with a stable seed, random sequences may still vary across platforms. If full reproducibility is required, consider switching to an explicitly specified engine (e.g., std::mt19937 or std::minstd_rand0) or clarify in the PR description/title that only the seed derivation is stabilized.
    std::default_random_engine& get_generator() {
        return generator;
    }

    void set_seed(const std::string& seed) {
        set_seed(stable_string_seed(seed));
    }

    void set_seed(const uint32_t seed) {
        generator = std::default_random_engine{seed};

Comment thread src/plugins/intel_gpu/tests/common/random_generator.hpp
@yuanxion yuanxion changed the title [GPU] provide stable random generator for different platforms [GPU] use stable seed hash algorithm for different platforms May 22, 2026
@yuanxion
Copy link
Copy Markdown
Contributor Author

yuanxion commented May 22, 2026

This PR can make the following testcases passed on Windows11 + UHD770 (iGPU driver: 32.0.101.7085):

fully_connected_gpu_tests.compressed_int4_scale_dynamic
fusings_gpu/activation_eltwise_activation_quantize_u8.per_channel/15
fusings_gpu/conv_fp32_eltwise_fusing_extend_ops.pattern01_simple_sub/3
fusings_gpu/conv_fp32_multi_eltwise_4_clamp.basic/4

@yuanxion yuanxion marked this pull request as ready for review May 25, 2026 08:19
Copy link
Copy Markdown
Contributor

@wilson-seok wilson-seok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

yuanxion and others added 3 commits June 3, 2026 09:17
Signed-off-by: yuan.xiong <yuan.xiong@intel.com>
Add standard header files

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: yuan.xiong <yuan.xiong@intel.com>
@yuanxion yuanxion force-pushed the fix-uhd-testcases-seed-generator branch from 225bfec to 62a2c61 Compare June 3, 2026 01:23
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.

3 participants