Skip to content

Commit 12c48ac

Browse files
committed
Clarify parallelism in comments
1 parent 58dbb8e commit 12c48ac

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Libraries/Embedders/EmbeddingModel.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public actor ModelContainer {
4646
public init(
4747
hub: HubApi, modelDirectory: URL, configuration: ModelConfiguration
4848
) async throws {
49-
// Start tokenizer config loading asynchronously, then load model synchronously.
50-
// Both operations run in parallel because async let begins execution immediately.
49+
// Load tokenizer config and model in parallel using async let.
5150
async let tokenizerConfigTask = loadTokenizerConfig(
5251
configuration: configuration, hub: hub)
5352

Libraries/Embedders/Load.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ public func load(
9090
let modelDirectory = try await prepareModelDirectory(
9191
hub: hub, configuration: configuration, progressHandler: progressHandler)
9292

93-
// Start tokenizer loading asynchronously, then load model synchronously.
94-
// Both operations run in parallel because async let begins execution immediately.
93+
// Load tokenizer and model in parallel using async let.
9594
async let tokenizerTask = loadTokenizer(configuration: configuration, hub: hub)
9695
let model = try loadSynchronous(modelDirectory: modelDirectory, modelName: configuration.name)
9796
let tokenizer = try await tokenizerTask

Libraries/MLXLLM/LLMModelFactory.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ public final class LLMModelFactory: ModelFactory {
503503
configurationURL.lastPathComponent, configuration.name, error)
504504
}
505505

506-
// Start tokenizer loading asynchronously, then load weights synchronously.
507-
// Both operations run in parallel because async let begins execution immediately.
506+
// Load tokenizer and weights in parallel using async let.
508507
async let tokenizerTask = loadTokenizer(configuration: configuration, hub: hub)
509508

510509
try loadWeights(

Libraries/MLXVLM/VLMModelFactory.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ public final class VLMModelFactory: ModelFactory {
282282
configurationURL.lastPathComponent, configuration.name, error)
283283
}
284284

285-
// Start tokenizer and processor config loading asynchronously, then load weights synchronously.
286-
// All three operations run in parallel because async let begins execution immediately.
285+
// Load tokenizer, processor config, and weights in parallel using async let.
286+
// Note: loadProcessorConfig does synchronous I/O but is marked async to enable
287+
// parallel scheduling. This may briefly block a cooperative thread pool thread,
288+
// but the config file is small and model loading is not a high-concurrency path.
287289
async let tokenizerTask = loadTokenizer(configuration: configuration, hub: hub)
288290
async let processorConfigTask = loadProcessorConfig(from: modelDirectory)
289291

@@ -331,6 +333,7 @@ private struct ProcessorConfigError: Error {
331333
}
332334

333335
/// Loads processor configuration, preferring preprocessor_config.json over processor_config.json.
336+
/// Marked async to enable parallel scheduling via async let, though the underlying I/O is synchronous.
334337
/// Throws ProcessorConfigError wrapping any underlying error with the filename.
335338
private func loadProcessorConfig(from modelDirectory: URL) async throws -> (
336339
Data, BaseProcessorConfiguration

0 commit comments

Comments
 (0)