-
Notifications
You must be signed in to change notification settings - Fork 475
Description
When initializing WhisperKit with a WhisperKitConfig, the useBackgroundDownloadSession argument is not correctly passed to the HubAPI downloader. This prevents the use of a background URLSession for model downloads during the initialization process. The issue appears to stem from the WhisperKit convenience initializer, which doesn't seem to propagate the useBackgroundDownloadSession setting to the underlying downloader.
Steps to Reproduce
- Create a
WhisperKitConfigwithuseBackgroundDownloadSessionset totrue:
let config = WhisperKitConfig(
verbose: true,
logLevel: .debug,
prewarm: true,
load: true,
download: true,
useBackgroundDownloadSession: true
)
- Initialize
WhisperKitusing this configuration:
self.whisperPipe = try await WhisperKit(config)
- Set a breakpoint in
Downloader.swiftfor theswift-transformershere: https://github.com/huggingface/swift-transformers/blob/main/Sources/Hub/Downloader.swift#L64
Expected Behavior: When useBackgroundDownloadSession is true, the code execution should enter this conditional block to configure a background URLSession:
if inBackground {
config = URLSessionConfiguration.background(withIdentifier: sessionIdentifier)
config.isDiscretionary = false
config.sessionSendsLaunchEvents = true
}
Actual Behavior: The if inBackground conditional evaluates to false, and the background URLSession configuration is skipped. The download proceeds using a standard URLSession.
Current Workaround: AFAIK, to enable background downloading, you must invoke the download() method directly on an already-initialized WhisperKit instance.