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

Conversation

@leezu
Copy link
Contributor

@leezu leezu commented Oct 19, 2020

Prior implementation recorded reshape with concrete shapes used during the particular invocation of At.
New implementation uses records reshape with magic numbers to match symbolic interface.

Example of failure without this patch

=================================== FAILURES ===================================
______________________ test_gpt2_incremental_states[ctx0] ______________________

ctx = cpu(0)

    def test_gpt2_incremental_states(ctx):
        with ctx:
            batch_size = 4
            sequence_length = 5
            inputs = mx.np.random.randint(0, 1000, (batch_size, sequence_length), ctx=ctx)
    
            cfg = GPT2Model.get_cfg()
            gpt2_model = GPT2Model.from_cfg(cfg)
            gpt2_model.initialize(ctx=ctx)
            gpt2_model.hybridize()
    
            one_time_hiddens, one_time_states = gpt2_model(
                inputs,
                gpt2_model.init_states(batch_size, ctx)
            )
    
            states = gpt2_model.init_states(batch_size, ctx)
            hiddens_l = []
            for i in range(sequence_length):
>               hiddens, states = gpt2_model(
                    inputs[:, i:i+1],
                    states
                )

tests/test_models_gpt2.py:96: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/mxnet/util.py:298: in _with_np_shape
    return func(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/mxnet/util.py:482: in _with_np_array
    return func(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/mxnet/gluon/block.py:1429: in __call__
    return self._call_cached_op(x, *args)
/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/mxnet/util.py:298: in _with_np_shape
    return func(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/mxnet/util.py:482: in _with_np_array
    return func(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/mxnet/gluon/block.py:1131: in _call_cached_op
    out = self._cached_op(*cargs)
/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/mxnet/_ctypes/ndarray.py:171: in __call__
    check_call(_LIB.MXInvokeCachedOp(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

ret = -1

    def check_call(ret):
        """Check the return value of C API call.
    
        This function will raise an exception when an error occurs.
        Wrap every API call with this function.
    
        Parameters
        ----------
        ret : int
            return value from API calls.
        """
        if ret != 0:
>           raise get_last_ffi_error()
E           mxnet.base.MXNetError: MXNetError: Error in operator node_16288: [02:57:54] ../src/operator/numpy/np_matrix_op.cc:149: Check failed: src.Size() == dst->Size() (6144 vs. 0) : Cannot reshape array of size 6144 into shape [2,4,0,768]

Details on failure

Json export of the recorded graph contains the following segment. We can see the shape of the first forward pass was hardcoded by the AtWithRecord implementation.

    {
      "op": "slice",
      "name": "node_10",
      "attrs": {
        "begin": "0",
        "end": "1"
      },
      "inputs": [[5, 0, 0]]
    },
    {
      "op": "_np_reshape",
      "name": "node_11",
      "attrs": {"newshape": "[2,4,0,768]"},
      "inputs": [[14, 0, 0]]
}

Prior implementation recorded reshape with concrete shapes used during the particular invocation of At.
New implementation uses records reshape with magic numbers to match symbolic interface.
@mxnet-bot
Copy link

Hey @leezu , 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: [clang, miscellaneous, centos-cpu, windows-gpu, edge, sanity, unix-gpu, website, unix-cpu, centos-gpu, windows-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.

@leezu leezu requested review from sxjscience and szha October 19, 2020 04:13
@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 19, 2020
Copy link
Member

@sxjscience sxjscience left a comment

Choose a reason for hiding this comment

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

LGTM

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 19, 2020
@leezu
Copy link
Contributor Author

leezu commented Oct 19, 2020

@mxnet-bot run ci [centos-cpu, centos-gpu, edge, miscellaneous, unix-gpu]

#19373

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [edge, unix-gpu, centos-gpu, centos-cpu, miscellaneous]

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 19, 2020
@leezu
Copy link
Contributor Author

leezu commented Oct 19, 2020

@mxnet-bot run ci [centos-gpu, edge, miscellaneous, unix-gpu, unix-cpu]

#19373

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [miscellaneous, edge, centos-gpu, unix-gpu, unix-cpu]

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 19, 2020
@leezu
Copy link
Contributor Author

leezu commented Oct 19, 2020

@mxnet-bot run ci [miscellaneous, unix-gpu, unix-cpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [miscellaneous, unix-cpu, unix-gpu]

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 19, 2020
@leezu
Copy link
Contributor Author

leezu commented Oct 19, 2020

@mxnet-bot run ci [miscellaneous, unix-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [miscellaneous, unix-gpu]

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 19, 2020
@leezu
Copy link
Contributor Author

leezu commented Oct 20, 2020

@mxnet-bot run ci [unix-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [unix-gpu]

@lanking520 lanking520 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 20, 2020
@leezu leezu merged commit defaafe into apache:master Oct 20, 2020
@leezu leezu deleted the 2020-10/fix-at-with-record branch October 20, 2020 02:52
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.

4 participants