[REVIEW] Add OpenSearch backend to cuvs-bench#2012
[REVIEW] Add OpenSearch backend to cuvs-bench#2012jrbourbeau wants to merge 8 commits intorapidsai:mainfrom
cuvs-bench#2012Conversation
Signed-off-by: James Bourbeau <jbourbeau@nvidia.com>
| print( | ||
| f"Build failed for {config.index_name}: {build_result.error_message}" | ||
| try: | ||
| backend.initialize() |
There was a problem hiding this comment.
Note to reviewers: This is a separate, but related change to the orchestrator. I noticed the initialize and cleanup methods weren't actually being called like their docstrings said they were suppose to. This is a big diff but most of it is just intending over the existing code into a try/except block. The functional change is calling initialize + cleanup
EDIT: FWIW supporting a context manager for backend setup / teardown seems reasonable. But that's also not something I wanted to handle in this PR.
There was a problem hiding this comment.
Good catch. The initialize() and cleanup() hooks in BenchmarkBackend are defined in the abstract base class with docstrings describing their intended purpose, but neither method is actually called by the BenchmarkOrchestrator in _run_sweep() or _run_trial(). This was an oversight because the only backend implemented at the time was CppGoogleBenchmarkBackend, whose lifecycle is entirely self-contained within each subprocess call to build()/search(), making initialize()/cleanup() unnecessary for it.
There was a problem hiding this comment.
EDIT: FWIW supporting a context manager for backend setup / teardown seems reasonable. But that's also not something I wanted to handle in this PR.
I Agree that context manager support is reasonable. The purpose of the pluggable backend API is precisely to enable these kinds of extensions without modifying the core orchestrator. Since initialize() and cleanup() are already part of the BenchmarkBackend interface, wiring them up in the orchestrator (whether as explicit calls or a context manager) would ensure the plugin system works end-to-end for future backends without requiring further modifications to the core
There was a problem hiding this comment.
Overall, I think we're leaning a little too strongly on the local (individual backend) vs global (benchmark orchestrator) control and we should probably prioritize global control for all boilerplate things so that we're not having to reimplement them in each backend. I'm okay doing this in follow-ups, but the way we typically handle these types of things is to create a github issue that clearly explains the intended changes for the follow-up (explain it in a way that assumes someone else might have to pick it up in the future, just in case) and then reference a link to the issue in a todo comment in the code where the change is intended to be made. This makes sure 1) people reading the code are aware of the intentions, and 2) the issue doesn't get orphaned and forgotten.
|
|
||
| [tool.pytest.ini_options] | ||
| markers = [ | ||
| "integration: tests that require a live OpenSearch node (run with '-m integration')", |
There was a problem hiding this comment.
TODO: Make this more generic language (not just opensearch)
…ch-opensearch Signed-off-by: James Bourbeau <jbourbeau@nvidia.com>
…ch-opensearch Signed-off-by: James Bourbeau <jbourbeau@nvidia.com>
cuvs-benchcuvs-bench
|
|
||
| ext = os.path.splitext(path)[1].lower() | ||
| dtype = _DTYPE_FOR_EXT.get(ext, np.float32) | ||
| with open(path, "rb") as f: |
There was a problem hiding this comment.
I mentioned this in the elasticsearch PR as well- we should standardize/centralize these calls so that we're not having to manually implement them for every backend. The benchmark should be opening the files and passing the vectors or the file handle) down to the actual backends.
There was a problem hiding this comment.
Don't disagree with this comment (or the other ones about consolidating various utilities). IIUC it sounds like these will need deeper changes to the config loader / orchestrator specs. Is that something that's needed in this PR, or is a follow up to refactor fine?
There was a problem hiding this comment.
Since both backends(elastic search and OpenSearch) are separately implementing this, a follow up PR consolidating both might be easier especially since both PRs are still open. Otherwise I can push a PR consolidating those various utilities (general purpose) based on both PRs which they can pull after it is merged
| return data.reshape(n_rows, n_cols) | ||
|
|
||
|
|
||
| def _load_yaml(path: str) -> Any: |
There was a problem hiding this comment.
This and the dataset config should also be getting loaded by the benchmark itself and not the backend. @jnke2016
|
|
||
|
|
||
| def _gather_algo_configs( | ||
| config_path: str, algorithm_configuration: Optional[str] |
|
|
||
| benchmark_configs: List[BenchmarkConfig] = [] | ||
|
|
||
| for algo_file in algo_files: |
There was a problem hiding this comment.
Yeah, this is all boilerplate- exactly why this should be centralized. The resulting config dicts should be loaded from the files by the benchmark and passed down to the individual backends. It's important that this is standardized across benchmarks so that we don't have specific backends doing things drastically different than others (that just makes it super complicated for everyone. But also, if we find a bug in a spcific loader or decide to change how we do things generally, every single backend then needs to be updated individually instead of just changing it one place ) @jnke2016
There was a problem hiding this comment.
So the loading pipeline (loading dataset YAML, gathering algorithm files, filtering by algorithm/group names etc ..) is a shared logic that should be centralized in the base ConfigLoader instead of having each backend implementing this.
| method_params = {"nlist": build_param.get("nlist", 4)} | ||
| else: | ||
| raise ValueError( | ||
| f"Unsupported faiss_method {faiss_method!r}. " |
There was a problem hiding this comment.
Yes! This is important. I believe i suggested that this be done in the eladticserch PR as well. Need to fail gracefully when the user configures somethign that's not supported (or loads the wrong file).
|
cc @navneet1v for thoughts / feedback on the opensearch backend for cuvs-bench. |
Would still like to refine a bit but pushing up for early feedback
cc @singhmanas1 @janakivamaraju @afourniernv
xref #1907 which does something similar but for Elastic
EDIT: Okay, this is now ready for review (cc @jnke2016)