Skip to content

Fix two host/device array mix-ups on the CuPy backend - #709

Open
max-models wants to merge 2 commits into
develfrom
cuda-bugfixes
Open

max-models wants to merge 2 commits into
develfrom
cuda-bugfixes

Conversation

@max-models

@max-models max-models commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Stack: part 1 of 14, based on devel, next: #708. Full order: #709 → #708 → #711 → #712 → #705 → #713 → #714 → #718 → #720 → #721 → #724 → #725 → #723 → #722.


Two small bugs that stop particle runs early on CUNUMPY_BACKEND=cupy:

  • SplineFunction.__init__ (feec/psydac_derham.py): the knots of derham.V0fem are NumPy arrays, and xp.ascontiguousarray (= cupy.ascontiguousarray) does not accept them:
    TypeError: Argument 'a' has incorrect type (expected cupy._core.core._ndarray_base, got numpy.ndarray).
    They are now made contiguous on the host and copied to the device with xp.asarray.
  • SortingBoxes._set_boxes (pic/sorting.py): xp.sqrt of a Python int returned a 0-d CuPy array, which round() rejects (TypeError: type ndarray doesn't define __round__ method).
    It is a host scalar, so this now uses math.sqrt.

The NumPy backend is unaffected.

Note

With these fixes, examples/VlasovAmpereOneSpecies/strong_Landau_damping gets further on CuPy but still stops in initialize_neighbours: box sorting and the vlasov_maxwell accumulation
are not on the GPU yet (see CUDA_STRATEGY.md, "Next"). This PR does not try to change that.

max-models added a commit that referenced this pull request Oct 7, 2026
Stack the PR on #709.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
max-models added a commit that referenced this pull request Oct 7, 2026
Stack the PR on #720.

Conflict in feec/psydac_derham.py (SplineFunction.__init__): SplineArguments/CudaSplineArguments of #721 built
from the degree check and the host-to-device copy of the knots of #709.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@max-models
max-models added this pull request to stack #729 October 8, 2026 05:59
@max-models
max-models marked this pull request as draft October 8, 2026 09:15
@max-models
max-models marked this pull request as ready for review October 8, 2026 11:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant