mstar.model.omnilingual_asr.weight_loader#
Fetch and load Meta’s Omnilingual ASR CTC checkpoints, with no fairseq2.
A checkpoint is a plain {"model": state_dict, "fs2": True} pickle holding
only fp32 tensors, so torch.load(weights_only=True) reads it. Its names
already match Wav2Vec2CTC; the one conversion is the positional
convolution’s weight norm (weight_g, weight_v), folded into a plain
weight with the same torch._weight_norm op the reference’s hook runs on
every forward, in the serving dtype, as the hook does.
Functions
|
Checkpoint names -> |
|
The artifact's cached path, downloading it first if needed, verified against its pinned sha256 either way. |
|
|
|
Install |
|
The checkpoint's state dict, memory-mapped (nothing is read until used). |
|
A local |
|
A local |
|
|
|
Raise unless |
- mstar.model.omnilingual_asr.weight_loader.convert_state_dict(state, dtype, device='cpu')[source]#
Checkpoint names ->
Wav2Vec2CTCnames and tensors indtypeondevice, with the positional conv’s weight norm folded.
- mstar.model.omnilingual_asr.weight_loader.fetch_cdn(artifact, cache_dir)[source]#
The artifact’s cached path, downloading it first if needed, verified against its pinned sha256 either way.
download_url_to_filewrites to a temporary file and renames it only once the hash matches.
- mstar.model.omnilingual_asr.weight_loader.fetch_hub(repo_id, filename, revision, sha256, cache_dir)[source]#
- mstar.model.omnilingual_asr.weight_loader.load_into(model, state)[source]#
Install
stateasmodel’s parameters (the model may be on the meta device: the tensors are assigned, not copied). Every parameter must be covered and every tensor used, with matching shapes.
- mstar.model.omnilingual_asr.weight_loader.read_checkpoint(path)[source]#
The checkpoint’s state dict, memory-mapped (nothing is read until used).
- mstar.model.omnilingual_asr.weight_loader.resolve_checkpoint(size, version, cache_dir, checkpoint_path=None)[source]#
A local
checkpoint_pathis used as given; the shipped checkpoints are verified.
- mstar.model.omnilingual_asr.weight_loader.resolve_tokenizer(version, cache_dir, tokenizer_path=None)[source]#
A local
tokenizer_pathis used as given; the shipped tokenizers are verified.
- mstar.model.omnilingual_asr.weight_loader.verify_sha256(path, expected, cache_dir)[source]#
Raise unless
pathhashes toexpected. The hash of a multi-GB checkpoint takes a while, so a match is remembered in a marker keyed by the hash and the file’s inode, size and times; a rewritten or replaced file is hashed again.