Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: cupyx/scipy/interpolate: add griddata #8290

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ev-br
Copy link
Contributor

@ev-br ev-br commented Apr 12, 2024

Port griddata function from scipy.interpolate. This is a pure python convenience wrapper ofLinearNDInterpolator, NearestNDInterpolator and CloughTocher2DInterpolator, so no need to benchmark performance.

This PR is on top of #8220 for the NearestNDInterpolator and #8289 for interp1d. Will need a rebase or two when these two PRs land.

@ev-br ev-br marked this pull request as draft April 12, 2024 13:26
@takagi takagi self-assigned this Apr 15, 2024
@takagi takagi added cat:feature New features/APIs prio:medium labels Apr 15, 2024
@andfoy andfoy mentioned this pull request Apr 15, 2024
51 tasks
Copy link
Contributor

mergify bot commented Apr 25, 2024

This pull request is now in conflicts. Could you fix it @ev-br? 🙏

Copy link
Contributor

mergify bot commented May 21, 2024

This pull request is now in conflicts. Could you fix it @ev-br? 🙏

@ev-br ev-br marked this pull request as ready for review May 21, 2024 18:13
@ev-br
Copy link
Contributor Author

ev-br commented May 21, 2024

Both dependencies are merged, the PR is rebased on main and is ready for review.

@takagi takagi added this to the v14.0.0a1 milestone May 23, 2024
@takagi
Copy link
Member

takagi commented May 23, 2024

/test mini

Copy link
Member

@takagi takagi left a comment

Choose a reason for hiding this comment

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

LGTM! Waiting for CI pass.

@takagi
Copy link
Member

takagi commented May 29, 2024

Seems that CI fails with illegal memory access. Does this occurs on your local? Disabling CuPy's memory pool cupy.cuda.set_allocator(None) may help.

E   cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered

@ev-br
Copy link
Contributor Author

ev-br commented May 29, 2024

Sadly, no, I don't see this locally. $ pytest tests/cupyx_tests/scipy_tests/interpolate_tests/ -v passes for me (on CUDA 12 and scipy 1.13) modulo a test failure due to a unrelated scipy 1.13 change, scipy/scipy#20364.

Also given that this PR only adds a thin pure python wrapper, the the root problem is likely somewhere else. Where does the error originate?

@takagi
Copy link
Member

takagi commented May 31, 2024

Seems that its first occurrence in CI log is TestGriddata.test_fill_value , but as you say it may not the root problem. I will also check this issue.

https://ci.preferred.jp/cupy.linux.cuda112/161482/
https://storage.googleapis.com/chainer-artifacts-pfn-public-ci/cupy-ci/161482/log.txt

...
cupyx_tests/scipy_tests/interpolate_tests/test_ndgriddata.py ..sssFFFFFF [ 36%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF                                      [ 36%]
cupyx_tests/scipy_tests/interpolate_tests/test_polyint.py FFFFFFFFFFFFFF [ 36%]
sFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFssssssssssssssssssssssssssssssssssssssss [ 37%]
ssssssssssssssssssssFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFsFFFFFFFFFFFFFsFFF [ 37%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [ 37%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [ 37%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFssssssssFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [ 37%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFsssss                                        [ 37%]
cupyx_tests/scipy_tests/interpolate_tests/test_ppoly.py FFFFFFFFFFFFFFFF [ 37%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFssssssssFFFFFFFFFFFFsssFFFFFFFFFFFFFFF [ 37%]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF                                 [ 37%]
cupyx_tests/scipy_tests/interpolate_tests/test_rbfinterp.py ssssssssFFFF [ 37%]
FFFFFFF

=================================== FAILURES ===================================
_________________________ TestGriddata.test_fill_value _________________________

self = <cupyx_tests.scipy_tests.interpolate_tests.test_ndgriddata.TestGriddata object at 0x7fb8d45a5df0>
xp = <module 'cupy' from '/root/.local/lib/python3.9/site-packages/cupy/__init__.py'>
scp = <module 'cupyx.scipy' from '/root/.local/lib/python3.9/site-packages/cupyx/scipy/__init__.py'>

    @testing.numpy_cupy_allclose(scipy_name='scp')
    def test_fill_value(self, xp, scp):
        x = [(0, 0), (0, 1), (1, 0)]
        y = [1, 2, 3]
...

@ev-br
Copy link
Contributor Author

ev-br commented Jun 1, 2024

TBH, I don't see how a pure python addition of this PR can trigger this. The only possiblility is that a nan assignment is broken somehow, in this line: https://github.com/cupy/cupy/pull/8290/files#diff-e6ca1b203fa4c1b7e7f6170aa16844edb19aa250d65f43d99d4bd3ee26187b36R256 with the default of fill_value=cupy.nan. But this is definitely not the only place nans appear, so it's unlikely too.

@kmaehashi
Copy link
Member

I've tried running compute-sanitizer --tool memcheck python -m pytest -v -s -k test_fill_value tests/cupyx_tests/scipy_tests/interpolate_tests/test_ndgriddata.py on my local with memory pool disabled by commenting out these lines. It's not always reproducing (it even sometimes hangs) but I got this error reported:

========= Invalid __global__ read of size 4 bytes
=========     at kerFindClosestTri(Point2 *, int, Tri *, int, TriOpp *, long long *, unsigned int *, Point2 *, Point2 *, const double *, const double *, Point2 *, Point2 *, double, bool, int *, double *)+0x85d0
=========     by thread (0,0,0) in block (0,0,0)
=========     Address 0x7f2ec2a007f4 is out of bounds
=========     and is 12 bytes before the nearest allocation at 0x7f2ec2a00800 of size 48 bytes
=========     Saved host backtrace up to driver entry point at kernel launch time
=========     Host Frame: [0x32e94f]

@takagi
Copy link
Member

takagi commented Jun 4, 2024

@andfoy Can I ask you to check if kerFindClosestTri could make any out-of-bounds access again?

@andfoy
Copy link
Contributor

andfoy commented Jun 7, 2024

Thanks for the report @takagi, the reported segfault should be fixed by #8363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏭 In progress
Development

Successfully merging this pull request may close these issues.

None yet

4 participants