pymilvus icon indicating copy to clipboard operation
pymilvus copied to clipboard

[Bug]: [milvus_client][milvus] Created HNSW index failed without ef input reporting "efConstruction out of range: [1, 2147483647])>"

Open binbinlv opened this issue 1 year ago • 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

The index always be "AUTOINDEX" no matter what kind of index type input

>>> milvus_client.describe_index(collection_name, "vector")
>>> {'index_type': 'AUTOINDEX', 'metric_type': 'IP', 'field_name': 'vector', 'index_name': 'vector'}
>>> index_params = milvus_client.prepare_index_params()
>>> index_params.add_index(field_name = "vector", index_type="HNSW", metric_type="L2")
>>> milvus_client.create_index(collection_name, index_params)
>>> milvus_client.describe_index(collection_name, "vector")
{'index_type': 'AUTOINDEX', 'metric_type': 'IP', 'field_name': 'vector', 'index_name': 'vector'}
>>> milvus_client.release_collection(collection_name)
>>> milvus_client.drop_index(collection_name, "vector")
>>> milvus_client.describe_index(collection_name, "vector")
>>> milvus_client.create_index(collection_name, index_params)
>>> milvus_client.describe_index(collection_name, "vector")
{'index_type': 'AUTOINDEX', 'metric_type': 'IP', 'field_name': 'vector', 'index_name': 'vector'}

Expected Behavior

Create inputted type of index

Steps/Code To Reproduce behavior

import time
import numpy as np
from pymilvus import (MilvusClient )

dim = 8
collection_name = "hello_milvus_new_1"
milvus_client = MilvusClient()
milvus_client.create_collection(collection_name, dim)
milvus_client.release_collection(collection_name)
milvus_client.drop_index(collection_name, "vector")
index_params = milvus_client.prepare_index_params()
index_params.add_index(field_name = "vector", index_type="HNSW", metric_type="L2")
milvus_client.create_index(collection_name, index_params)
milvus_client.describe_index(collection_name, "vector")

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0): master-20240122-a77693aa
- pymilvus version: 2.4.0rc24
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

No response

binbinlv avatar Jan 23 '24 08:01 binbinlv

And the metric_type did not change yet.

binbinlv avatar Jan 23 '24 08:01 binbinlv

/assign @czs007

binbinlv avatar Jan 23 '24 08:01 binbinlv

Not fixed with new error: pymilvus: 2.4.0rc30 milvus: master-20240205-a68b3213

results:

>>> index_params = milvus_client.prepare_index_params()
>>> index_params.add_index(field_name = "vector", index_type="HNSW", metric_type="L2")
>>>
>>> milvus_client.create_index(collection_name, index_params)
RPC error: [create_index], <MilvusException: (code=65535, message=efConstruction out of range: [1, 2147483647])>, <Time:{'RPC start': '2024-02-05 15:47:53.929151', 'RPC error': '2024-02-05 15:47:54.128284'}>
Failed to create an index on collection: hello_milvus_new_1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 158, in create_index
    self._create_index(collection_name, index_param, timeout=timeout, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 188, in _create_index
    raise ex from ex
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 177, in _create_index
    conn.create_index(
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 135, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 131, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 170, in handler
    return func(self, *args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 110, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 74, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/grpc_handler.py", line 936, in create_index
    check_status(status)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/utils.py", line 60, in check_status
    raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=65535, message=efConstruction out of range: [1, 2147483647])>

binbinlv avatar Feb 05 '24 07:02 binbinlv

@binbinlv this is normal Here, HNSW is specified, so it is not AutoIndex. Therefore, it is necessary to specify M and efConstruction. Since it is not specified here, efConstruction is set to 0, which is out of range [0, 2147483647).

czs007 avatar Feb 05 '24 12:02 czs007

It created the index successfully when specify all the index parameters:

>>> index_params.add_index(field_name = "vector", index_type="HNSW", metric_type="L2", efConstruction=100, M=10)
>>> milvus_client.create_index(collection_name, index_params)
>>>
>>> milvus_client.describe_index(collection_name, "vector")
{'index_type': 'HNSW', 'metric_type': 'L2', 'efConstruction': '100', 'M': '10', 'field_name': 'vector', 'index_name': 'vector'}

binbinlv avatar Feb 06 '24 02:02 binbinlv

But maybe we could have an enhancement, could we tell user all the required parameter when did not input all the parameters here:

>>> index_params = milvus_client.prepare_index_params()
>>> index_params.add_index(field_name = "vector", index_type="HNSW", metric_type="L2")
>>>
>>> milvus_client.create_index(collection_name, index_params)
RPC error: [create_index], <MilvusException: (code=65535, message=efConstruction out of range: [1, 2147483647])>, <Time:{'RPC start': '2024-02-05 15:47:53.929151', 'RPC error': '2024-02-05 15:47:54.128284'}>
Failed to create an index on collection: hello_milvus_new_1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 158, in create_index
    self._create_index(collection_name, index_param, timeout=timeout, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 188, in _create_index
    raise ex from ex
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 177, in _create_index
    conn.create_index(
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 135, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 131, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 170, in handler
    return func(self, *args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 110, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 74, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/grpc_handler.py", line 936, in create_index
    check_status(status)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/utils.py", line 60, in check_status
    raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=65535, message=efConstruction out of range: [1, 2147483647])>

>>> index_params.add_index(field_name = "vector", index_type="HNSW", metric_type="L2", efConstruction=100)
>>> milvus_client.create_index(collection_name, index_params)
RPC error: [create_index], <MilvusException: (code=65535, message=M out of range: [1, 2048])>, <Time:{'RPC start': '2024-02-06 10:26:39.871162', 'RPC error': '2024-02-06 10:26:40.043897'}>
Failed to create an index on collection: hello_milvus_new_1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 148, in create_index
    self._create_index(collection_name, index_param, timeout=timeout, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 170, in _create_index
    raise ex from ex
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 159, in _create_index
    conn.create_index(
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 135, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 131, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 170, in handler
    return func(self, *args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 110, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 74, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/grpc_handler.py", line 977, in create_index
    check_status(status)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/utils.py", line 60, in check_status
    raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=65535, message=M out of range: [1, 2048])>

binbinlv avatar Feb 06 '24 02:02 binbinlv