Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Large Tensor] Fix ravel_multi_index op #17644

Merged
merged 2 commits into from
Feb 26, 2020

Conversation

connorgoggins
Copy link
Contributor

@connorgoggins connorgoggins commented Feb 21, 2020

Description

The ravel_multi_index op was previously breaking on large tensor (dimension >= 2^32) data. With the following input:

run_performance_test(nd.ravel_multi_index, inputs=[{"data": (2, 2**32), "shape":(2, 10)}], run_backward=True, warmup=1, runs=1)

the following error was thrown:

Segmentation fault: 11

To root cause this issue, I ran the previous command in a Python script with GDB, and found that the underlying problem was in the header of the ravel_index struct in ravel.h. The index variable i used the int dtype when it should have been using index_t to properly handle long int indices. I switched this variable to index_t in the struct header and, after rebuilding, the previous input command displayed the correct output:

INFO:root:Begin Benchmark - ravel_multi_index
INFO:root:Complete Benchmark - ravel_multi_index
[{'ravel_multi_index': [{'inputs': {'data': (2, 4294967296), 'shape': (2, 10)}, 'max_storage_mem_alloc_cpu/0': 24696062.0, 'avg_time_forward_ravel_multi_inde
x': 4257.312}]}]

To ensure completeness and to prevent future breaking changes, I also added a nightly test for the ravel_multi_index op with large tensor data in tests/nightly/test_large_array.py.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented
  • To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • M src/operator/ravel.h
  • M tests/nightly/test_large_array.py

Comments

Tested on r5dn.24xl-ubuntu 16.04 and p2.16xl-ubuntu 16.04 with

  1. Individual op run
  2. Full OpPerf run

Results

The key difference between CPU and GPU tests was the instance type (r5dn.24xl for CPU, p2.16xl for GPU). All relevant build flags remain the same, and both were tested using CPU context.

Single operator test - ravel_multi_index op (GPU)
Single operator test - ravel_multi_index op (CPU)

Full OpPerf test (GPU)
Full OpPerf test (CPU)

@apeforest @access2rohit @ChaiBapchya

Copy link
Contributor

@ChaiBapchya ChaiBapchya left a comment

Choose a reason for hiding this comment

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

LGTM!

@connorgoggins
Copy link
Contributor Author

@mxnet-label-bot add [pr-awaiting-review]

@lanking520 lanking520 added the pr-awaiting-review PR is waiting for code review label Feb 21, 2020
@connorgoggins connorgoggins force-pushed the fix_ravel_large_tensor branch 3 times, most recently from 7bd485d to 443d54f Compare February 25, 2020 10:05
@apeforest apeforest merged commit 13f5ad9 into apache:master Feb 26, 2020

out = nd.ravel_multi_index(data=data, shape=shape)

assert out.shape[0] == LARGE_TENSOR_SHAPE
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have values checks here ?

anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request May 29, 2020
* Fixed dtype on i

* Added nightly test for ravel_multi_index
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants