`FaissIndex` to support multiple GPU and `custom_index`
{'login': 'rentruewang', 'id': 32859905, 'node_id': 'MDQ6VXNlcjMyODU5OTA1', 'avatar_url': 'https://avatars.githubusercontent.com/u/32859905?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/rentruewang', 'html_url': 'https://github.com/rentruewang', 'followers_url': 'https://api.github.com/users/rentruewang/followers', 'following_url': 'https://api.github.com/users/rentruewang/following{/other_user}', 'gists_url': 'https://api.github.com/users/rentruewang/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/rentruewang/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/rentruewang/subscriptions', 'organizations_url': 'https://api.github.com/users/rentruewang/orgs', 'repos_url': 'https://api.github.com/users/rentruewang/repos', 'events_url': 'https://api.github.com/users/rentruewang/events{/privacy}', 'received_events_url': 'https://api.github.com/users/rentruewang/received_events', 'type': 'User', 'site_admin': False}
[{'id': 1935892871, 'node_id': 'MDU6TGFiZWwxOTM1ODkyODcx', 'url': 'https://api.github.com/repos/huggingface/datasets/labels/enhancement', 'name': 'enhancement', 'color': 'a2eeef', 'default': True, 'description': 'New feature or request'}]
[]
Hi @rentruewang, thansk for reporting and for your PR!!! We should definitely support this.  @albertvillanova Great! :)
**Is your feature request related to a problem? Please describe.**
Currently, because `device` is of the type `int | None`, to leverage `faiss-gpu`'s multi-gpu support, you need to create a `custom_index`. However, if using a `custom_index` created by e.g. `faiss.index_cpu_to_all_gpus`, then `FaissIndex.save` does not work properly because it checks the device id (which is an int, so no multiple GPUs).

**Describe the solution you'd like**
I would like `FaissIndex` to support multiple GPUs, by passing in a list to `add_faiss_index`.

**Describe alternatives you've considered**
Alternatively, I would like it to at least provide a warning cause it wasn't the behavior that I expected.

**Additional context**
Relavent source code here:
 https://github.com/huggingface/datasets/blob/6ed6ac9448311930557810383d2cfd4fe6aae269/src/datasets/search.py#L340-L349

Device management needs changing to support multiple GPUs, probably by `isinstance` calls.

I can provide a PR if you like :)

Thanks for reading!

{'url': 'https://api.github.com/repos/huggingface/datasets/issues/3716/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}