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

Add Large Tensor Test for linalg_syrk #18782

Merged
merged 5 commits into from
Jul 24, 2020

Conversation

Zha0q1
Copy link
Contributor

@Zha0q1 Zha0q1 commented Jul 23, 2020

Description

Check if syrk_batch works correctly with large tensors. This test will fail with the current code base; #18752 should fix it.

TODO:

  1. make test function naming consistent with other large tensor tests (need to rebase after any of those tests are merged)
  2. merge this only after the fix has been merged

This test passes on both BLAS int32 and 64 builds.

ubuntu@ip-172-31-43-103:~$ MXNET_TEST_COUNT=10000 nosetests --logging-level=DEBUG --verbose -s mxnet/tests/nightly/test_large_array.py:test_linalg_operators
test_large_array.test_linalg_operators ... [23:14:57] ../src/storage/storage.cc:198: Using Pooled (Naive) StorageManager for CPU
ok

----------------------------------------------------------------------
Ran 1 test in 637.245s

OK

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 https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • 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

  • 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

@mxnet-bot
Copy link

Hey @Zha0q1 , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [windows-cpu, centos-cpu, windows-gpu, sanity, edge, miscellaneous, clang, centos-gpu, website, unix-gpu, unix-cpu]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@access2rohit
Copy link
Contributor

@Zha0q1 can you fix this issue with your PR "This branch is out-of-date with the base branch"

@Zha0q1
Copy link
Contributor Author

Zha0q1 commented Jul 23, 2020

@Zha0q1 can you fix this issue with your PR "This branch is out-of-date with the base branch"

Fixed.

A.attach_grad()
with mx.autograd.record():
out = nd.linalg.syrk(A, alpha=2, transpose=False)
for i in range(LARGE_SQ_X):
Copy link
Contributor

Choose a reason for hiding this comment

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

You can check in 2 places in (0,y,y) and (1,y,y). No need to check in 70000 locations

assert out[0,i,i] == 2
assert_almost_equal(out[1,i,i], nd.array([0.02]), rtol=1e-3, atol=1e-5)
out.backward()
for i in range(LARGE_SQ_X):
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

for i in range(LARGE_SQ_X):
# check the first row
assert A.grad[0,0,i] == 4
assert_almost_equal(A.grad[1,0,i], nd.array([0.4]), rtol=1e-3, atol=1e-5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Why did this become 0.4 and not 0.04 ? OR just let me know if this output is consistent with smaller inputs like 2x2 or 3x3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the correct result I believe. I verified with hand-written calculation. Yeah it also struck as counter-intuitive to me.. I am going to dive deep in matrix grad when I find time

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just check with smaller input run and let me know the results. That should be good enough

@access2rohit
Copy link
Contributor

Few comments ... overall code is good

Copy link
Contributor

@access2rohit access2rohit left a comment

Choose a reason for hiding this comment

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

Can you just check with smaller input run and let me know the results. That should be good enough .... overall LGTM!

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
Thanks!

@Zha0q1
Copy link
Contributor Author

Zha0q1 commented Jul 24, 2020

Can you just check with smaller input run and let me know the results. That should be good enough .... overall LGTM!

This has been tested with both small and large input tensors

@Zha0q1 Zha0q1 changed the title [WIP] Add Large Tensor Test for linalg_syrk Add Large Tensor Test for linalg_syrk Jul 24, 2020
@@ -37,7 +37,7 @@
LARGE_X = 100000000
SMALL_X = 100
SMALL_Y = 50
LARGE_SQ_X = 80000
LARGE_SQ_X = 70000
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Contributor

Choose a reason for hiding this comment

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

70000*70000/2**32 is just over 2**32
80k is lot more

Copy link
Contributor Author

@Zha0q1 Zha0q1 Jul 24, 2020

Choose a reason for hiding this comment

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

We figured 7000 is large enough to overflow int 32. This is a new constant just introduced so the few of us decided to tweak it to 70000

Copy link
Contributor

Choose a reason for hiding this comment

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

70k * 70k = 4.9 billion
int32 range < 4.3 billion
Therefore increasing input size will only increase test runtime.

@ChaiBapchya
Copy link
Contributor

ChaiBapchya commented Jul 24, 2020

@Zha0q1 also add your name to Contributors.md in the upcoming PR [let's not retrigger CI for that].
https://github.com/apache/incubator-mxnet/blob/master/CONTRIBUTORS.md
Thanks a lot for your contributions! :)

@Zha0q1
Copy link
Contributor Author

Zha0q1 commented Jul 24, 2020

@Zha0q1 also add your name to Contributors.md in the upcoming PR [let's not retrigger CI for that].
https://github.com/apache/incubator-mxnet/blob/master/CONTRIBUTORS.md
Thanks a lot for your contributions! :)

will do!

@szha szha merged commit 85ff00d into apache:v1.x Jul 24, 2020
ChaiBapchya pushed a commit to ChaiBapchya/mxnet that referenced this pull request Aug 15, 2020
* add large tensor test for syrk, foward and backward

* change to batch input

* move syrk test into test-linalg

Co-authored-by: Ubuntu <ubuntu@ip-172-31-6-47.us-west-2.compute.internal>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants