Skip to content

Conversation

@smessmer
Copy link
Contributor

@smessmer smessmer commented Apr 30, 2019

Stack:
    :white_circle:  #20185 Extend testAvailableArgTypes  💚
    :white_circle:  #20184 Allow Dict type in c10 operators  💚
    :black_circle:  #19976 Dict  💚

Implement a Dict type that allows us to abstract away from the concrete implementation used.
The API is similar to std::unordered_map, but behind the scenes we can switch to any map implementation we like. ska::flat_hash_map, google dense map, or any future map implementation with better performance.
Switching such an implementation choice does not have to break backwards compatibility of kernel code using the Dict type.

Differential Revision: D15156384

Differential Revision: D15156384
Differential Version: 80987102
@pytorchbot pytorchbot added the module: internals Related to internal abstractions in c10 and ATen label Apr 30, 2019
Differential Revision: D15156384
Differential Version: 80987420
@dzhulgakov dzhulgakov requested review from dzhulgakov and li-roy May 1, 2019 03:24
Copy link
Collaborator

@dzhulgakov dzhulgakov left a comment

Choose a reason for hiding this comment

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

Looks pretty good, but the build seems to be broken.

Differential Revision: D15156384
Differential Version: 81123864
Differential Revision: D15156384
Differential Version: 81148985
smessmer added 6 commits May 3, 2019 17:46
Differential Revision: D15156384
Differential Version: 81201175
Differential Revision: D15156384
Differential Version: 81204262
Differential Revision: D15156384
Differential Version: 81214399
Differential Revision: D15156384
Differential Version: 81235671
Differential Revision: D15156384
Differential Version: 81242194
Differential Revision: D15156384
Differential Version: 81263200
smessmer added 4 commits May 6, 2019 18:02
Differential Revision: D15156384
Differential Version: 81279543
Differential Revision: D15156384
Differential Version: 81330634
Differential Revision: D15156384
Differential Version: 81395862
Differential Revision: D15156384
Differential Version: 81416436
@yf225 yf225 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label May 9, 2019
Differential Revision: D15156384
Differential Version: 81423413
zdevito pushed a commit to zdevito/ATen that referenced this pull request May 9, 2019
Summary:
Pull Request resolved: pytorch/pytorch#19976

Implement a Dict type that allows us to abstract away from the concrete implementation used.
The API is similar to std::unordered_map, but behind the scenes we can switch to any map implementation we like. ska::flat_hash_map, google dense map, or any future map implementation with better performance.
Switching such an implementation choice does not have to break backwards compatibility of kernel code using the Dict type.

Reviewed By: li-roy

Differential Revision: D15156384

fbshipit-source-id: b9313ec4dd9acb3b6a0035345b6ba4f2a437d1e5
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in c921290.

@zdevito
Copy link
Contributor

zdevito commented May 10, 2019

This is a giant patch (nearly 2000 lines changes) that makes organization changes to JIT primitives (where is ivalue defined now? not in ivalue.h!). The reviews for it have 0 comments, the commit message doesn't discuss this reorganization, and no member of the JIT team was asked to review it.

@soumith
Copy link
Member

soumith commented May 10, 2019

@smessmer this doesn't sound right. can you please get it reviewed properly next time.

@soumith
Copy link
Member

soumith commented May 10, 2019

actually, probably this time

@ezyang
Copy link
Contributor

ezyang commented May 10, 2019

Also, it broke ASAN

May 09 03:23:03 test_cdf (__main__.TestJit) ... /var/lib/jenkins/workspace/aten/src/ATen/core/ivalue.h:25:53: runtime error: downcast of address 0x6040001295d0 which does not point to an object of type 'c10::ivalue::List<at::Tensor>'
May 09 03:23:03 0x6040001295d0: note: object is of type 'c10::ivalue::List<at::Tensor>'
May 09 03:23:03  1d 01 80 35  98 a6 79 e9 5b 7f 00 00  01 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  70 26 18 00
May 09 03:23:03               ^~~~~~~~~~~~~~~~~~~~~~~
May 09 03:23:03               vptr for 'c10::ivalue::List<at::Tensor>'
May 09 03:23:03     #0 0x7f5bef98e5e5 in c10::intrusive_ptr<c10::ivalue::List<at::Tensor>, c10::detail::intrusive_target_default_null_type<c10::ivalue::List<at::Tensor> > > c10::IValue::toIntrusivePtr<c10::ivalue::List<at::Tensor>, c10::detail::intrusive_target_default_null_type<c10::ivalue::List<at::Tensor> > >() const (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0x14a15e5)
May 09 03:23:03     #1 0x7f5bd2147384 in c10::IValue::toTensorList() const & (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch.so.1+0x2e3b384)
May 09 03:23:03     #2 0x7f5bd24761c2 in std::_Function_handler<int (std::vector<c10::IValue, std::allocator<c10::IValue> >&), torch::jit::(anonymous namespace)::$_50::operator()(torch::jit::Node const*) const::{lambda(std::vector<c10::IValue, std::allocator<c10::IValue> >&)#3}>::_M_invoke(std::_Any_data const&, std::vector<c10::IValue, std::allocator<c10::IValue> >&) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch.so.1+0x316a1c2)
May 09 03:23:03     #3 0x7f5bd21cd644 in torch::jit::InterpreterStateImpl::runImpl(std::vector<c10::IValue, std::allocator<c10::IValue> >&) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch.so.1+0x2ec1644)
May 09 03:23:03     #4 0x7f5bd21b703f in torch::jit::InterpreterStateImpl::run(std::vector<c10::IValue, std::allocator<c10::IValue> >&) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch.so.1+0x2eab03f)
May 09 03:23:03     #5 0x7f5bd213f3bb in torch::jit::(anonymous namespace)::ExecutionPlan::run(std::vector<c10::IValue, std::allocator<c10::IValue> >&) const (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch.so.1+0x2e333bb)
May 09 03:23:03     #6 0x7f5bd21407c6 in torch::jit::GraphExecutorImpl::run(std::vector<c10::IValue, std::allocator<c10::IValue> >&) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch.so.1+0x2e347c6)
May 09 03:23:03     #7 0x7f5befb8a601 in pybind11::object torch::jit::invokeScriptMethodFromPython<torch::jit::script::Function>(torch::jit::script::Function&, torch::jit::tuple_slice, pybind11::kwargs) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0x169d601)
May 09 03:23:03     #8 0x7f5befb0c43c in void pybind11::cpp_function::initialize<torch::jit::script::initJitScriptBindings(_object*)::$_20, pybind11::object, pybind11::args, pybind11::kwargs, pybind11::name, pybind11::is_method, pybind11::sibling>(torch::jit::script::initJitScriptBindings(_object*)::$_20&&, pybind11::object (*)(pybind11::args, pybind11::kwargs), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#1}::__invoke(pybind11::detail::function_call&) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0x161f43c)
May 09 03:23:03     #9 0x7f5bef0ed1c9 in pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0xc001c9)
May 09 03:23:03     #10 0x559a50902743 in _PyCFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/methodobject.c:231
May 09 03:23:03     #11 0x559a50902b5e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2313
May 09 03:23:03     #12 0x559a509076a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
May 09 03:23:03     #13 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #14 0x559a5095ca90 in slot_tp_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6207
May 09 03:23:03     #15 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #16 0x559a509afa6b in do_call_core /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
May 09 03:23:03     #17 0x559a509afa6b in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
May 09 03:23:03     #18 0x559a50982bfd in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #19 0x559a50983770 in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
May 09 03:23:03     #20 0x559a50989504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
May 09 03:23:03     #21 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #22 0x559a509848c5 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #23 0x559a509848c5 in PyEval_EvalCodeEx /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4187
May 09 03:23:03     #24 0x559a509851a5 in function_call /tmp/build/80754af9/python_1546130271559/work/Objects/funcobject.c:604
May 09 03:23:03     #25 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #26 0x559a509afa6b in do_call_core /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
May 09 03:23:03     #27 0x559a509afa6b in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
May 09 03:23:03     #28 0x559a50982bfd in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #29 0x559a50983770 in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
May 09 03:23:03     #30 0x559a50989504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
May 09 03:23:03     #31 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #32 0x559a509828e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #33 0x559a50983770 in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
May 09 03:23:03     #34 0x559a50989504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
May 09 03:23:03     #35 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #36 0x559a50982bfd in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #37 0x559a50983770 in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
May 09 03:23:03     #38 0x559a50989504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
May 09 03:23:03     #39 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #40 0x559a509828e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #41 0x559a50983e69 in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
May 09 03:23:03     #42 0x559a50902b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
May 09 03:23:03     #43 0x559a509076a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
May 09 03:23:03     #44 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #45 0x559a509afa6b in do_call_core /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
May 09 03:23:03     #46 0x559a509afa6b in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
May 09 03:23:03     #47 0x559a509828e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #48 0x559a50983c4b in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
May 09 03:23:03     #49 0x559a50902b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
May 09 03:23:03     #50 0x559a509076a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
May 09 03:23:03     #51 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #52 0x559a5095ca90 in slot_tp_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6207
May 09 03:23:03     #53 0x559a5090292a in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
May 09 03:23:03     #54 0x559a5098957d in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
May 09 03:23:03     #55 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #56 0x559a509828e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #57 0x559a50983e69 in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
May 09 03:23:03     #58 0x559a50902b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
May 09 03:23:03     #59 0x559a509076a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
May 09 03:23:03     #60 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #61 0x559a509afa6b in do_call_core /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
May 09 03:23:03     #62 0x559a509afa6b in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
May 09 03:23:03     #63 0x559a509828e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #64 0x559a50983c4b in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
May 09 03:23:03     #65 0x559a50902b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
May 09 03:23:03     #66 0x559a509076a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
May 09 03:23:03     #67 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #68 0x559a5095ca90 in slot_tp_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6207
May 09 03:23:03     #69 0x559a5090292a in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
May 09 03:23:03     #70 0x559a5098957d in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
May 09 03:23:03     #71 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #72 0x559a5098353a in _PyFunction_FastCall /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
May 09 03:23:03     #73 0x559a5098353a in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
May 09 03:23:03     #74 0x559a50989504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
May 09 03:23:03     #75 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #76 0x559a5098353a in _PyFunction_FastCall /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
May 09 03:23:03     #77 0x559a5098353a in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
May 09 03:23:03     #78 0x559a50989504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
May 09 03:23:03     #79 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #80 0x559a50982d70 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #81 0x559a50983e69 in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
May 09 03:23:03     #82 0x559a50902b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
May 09 03:23:03     #83 0x559a509076a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
May 09 03:23:03     #84 0x559a5090254d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
May 09 03:23:03     #85 0x559a5095c0fa in slot_tp_init /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6420
May 09 03:23:03     #86 0x559a50989766 in type_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:915
May 09 03:23:03     #87 0x559a5090292a in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
May 09 03:23:03     #88 0x559a50983a59 in _PyObject_FastCallKeywords /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2496
May 09 03:23:03     #89 0x559a5098957d in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
May 09 03:23:03     #90 0x559a509af146 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3351
May 09 03:23:03     #91 0x559a5093122a in _PyFunction_FastCall /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
May 09 03:23:03     #92 0x559a50989504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
May 09 03:23:03     #93 0x559a509ae389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
May 09 03:23:03     #94 0x559a50984288 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
May 09 03:23:03     #95 0x559a50984288 in PyEval_EvalCodeEx /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4187
May 09 03:23:03     #96 0x559a5098501b in PyEval_EvalCode /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:731
May 09 03:23:03     #97 0x559a50a073c3 in run_mod /tmp/build/80754af9/python_1546130271559/work/Python/pythonrun.c:1025
May 09 03:23:03     #98 0x559a50a077c0 in PyRun_FileExFlags /tmp/build/80754af9/python_1546130271559/work/Python/pythonrun.c:978
May 09 03:23:03     #99 0x559a50a079c2 in PyRun_SimpleFileExFlags /tmp/build/80754af9/python_1546130271559/work/Python/pythonrun.c:419
May 09 03:23:03     #100 0x559a50a0b4b2 in run_file /tmp/build/80754af9/python_1546130271559/work/Modules/main.c:340
May 09 03:23:03     #101 0x559a50a0b4b2 in Py_Main /tmp/build/80754af9/python_1546130271559/work/Modules/main.c:811
May 09 03:23:03     #102 0x559a508d402d in main /tmp/build/80754af9/python_1546130271559/work/Programs/python.c:69
May 09 03:23:03     #103 0x7f5c020a382f in __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:291
May 09 03:23:03     #104 0x559a509b4e0d in _start /home/rdonnelly/mc/conda-bld/compilers_linux-64_1534865402226/work/.build/src/glibc-2.12.2/csu/../sysdeps/x86_64/elf/start.S:103
May 09 03:23:03 
May 09 03:23:03 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /var/lib/jenkins/workspace/aten/src/ATen/core/ivalue.h:25:53 in 
May 09 03:23:03 Traceback (most recent call last):
May 09 03:23:03   File "test/run_test.py", line 439, in <module>
May 09 03:23:03     main()
May 09 03:23:03   File "test/run_test.py", line 431, in main
May 09 03:23:03     raise RuntimeError(message)
May 09 03:23:03 RuntimeError: test_distributions failed!

@ezyang ezyang deleted the export-D15156384 branch May 30, 2019 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: internals Related to internal abstractions in c10 and ATen triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants