perf: Add vector search stage metrics#5974
Draft
franciscojavierarceo wants to merge 6 commits into
Draft
Conversation
Add a configurable prefix-to-encoding mapping with sensible defaults for common non-OpenAI model families (llama, mistral, claude, gemma, qwen, phi, deepseek). This is the first step toward supporting compaction with non-OpenAI models. Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Replace the 2-step resolution (admin config OR tiktoken) with a 5-step chain: per-request extra_body override, admin default, tiktoken built-in, model-family prefix mapping, character-based estimate. Explicit choices fail hard with InvalidParameterError; automatic resolution falls through. Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com> # Conflicts: # docs/docs/providers/responses/inline_builtin.mdx # src/ogx/providers/inline/responses/builtin/config.py # src/ogx/providers/inline/responses/builtin/responses/openai_responses.py # tests/unit/providers/inline/responses/builtin/responses/test_tokenizer_resolution.py
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
ogx.vector_io.query_stage_duration_secondsfor retrieval stage timing.ogx.vector_io.query_result_countfor returned chunk counts.VectorStoreWithIndex.query_chunks.Why
The existing router-level retrieval duration tells us that search was slow, but not whether the regression came from embedding, backend lookup, reranking, or unexpectedly large result sets. These stage-level metrics make future RAG/search regressions easier to localize.
Review notes
This draft intentionally includes the same hot-path logging cleanup as #5972 because both changes touch
src/ogx/providers/utils/memory/vector_store.pyand the logging hook inspects that file. If #5972 lands first, this PR should shrink to the metric changes after updating.Validation
git diff --checkuv run pytest tests/unit/telemetry/test_vector_io_metrics.py tests/unit/rag/test_vector_store.py -q, but directuv rundid not start because the shelluvis0.5.29and the repo requires>=0.7.0.