Skip to content

Cache pipeline by model+device only#499

Merged
satra merged 1 commit into
alphafrom
fix/pipeline-cache-key
Apr 30, 2026
Merged

Cache pipeline by model+device only#499
satra merged 1 commit into
alphafrom
fix/pipeline-cache-key

Conversation

@satra

@satra satra commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

top_k/function_to_apply/batch_size are call-time params, not pipeline config. Single pipeline reused regardless.

top_k, function_to_apply, and batch_size are call-time parameters
passed at pipe() invocation, not pipeline construction config.
Including them in the cache key created duplicate pipeline instances
in memory for each unique parameter combination.

Now a single pipeline is reused regardless of top_k/function_to_apply
values — these are passed per-call at inference time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Hugging Face audio classification pipeline caching mechanism to use only the model identity and device as the cache key, treating parameters like top_k and function_to_apply as call-time arguments. Feedback highlights that top_k, function_to_apply, and batch_size are now unused in the method signature and that batch_size is currently ignored in the pipeline invocation, suggesting a cleanup and fix.

Comment on lines +47 to +49
# Cache by model identity + device only. top_k, function_to_apply,
# and batch_size are call-time parameters passed at pipe() invocation.
key = f"{model.path_or_uri}-{model.revision}-{device.value}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The comment states that batch_size is a call-time parameter passed at pipe() invocation. However, in classify_audios_with_transformers (line 149), batch_size is not actually passed to the pipeline call, meaning the batch_size argument is currently ignored. Additionally, since top_k, function_to_apply, and batch_size are no longer used to construct the cache key or initialize the pipeline, they are now unused parameters in this method. Consider removing them from the signature of _get_hf_audio_classification_pipeline and updating the caller at line 108.

@satra
satra merged commit 4b6a891 into alpha Apr 30, 2026
10 checks passed
@satra
satra deleted the fix/pipeline-cache-key branch April 30, 2026 18:55
github-actions Bot added a commit that referenced this pull request Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant