Skip to content

Commit

Permalink
Merge branch 'branch-25.02' of github.com:nv-morpheus/Morpheus into d…
Browse files Browse the repository at this point in the history
…avid-stubgen-2074
  • Loading branch information
dagardner-nv committed Dec 16, 2024
2 parents 2d20b8a + 5e1116d commit 3ddb1be
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 25 deletions.
1 change: 1 addition & 0 deletions ci/conda/recipes/morpheus-libs/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ outputs:
- cudf {{ rapids_version }}
- cython 3.0.*
- glog >=0.7.1,<0.8
- indicators=2.3
- libcudf {{ rapids_version }}
- librdkafka >=1.9.2,<1.10.0a0
- mrc {{ minor_version }}
Expand Down
1 change: 1 addition & 0 deletions ci/conda/recipes/morpheus/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ outputs:
- cudf {{ rapids_version }}
- cython 3.0.*
- glog >=0.7.1,<0.8
- indicators=2.3
- libcudf {{ rapids_version }}
- librdkafka >=1.9.2,<1.10.0a0
- mrc {{ minor_version }}
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies:
- grpcio-status
- gtest=1.14
- gxx=12.1
- httpx>=0.23,<0.28
- huggingface_hub=0.20.2
- include-what-you-use=0.20
- indicators=2.3
Expand Down Expand Up @@ -136,6 +137,7 @@ dependencies:
- faiss-cpu
- google-search-results==2.4
- langchain-nvidia-ai-endpoints==0.0.11
- langchain-openai==0.1.3
- langchain==0.1.16
- milvus==2.3.5
- nemollm==0.3.5
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/examples_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- feedparser=6.0
- grpcio
- grpcio-status
- httpx>=0.23,<0.28
- huggingface_hub=0.20.2
- jsonpatch>=1.33
- kfp
Expand Down Expand Up @@ -73,6 +74,7 @@ dependencies:
- faiss-cpu
- google-search-results==2.4
- langchain-nvidia-ai-endpoints==0.0.11
- langchain-openai==0.1.3
- langchain==0.1.16
- milvus==2.3.5
- nemollm==0.3.5
Expand Down
23 changes: 13 additions & 10 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,14 @@ dependencies:
common:
- output_types: [requirements]
packages:
- faiss-cpu
- google-search-results==2.4
- langchain==0.1.16
- langchain-nvidia-ai-endpoints==0.0.11
- &faiss-cpu faiss-cpu
- &google-search-results google-search-results==2.4
- &langchain langchain==0.1.16
- &langchain-nvidia-ai-endpoints langchain-nvidia-ai-endpoints==0.0.11
- &langchain-openai langchain-openai==0.1.3
- milvus==2.3.5 # update to match pymilvus when available
- pymilvus==2.3.6
- nemollm==0.3.5
- &nemollm nemollm==0.3.5

example-dfp-prod:
common:
Expand Down Expand Up @@ -487,6 +488,7 @@ dependencies:
- &transformers transformers=4.36.2 # newer versions are incompatible with our pinned version of huggingface_hub
- anyio>=3.7
- arxiv=1.4
- httpx>=0.23,<0.28 # work-around for https://github.com/openai/openai-python/issues/1915
- huggingface_hub=0.20.2 # work-around for https://github.com/UKPLab/sentence-transformers/issues/1762
- jsonpatch>=1.33
- newspaper3k=0.2
Expand All @@ -499,11 +501,12 @@ dependencies:
- requests-toolbelt=1.0 # Transitive dep needed by nemollm, specified here to ensure we get a compatible version
- pip
- pip:
- langchain==0.1.16
- langchain-nvidia-ai-endpoints==0.0.11
- faiss-cpu
- google-search-results==2.4
- nemollm==0.3.5
- *faiss-cpu
- *google-search-results
- *langchain
- *langchain-nvidia-ai-endpoints
- *langchain-openai
- *nemollm
- sentence-transformers==2.7 # using pip now instead of conda to avoid install of pytorch cpu

model-training-tuning:
Expand Down
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ COPY . ./

RUN --mount=type=cache,id=workspace_cache,target=/workspace/.cache,sharing=locked \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# Install git-lfs before running the build to avoid errors during conda build
/opt/conda/bin/mamba install -y -n base -c conda-forge "git-lfs" &&\
source activate base &&\
Expand Down Expand Up @@ -227,6 +228,7 @@ COPY ${MORPHEUS_ROOT_HOST}/conda/environments/dev_cuda-${CUDA_MAJOR_VER}${CUDA_M

# Update the morpheus environment
RUN --mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# Temp add channel_alias to get around conda 404 errors
conda config --env --set channel_alias ${CONDA_CHANNEL_ALIAS} &&\
/opt/conda/bin/conda env update --solver=libmamba -n morpheus --file conda/environments/dev.yaml &&\
Expand Down Expand Up @@ -263,6 +265,7 @@ COPY . ./

RUN --mount=type=cache,id=workspace_cache,target=/workspace/.cache,sharing=locked \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# Install git-lfs before running the build to avoid errors during conda build
/opt/conda/bin/mamba install -y -n base -c conda-forge "git-lfs" &&\
source activate base &&\
Expand All @@ -285,6 +288,7 @@ COPY . ./
RUN --mount=type=cache,id=workspace_cache,target=/workspace/.cache,sharing=locked \
--mount=type=bind,from=conda_bld_morpheus,source=/opt/conda/conda-bld,target=/opt/conda/conda-bld \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
source activate morpheus &&\
CONDA_ALWAYS_YES=true /opt/conda/bin/mamba install -n morpheus \
-c local \
Expand Down Expand Up @@ -314,6 +318,7 @@ COPY "${MORPHEUS_ROOT_HOST}/conda/environments/runtime_cuda-${CUDA_MAJOR_VER}${C
# Mount Morpheus conda package build in `conda_bld_morpheus`
RUN --mount=type=bind,from=conda_bld_morpheus,source=/opt/conda/conda-bld,target=/opt/conda/conda-bld \
--mount=type=cache,id=conda_pkgs,target=/opt/conda/pkgs,sharing=locked \
--mount=type=cache,id=pip_cache,target=/root/.cache/pip,sharing=locked \
# CVE-2018-20225 for the base pip, not the env one
# conda will ignore the request to remove pip
python -m pip uninstall -y pip && \
Expand Down
2 changes: 1 addition & 1 deletion examples/llm/agents/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from langchain.agents import initialize_agent
from langchain.agents import load_tools
from langchain.agents.agent import AgentExecutor
from langchain.llms.openai import OpenAI
from langchain_openai import OpenAI

from morpheus.config import Config
from morpheus.pipeline.linear_pipeline import LinearPipeline
Expand Down
43 changes: 39 additions & 4 deletions python/morpheus/morpheus/_lib/cudf_helpers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import itertools

import cudf
from cudf.core.column import ColumnBase
from cudf.core.dtypes import StructDtype

from libcpp.string cimport string
Expand All @@ -26,8 +29,6 @@ from pylibcudf.libcudf.table.table_view cimport table_view
from pylibcudf.libcudf.types cimport size_type

from cudf._lib.column cimport Column
from cudf._lib.utils cimport data_from_unique_ptr
from cudf._lib.utils cimport table_view_from_table

##### THE FOLLOWING CODE IS COPIED FROM CUDF AND SHOULD BE REMOVED WHEN UPDATING TO cudf>=24.12 #####
# see https://github.com/rapidsai/cudf/pull/17193 for details
Expand All @@ -39,6 +40,7 @@ cimport pylibcudf.libcudf.copying as cpp_copying
from pylibcudf.libcudf.column.column_view cimport column_view
from libcpp.memory cimport make_unique, unique_ptr
from pylibcudf.libcudf.scalar.scalar cimport scalar
from pylibcudf cimport Table as plc_Table
from cudf._lib.scalar cimport DeviceScalar

# imports needed for from_column_view_with_fix
Expand Down Expand Up @@ -289,8 +291,35 @@ cdef public api:
index_names = schema_infos[0:index_col_count] if index_col_count > 0 else None
column_names = schema_infos[index_col_count:]

data, index = data_from_unique_ptr(move(table.tbl), column_names=column_names, index_names=index_names)
plc_table = plc_Table.from_libcudf(move(table.tbl))

if index_names is None:
index = None
data = {
col_name: ColumnBase.from_pylibcudf(col)
for col_name, col in zip(
column_names, plc_table.columns()
)
}
else:
result_columns = [
ColumnBase.from_pylibcudf(col)
for col in plc_table.columns()
]
index = cudf.Index._from_data(
dict(
zip(
index_names,
result_columns[: len(index_names)],
)
)
)
data = dict(
zip(
column_names,
result_columns[len(index_names) :],
)
)
df = cudf.DataFrame._from_data(data, index)

# Update the struct field names after the DataFrame is created
Expand Down Expand Up @@ -356,7 +385,13 @@ cdef public api:

cdef vector[string] temp_col_names = get_column_names(table, True)

cdef table_view input_table_view = table_view_from_table(table, ignore_index=False)
cdef plc_Table plc_table = plc_Table(
[
col.to_pylibcudf(mode="read")
for col in itertools.chain(table.index._columns, table._columns)
]
)
cdef table_view input_table_view = plc_table.view()
cdef vector[string] index_names
cdef vector[string] column_names

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
faiss-cpu
google-search-results==2.4
langchain-nvidia-ai-endpoints==0.0.11
langchain-openai==0.1.3
langchain==0.1.16
milvus==2.3.5
nemollm==0.3.5
Expand Down
12 changes: 5 additions & 7 deletions tests/_utils/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ def mk_mock_openai_response(messages: list[str]) -> mock.MagicMock:
response = mock.MagicMock()

response.choices = [_mk_mock_choice(message) for message in messages]
response.dict.return_value = {
"choices": [{
'message': {
'role': 'assistant', 'content': message
}
} for message in messages]
}

response_dict = {"choices": [{'message': {'role': 'assistant', 'content': message}} for message in messages]}

response.dict.return_value = response_dict
response.model_dump.return_value = response_dict

return response

Expand Down
2 changes: 1 addition & 1 deletion tests/morpheus_llm/llm/nodes/test_langchain_agent_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
from langchain.agents import initialize_agent
from langchain.callbacks.manager import AsyncCallbackManagerForToolRun
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain_community.chat_models.openai import ChatOpenAI
from langchain_core.tools import BaseTool
from langchain_openai import ChatOpenAI
except ImportError:
pass

Expand Down
4 changes: 2 additions & 2 deletions tests/morpheus_llm/llm/test_agents_simple_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
from langchain.agents.tools import Tool
from langchain.schema import Generation
from langchain.schema import LLMResult
from langchain_community.llms import OpenAI # pylint: disable=no-name-in-module
from langchain_community.utilities import serpapi
from langchain_openai import OpenAI # pylint: disable=no-name-in-module
except ImportError:
pass

Expand Down Expand Up @@ -129,7 +129,7 @@ def test_agents_simple_pipe_integration_openai(config: Config, questions: list[s

@pytest.mark.usefixtures("openai", "restore_environ")
@mock.patch("langchain_community.utilities.serpapi.SerpAPIWrapper.aresults")
@mock.patch("langchain_community.llms.OpenAI._agenerate",
@mock.patch("langchain_openai.OpenAI._agenerate",
autospec=True) # autospec is needed as langchain will inspect the function
def test_agents_simple_pipe(mock_openai_agenerate: mock.AsyncMock,
mock_serpapi_aresults: mock.AsyncMock,
Expand Down

0 comments on commit 3ddb1be

Please sign in to comment.