Skip to content

Commit 4b6a891

Browse files
satraclaude
andauthored
Cache pipeline by model+device only, not call-time params (#499)
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>
1 parent ae773d5 commit 4b6a891

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/senselab/audio/tasks/classification/huggingface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ def _get_hf_audio_classification_pipeline(
4444
device, _ = _select_device_and_dtype(
4545
user_preference=device, compatible_devices=[DeviceType.CUDA, DeviceType.CPU]
4646
)
47-
key = f"{model.path_or_uri}-{model.revision}-{top_k}-{function_to_apply}-{device.value}"
47+
# Cache by model identity + device only. top_k, function_to_apply,
48+
# and batch_size are call-time parameters passed at pipe() invocation.
49+
key = f"{model.path_or_uri}-{model.revision}-{device.value}"
4850
if key not in cls._pipelines:
4951
cls._pipelines[key] = cast(
5052
Pipeline,
5153
pipeline( # type: ignore[call-overload]
5254
task="audio-classification",
5355
model=model.path_or_uri,
5456
revision=model.revision,
55-
top_k=top_k,
56-
function_to_apply=function_to_apply,
5757
device=device.value,
5858
),
5959
)

0 commit comments

Comments
 (0)