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

Properly handling custom op exception by modify engine #14693

Merged
merged 6 commits into from
Apr 16, 2019

Conversation

arcadiaphy
Copy link
Member

Description

In #14522, problems of custom op exception handling are reported. #14575 tries to fix them by modify custom op implementation, which causes blocking in custom thread.

This PR tries to address the issue by modifying engine:

  1. Add kNoSkip operation to force execution even with associated exception
  2. Since NDArray is duplicated in custom op with shared data, their exception status may not be synchronized, so Throw method is added in engine to re-throw associated exception on var.
  3. Users are free to use sync operation like asnumpy or wait_to_read in custom op to block custom thread, so unlimited number of threads are still needed to avoid deadlock.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@szha
Copy link
Member

szha commented Apr 14, 2019

@junrushao1994 could you take a look too?

Copy link
Member

@wkcn wkcn left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for the fix!

Copy link
Member

@anirudh2290 anirudh2290 left a comment

Choose a reason for hiding this comment

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

Thanks for the nice work ! Added a comment for tests, otherwise LGTM.

src/operator/custom/custom-inl.h Show resolved Hide resolved
tests/python/unittest/test_operator.py Show resolved Hide resolved
Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

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

LGTM

@nswamy nswamy added Exception Handling pr-work-in-progress PR is still work in progress labels Apr 15, 2019
@arcadiaphy
Copy link
Member Author

@arcadiaphy arcadiaphy merged commit 1f84682 into apache:master Apr 16, 2019
@arcadiaphy arcadiaphy deleted the pr_engine_async branch April 16, 2019 08:06
@arcadiaphy arcadiaphy mentioned this pull request Apr 16, 2019
7 tasks
kedarbellare pushed a commit to kedarbellare/incubator-mxnet that referenced this pull request Apr 20, 2019
* fix custom except handling by modify engine

* add test

* fix lint

* update test

* fix test

* trigger CI
@TaoLv
Copy link
Member

TaoLv commented Apr 25, 2019

@arcadiaphy
Copy link
Member Author

@TaoLv Sure, let me have a look.

haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
* fix custom except handling by modify engine

* add test

* fix lint

* update test

* fix test

* trigger CI
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Exception Handling pr-work-in-progress PR is still work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants