ArrayBuffer Lazy-assignment for GPU Context#5076
Draft
SamSJackson wants to merge 24 commits intoconnorjward/pyop3from
Draft
ArrayBuffer Lazy-assignment for GPU Context#5076SamSJackson wants to merge 24 commits intoconnorjward/pyop3from
SamSJackson wants to merge 24 commits intoconnorjward/pyop3from
Conversation
added 18 commits
April 27, 2026 12:39
…Patch*ExteriorFacets
- new state object (int -> dict) leads the reassignment being a weak reference.
connorjward
requested changes
May 4, 2026
Contributor
connorjward
left a comment
There was a problem hiding this comment.
I've been strict but in general this is fantastic, thank you
added 6 commits
May 4, 2026 14:04
- defaultdict gives -1 as default value if device object does not exist
- constant property was lost between cupy/numpy conversions - fixed by passing kwarg that is disregarded for cupy but used for numpy
- using @Property for last_updated_device, known by state, does not need to be variable. - duplicate method only copies most up-to-date copy and non-copy duplicate only copies for current device - initialisation adds None as optional for data input
- v3.24.5 was failing to compile petsc4py due to PETSc no support for PCPatchSetComputeFunctionExteriorFacets
Contributor
|
For any trivial changes please go ahead and resolve them. Saves me cross checking things. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a context manager to allow dynamic assignment of PyOP3 arrays on a given device.
Devices are defined within the new
device.pymodule, where internal array management is also contained.Key modifications:
device.pymodule to represent offloading devices as offloading context managerbuffer.pyto lazily-evaluate data with respect to the current context (i.e. host or offloading device)_lazy_datais now a dictionary object, mapping between Device objects and respective arrays._dataproperty lazily-evaluates to appropriate data for the given context. If the data is not up-to-date, as per state property, the data is copied.device.pysobuffer.pycan remain device/gpu-agnostic - apart from some type-hinting, i.e.cp.ndarray.Notable issues:
writeableflag. It will throw away the flag when converting from NumPy objects (and it will not return if converted back)./pyop3_gpu_demo.pyfrom asserts before entering context manager.