nv-morpheus / Morpheus

Morpheus SDK
Apache License 2.0
362 stars 135 forks source link

[BUG]: Morpheus does not build with `nlohmann_json=3.10` #1508

Open cwharris opened 8 months ago

cwharris commented 8 months ago

Version

24.03

Which installation method(s) does this occur on?

Source

Describe the bug.

Morpheus does not build with nlohmann_json=3.10. The following static_cast is failing in morpheus/pybind11/json.hpp at lines 103 and 150:

value = static_cast<const nlohmann::json_list>(
    mrc::pymrc::cast_from_pyobject(pybind11::reinterpret_borrow<pybind11::object>(src)));

Presumably the nlohmann::json is somehow being cast to a string prior to being cast to the nlohmann::json_list type (which is introduced by Morpheus, not officially nlohmann_json).

My have something to do with the changes in this commit: https://github.com/nlohmann/json/commit/b0e5965d712c501d6043eac17437c7a033d54ae3

Minimum reproducible example

Update dependencies.yaml to include `nlohmann_json=3.10` and try to build Morpheus.

Relevant log output

Click here to see error details

```
[95/117] Building CXX object morpheus/_lib/llm/CMakeFiles/morpheus._lib.llm.dir/module.cpp.o
FAILED: morpheus/_lib/llm/CMakeFiles/morpheus._lib.llm.dir/module.cpp.o 
/usr/bin/sccache /home/coder/.conda/envs/cyber/bin/x86_64-conda-linux-gnu-c++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_CONTEXT_DYN_LINK -DBOOST_CONTEXT_NO_LIB -DBOOST_FIBER_DYN_LINK -DBOOST_FIBER_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DFMT_HEADER_ONLY=1 -DGFLAGS_IS_A_DLL=0 -DGLOG_CUSTOM_PREFIX_SUPPORT -DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE -DRXCPP_USE_FIBERS -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO -DSPDLOG_FMT_EXTERNAL -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_DISABLE_ABI_NAMESPACE -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -DTHRUST_IGNORE_ABI_NAMESPACE_ERROR -DTRITON_ENABLE_GPU=1 -Dmorpheus__lib_llm_EXPORTS -I/home/coder/morpheus/morpheus/_lib/llm/include -I/home/coder/morpheus/morpheus/_lib/include -I/home/coder/morpheus/build/release/autogenerated/include -I/home/coder/morpheus/.cache/cpm/cccl/d00fec379a67cff2a0af27df9b39c0e812ab728e/thrust/thrust/cmake/../.. -I/home/coder/morpheus/.cache/cpm/cccl/d00fec379a67cff2a0af27df9b39c0e812ab728e/libcudacxx/lib/cmake/libcudacxx/../../../include -I/home/coder/morpheus/.cache/cpm/cccl/d00fec379a67cff2a0af27df9b39c0e812ab728e/cub/cub/cmake/../.. -I/home/coder/morpheus/.cache/cpm/rxcpp/b2d191b4c471273143046efec8f535a2cf41a228/Rx/v2/src -I/home/coder/morpheus/.cache/cpm/tritonclient/e92e64c6eda442021fa9b6090889f75c2ad63d45/src/c++/library -isystem /home/coder/morpheus/.cache/cpm/pybind11/1f8215fe2e46182f595323d354918e38202ac61a/include -isystem /home/coder/.conda/envs/cyber/include/python3.10 -isystem /home/coder/mrc/python/mrc/_pymrc/include -isystem /home/coder/mrc/cpp/mrc/include -isystem /home/coder/mrc/build/release/autogenerated/include -isystem /home/coder/mrc/build/release/protos -isystem /home/coder/.conda/envs/cyber/include/librdkafka -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/coder/.conda/envs/cyber/include  -I/home/coder/.conda/envs/cyber/targets/x86_64-linux/include  -L/home/coder/.conda/envs/cyber/targets/x86_64-linux/lib -L/home/coder/.conda/envs/cyber/targets/x86_64-linux/lib/stubs -O3 -DNDEBUG -std=gnu++20 -fPIC -fvisibility=hidden -flto -fno-fat-lto-objects -pthread -MD -MT morpheus/_lib/llm/CMakeFiles/morpheus._lib.llm.dir/module.cpp.o -MF morpheus/_lib/llm/CMakeFiles/morpheus._lib.llm.dir/module.cpp.o.d -o morpheus/_lib/llm/CMakeFiles/morpheus._lib.llm.dir/module.cpp.o -c /home/coder/morpheus/morpheus/_lib/llm/module.cpp
In file included from /home/coder/.conda/envs/cyber/include/nlohmann/adl_serializer.hpp:6,
                 from /home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:60,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_task.hpp:22,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_context.hpp:22,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/./include/py_llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/module.cpp:18:
/home/coder/.conda/envs/cyber/include/nlohmann/detail/conversions/from_json.hpp: In instantiation of 'void nlohmann::detail::from_json(const BasicJsonType&, ConstructibleStringType&) [with BasicJsonType = nlohmann::basic_json<>; ConstructibleStringType = nlohmann::json_dict; typename std::enable_if<(nlohmann::detail::is_constructible_string_type::value && (! std::is_same::value)), int>::type  = 0]':
/home/coder/.conda/envs/cyber/include/nlohmann/detail/conversions/from_json.hpp:480:25:   required from 'decltype (nlohmann::detail::from_json(j, forward(val))) nlohmann::detail::from_json_fn::operator()(const BasicJsonType&, T&&) const [with BasicJsonType = nlohmann::basic_json<>; T = nlohmann::json_dict&; decltype (nlohmann::detail::from_json(j, forward(val))) = void]'
/home/coder/.conda/envs/cyber/include/nlohmann/adl_serializer.hpp:25:30:   required from 'static decltype ((nlohmann::{anonymous}::from_json(forward(j), val), void())) nlohmann::adl_serializer::from_json(BasicJsonType&&, TargetType&) [with BasicJsonType = const nlohmann::basic_json<>&; TargetType = nlohmann::json_dict; ValueType = nlohmann::json_dict;  = void; decltype ((nlohmann::{anonymous}::from_json(forward(j), val), void())) = void]'
/home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:1602:45:   required from 'ValueType nlohmann::basic_json::get_impl(nlohmann::detail::priority_tag<0>) const [with ValueType = nlohmann::json_dict; typename std::enable_if<(nlohmann::detail::is_default_constructible::value && nlohmann::detail::has_from_json, ValueType>::value), int>::type  = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector]'
/home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:1745:35:   required from 'constexpr decltype (declval().get_impl(nlohmann::detail::priority_tag<4>{})) nlohmann::basic_json::get() const [with ValueTypeCV = nlohmann::json_dict; ValueType = nlohmann::json_dict; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector; decltype (declval().get_impl(nlohmann::detail::priority_tag<4>{})) = nlohmann::json_dict; nlohmann::basic_json::basic_json_t = nlohmann::basic_json<>]'
/home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:1888:30:   required from 'nlohmann::basic_json::operator ValueType() const [with ValueType = nlohmann::json_dict; typename std::enable_if >, nlohmann::detail::negation > > >, nlohmann::detail::negation >, nlohmann::detail::negation >, nlohmann::detail::negation > >, nlohmann::detail::negation > > >, nlohmann::detail::is_detected_lazy&, ValueType> >::value, int>::type  = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector]'
/home/coder/morpheus/morpheus/_lib/include/morpheus/pybind11/json.hpp:103:96:   required from here
/home/coder/.conda/envs/cyber/include/nlohmann/detail/conversions/from_json.hpp:121:7: error: no match for 'operator=' (operand types are 'nlohmann::json_dict' and 'const string_t' {aka 'const std::__cxx11::basic_string'})
  121 |     s = *j.template get_ptr();
      |     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_context.hpp:24,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/./include/py_llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/module.cpp:18:
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:30:7: note: candidate: 'nlohmann::json_dict& nlohmann::json_dict::operator=(const nlohmann::json_dict&)'
   30 | class json_dict : public basic_json<>
      |       ^~~~~~~~~
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:30:7: note:   no known conversion for argument 1 from 'const string_t' {aka 'const std::__cxx11::basic_string'} to 'const nlohmann::json_dict&'
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:30:7: note: candidate: 'nlohmann::json_dict& nlohmann::json_dict::operator=(nlohmann::json_dict&&)'
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:30:7: note:   no known conversion for argument 1 from 'const string_t' {aka 'const std::__cxx11::basic_string'} to 'nlohmann::json_dict&&'
In file included from /home/coder/.conda/envs/cyber/include/nlohmann/adl_serializer.hpp:6,
                 from /home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:60,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_task.hpp:22,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_context.hpp:22,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/./include/py_llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/module.cpp:18:
/home/coder/.conda/envs/cyber/include/nlohmann/detail/conversions/from_json.hpp: In instantiation of 'void nlohmann::detail::from_json(const BasicJsonType&, ConstructibleStringType&) [with BasicJsonType = nlohmann::basic_json<>; ConstructibleStringType = nlohmann::json_list; typename std::enable_if<(nlohmann::detail::is_constructible_string_type::value && (! std::is_same::value)), int>::type  = 0]':
/home/coder/.conda/envs/cyber/include/nlohmann/detail/conversions/from_json.hpp:480:25:   required from 'decltype (nlohmann::detail::from_json(j, forward(val))) nlohmann::detail::from_json_fn::operator()(const BasicJsonType&, T&&) const [with BasicJsonType = nlohmann::basic_json<>; T = nlohmann::json_list&; decltype (nlohmann::detail::from_json(j, forward(val))) = void]'
/home/coder/.conda/envs/cyber/include/nlohmann/adl_serializer.hpp:25:30:   required from 'static decltype ((nlohmann::{anonymous}::from_json(forward(j), val), void())) nlohmann::adl_serializer::from_json(BasicJsonType&&, TargetType&) [with BasicJsonType = const nlohmann::basic_json<>&; TargetType = nlohmann::json_list; ValueType = nlohmann::json_list;  = void; decltype ((nlohmann::{anonymous}::from_json(forward(j), val), void())) = void]'
/home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:1602:45:   required from 'ValueType nlohmann::basic_json::get_impl(nlohmann::detail::priority_tag<0>) const [with ValueType = nlohmann::json_list; typename std::enable_if<(nlohmann::detail::is_default_constructible::value && nlohmann::detail::has_from_json, ValueType>::value), int>::type  = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector]'
/home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:1745:35:   required from 'constexpr decltype (declval().get_impl(nlohmann::detail::priority_tag<4>{})) nlohmann::basic_json::get() const [with ValueTypeCV = nlohmann::json_list; ValueType = nlohmann::json_list; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector; decltype (declval().get_impl(nlohmann::detail::priority_tag<4>{})) = nlohmann::json_list; nlohmann::basic_json::basic_json_t = nlohmann::basic_json<>]'
/home/coder/.conda/envs/cyber/include/nlohmann/json.hpp:1888:30:   required from 'nlohmann::basic_json::operator ValueType() const [with ValueType = nlohmann::json_list; typename std::enable_if >, nlohmann::detail::negation > > >, nlohmann::detail::negation >, nlohmann::detail::negation >, nlohmann::detail::negation > >, nlohmann::detail::negation > > >, nlohmann::detail::is_detected_lazy&, ValueType> >::value, int>::type  = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector]'
/home/coder/morpheus/morpheus/_lib/include/morpheus/pybind11/json.hpp:150:96:   required from here
/home/coder/.conda/envs/cyber/include/nlohmann/detail/conversions/from_json.hpp:121:7: error: no match for 'operator=' (operand types are 'nlohmann::json_list' and 'const string_t' {aka 'const std::__cxx11::basic_string'})
  121 |     s = *j.template get_ptr();
      |     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_context.hpp:24,
                 from /home/coder/morpheus/morpheus/_lib/include/morpheus/llm/llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/./include/py_llm_engine.hpp:23,
                 from /home/coder/morpheus/morpheus/_lib/llm/module.cpp:18:
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:37:7: note: candidate: 'nlohmann::json_list& nlohmann::json_list::operator=(const nlohmann::json_list&)'
   37 | class json_list : public basic_json<>
      |       ^~~~~~~~~
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:37:7: note:   no known conversion for argument 1 from 'const string_t' {aka 'const std::__cxx11::basic_string'} to 'const nlohmann::json_list&'
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:37:7: note: candidate: 'nlohmann::json_list& nlohmann::json_list::operator=(nlohmann::json_list&&)'
/home/coder/morpheus/morpheus/_lib/include/morpheus/utilities/json_types.hpp:37:7: note:   no known conversion for argument 1 from 'const string_t' {aka 'const std::__cxx11::basic_string'} to 'nlohmann::json_list&&'
```

Full env printout

Click here to see environment details

 [Paste the results of print_env.sh here, it will be hidden by default]

Other/Misc.

No response

Code of Conduct

cwharris commented 8 months ago

nlohmann_json=3.10.5 introduces some extra type restrictions over =3.9.1 which makes the json_list and json_dict types declared in morpheus not usable with =3.10.5. However, simply removing these types (which appear to be unused) resolves the issue.