Skip to content

[GPU] Enable zero-copy subbuffers for usm_device on iGPUs#36645

Open
Prithviraj-R wants to merge 1 commit into
openvinotoolkit:masterfrom
Prithviraj-R:zero_copy_bug_fix
Open

[GPU] Enable zero-copy subbuffers for usm_device on iGPUs#36645
Prithviraj-R wants to merge 1 commit into
openvinotoolkit:masterfrom
Prithviraj-R:zero_copy_bug_fix

Conversation

@Prithviraj-R

@Prithviraj-R Prithviraj-R commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

[GPU] Enable zero-copy subbuffers for usm_device on iGPUs

Details:

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

  • Zero-copy handling for usm_host and usm_shared was already implemented in
    earlier PRs ([GPU] Enable mmap for loading model weights​ on iGPUs #34494, [GPU] Support CPU pointers on remote tensor #36539); this PR focuses on closing the usm_device gap.
  • Previously, for usm_device allocations, a separate GPU usm_device buffer
    was allocated and filled from mapped host buffer data during cache load,
    causing duplicate allocation/copy overhead and increasing inference memory
    footprint.
  • This change enables zero-copy subbuffer usage for supported XE2+ iGPUs in the
    usm_device flow, removing extra staging/copy in applicable cases.
  • Blob offset alignment handling in deserialization is kept correct for
    subbuffer creation.

Implementation changes:

  • Extend zero-copy eligibility in data.hpp to include usm_device while
    preserving existing usm_host/usm_shared behavior.
  • Add/use helper check for zero-copy-capable device (XE2+ integrated GPU).
  • Use seek_current_ptr() for padding skip during deserialization alignment.
  • Refine zero-copy condition naming/readability in load path.

Changed files:
src/plugins/intel_gpu/include/intel_gpu/graph/serialization/binary_buffer.hpp
src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp
src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp
src/plugins/intel_gpu/src/graph/program.cpp
src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp
src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp
src/plugins/intel_gpu/tests/unit/test_cases/cache_serialization_test.cpp

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

Problematic graph
NA

Checklist

  • Is it a proper fix? Yes (removes duplicate usm_device staging/copy in
    supported zero-copy cases)
  • Did you include test case for this fix, if necessary? NA
  • Did you review existing test that can be extended to cover this scenario?
    NA

Tickets:

AI Assistance:

  • AI assistance used: yes
  • AI was used for wording refinement and commit message cleanup.

@Prithviraj-R Prithviraj-R requested review from a team as code owners June 30, 2026 13:41
@Prithviraj-R Prithviraj-R requested a review from Copilot June 30, 2026 13:41
@github-actions github-actions Bot added the category: GPU OpenVINO GPU plugin label Jun 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Intel GPU cache serialization/deserialization for cldnn::data weights to broaden zero-copy subbuffer usage (xe2+ iGPU) and to apply sub-buffer alignment padding more consistently.

Changes:

  • Move sub-buffer padding logic to be applied outside the host-accessible branch in save/load paths.
  • Relax zero-copy enablement conditions (xe2+ integrated GPU + mmap alignment + non-weightless).
  • Simplify branching in load_weights().

Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread src/plugins/intel_gpu/include/intel_gpu/graph/serialization/binary_buffer.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
@Prithviraj-R Prithviraj-R changed the title [GPU] Enable zero-copy subbuffers for all allocation types and fix pa… [GPU] Enable zero-copy subbuffers across all alloc types for iGPUs Jun 30, 2026
@Prithviraj-R Prithviraj-R requested a review from Copilot June 30, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
@Prithviraj-R Prithviraj-R force-pushed the zero_copy_bug_fix branch 3 times, most recently from 1dd8ab4 to 556df4f Compare July 1, 2026 10:33
@Prithviraj-R Prithviraj-R requested a review from javier-intel July 1, 2026 10:36
@Prithviraj-R Prithviraj-R force-pushed the zero_copy_bug_fix branch 2 times, most recently from 4a4a190 to ae5b220 Compare July 1, 2026 13:15

@javier-intel javier-intel left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me

@p-durandin p-durandin added this to the 2026.3 milestone Jul 2, 2026
Comment thread src/plugins/intel_gpu/include/intel_gpu/runtime/engine.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
Comment thread src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp Outdated
Comment thread src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp Outdated
Comment thread src/plugins/intel_gpu/src/runtime/engine.cpp Outdated
@Prithviraj-R Prithviraj-R force-pushed the zero_copy_bug_fix branch 6 times, most recently from 8835f47 to c6d708d Compare July 13, 2026 11:52
Comment thread src/plugins/intel_gpu/include/intel_gpu/graph/serialization/binary_buffer.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/graph/serialization/binary_buffer.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/graph/serialization/binary_buffer.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/graph/serialization/binary_buffer.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp Outdated
Comment thread src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp Outdated
Comment thread src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp Outdated
Comment thread src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp Outdated
@maxnick maxnick modified the milestones: 2026.3, 2026.4 Jul 13, 2026
@maxnick

maxnick commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@Prithviraj-R , please update the PR description. The PR body lists 12 changed files (incl.  ze_engine.* ,  sycl_engine.* ,  ocl_engine.hpp ) and claims  CACHE_PAGE_SIZE  was moved to  memory_caps.hpp , but the diff touches 7 files and the constant is simply deleted (no references remain, so no build break)

@Prithviraj-R Prithviraj-R force-pushed the zero_copy_bug_fix branch 7 times, most recently from c2fec9f to c122efa Compare July 14, 2026 14:12
@p-durandin

Copy link
Copy Markdown
Contributor

@Prithviraj-R please take a look on L0 related errors. They look not a random
FAILED TESTS (2/447):
2058 ms: /__w/openvino/openvino/install/tests/ov_gpu_unit_tests smoke/conv_dyn_3d_test.convolution_gpu_b_fs_zyx_fsv16_imad_quantized/1
2079 ms: /__w/openvino/openvino/install/tests/ov_gpu_unit_tests smoke/conv_dyn_3d_test.convolution_gpu_b_fs_zyx_fsv16_imad_quantized/3

@Prithviraj-R Prithviraj-R force-pushed the zero_copy_bug_fix branch 2 times, most recently from 5e1790e to e086125 Compare July 15, 2026 15:42
@Prithviraj-R Prithviraj-R changed the title [GPU] Enable zero-copy subbuffers across all alloc types for iGPUs [GPU] Enable zero-copy subbuffers for usm_device on iGPUs Jul 15, 2026
@Prithviraj-R Prithviraj-R force-pushed the zero_copy_bug_fix branch 4 times, most recently from acf8db0 to e0a1663 Compare July 15, 2026 18:01
#### Details:
Description of the issue (symptom, root-cause, how it was resolved)
- Zero-copy handling for `usm_host` and `usm_shared` was already implemented in
  earlier PRs (openvinotoolkit#34494, openvinotoolkit#36539); this PR focuses on closing the `usm_device` gap.
- Previously, for `usm_device` allocations, a separate GPU `usm_device` buffer
  was allocated and filled from mapped host buffer data during cache load,
  causing duplicate allocation/copy overhead and increasing inference memory
  footprint.
- This change enables zero-copy subbuffer usage for supported XE2+ iGPUs in the
  `usm_device` flow, removing extra staging/copy in applicable cases.
- Blob offset alignment handling in deserialization is kept correct for
  subbuffer creation.

Implementation changes:
- Extend zero-copy eligibility in `data.hpp` to include `usm_device` while
  preserving existing `usm_host`/`usm_shared` behavior.
- Add/use helper check for zero-copy-capable device (XE2+ integrated GPU).
- Use `seek_current_ptr()` for padding skip during deserialization alignment.
- Refine zero-copy condition naming/readability in load path.

Changed files:
src/plugins/intel_gpu/include/intel_gpu/graph/serialization/binary_buffer.hpp
src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp
src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp
src/plugins/intel_gpu/src/graph/program.cpp
src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp
src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp
src/plugins/intel_gpu/tests/unit/test_cases/cache_serialization_test.cpp

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

Problematic graph
NA

#### Checklist
- [x] Is it a proper fix? Yes (removes duplicate `usm_device` staging/copy in
      supported zero-copy cases)
- [x] Did you include test case for this fix, if necessary? NA
- [x] Did you review existing test that can be extended to cover this scenario?
      NA

#### Tickets:
 - CVS-176160

#### AI Assistance:
 - AI assistance used: yes
 - AI was used for wording refinement and commit message cleanup.
@Prithviraj-R

Copy link
Copy Markdown
Contributor Author

@Prithviraj-R please take a look on L0 related errors. They look not a random FAILED TESTS (2/447): 2058 ms: /__w/openvino/openvino/install/tests/ov_gpu_unit_tests smoke/conv_dyn_3d_test.convolution_gpu_b_fs_zyx_fsv16_imad_quantized/1 2079 ms: /__w/openvino/openvino/install/tests/ov_gpu_unit_tests smoke/conv_dyn_3d_test.convolution_gpu_b_fs_zyx_fsv16_imad_quantized/3

@p-durandin fixed.

@Prithviraj-R

Copy link
Copy Markdown
Contributor Author

@Prithviraj-R , please update the PR description. The PR body lists 12 changed files (incl.  ze_engine.* ,  sycl_engine.* ,  ocl_engine.hpp ) and claims  CACHE_PAGE_SIZE  was moved to  memory_caps.hpp , but the diff touches 7 files and the constant is simply deleted (no references remain, so no build break)

@maxnick fixed

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.

7 participants