bark_coreml.py recompiles the .mlpackage on every run (5-6 minutes each time)

#2
by lucharo - opened

coreml/ane/bark_coreml.py loads BarkEncoder.mlpackage with ct.models.MLModel(...). coremltools compiles the package to a temporary .mlmodelc on every load and discards it afterwards, so every new process pays the compile again. That took 5 to 6 minutes per run on an M4 Pro Mac.

Compiling once with xcrun coremlcompiler compile BarkEncoder.mlpackage . (77 s for the Pro package) and loading the result through ct.models.CompiledMLModel brings later loads down to about 3 seconds. The script could cache the compiled model next to the package, using MLModel.get_compiled_model_path() and then CompiledMLModel on later runs, or the repo could ship the compiled .mlmodelc. Keeping one Transcriber alive, as the card suggests, only helps within a single process.

Sign up or log in to comment