Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Facebookresearch Audiocraft Resolve checkpoint path

From Leeroopedia
Revision as of 12:33, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Facebookresearch_Audiocraft_Resolve_checkpoint_path.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

Resolve_checkpoint_path resolves a Dora experiment signature or direct filesystem path to a concrete checkpoint file path. This is the entry point for any model export workflow, converting human-friendly experiment identifiers into loadable checkpoint locations.

Implements

Principle:Facebookresearch_Audiocraft_Training_Checkpoint_Resolution

API Signature

def resolve_checkpoint_path(
    sig_or_path: Union[Path, str],
    name: Optional[str] = None,
    use_fsdp: bool = False
) -> Optional[Path]

Source: audiocraft/utils/checkpoint.py, lines 56-84

Import:

from audiocraft.utils.checkpoint import resolve_checkpoint_path

Parameters

Parameter Type Default Description
sig_or_path Union[Path, str] required Dora experiment signature (with //sig/ prefix) or direct filesystem path to a checkpoint file or directory
name Optional[str] None Checkpoint name suffix (e.g., "best" for checkpoint_best.th). When None, resolves to the latest checkpoint (checkpoint.th)
use_fsdp bool False Whether to append FSDP rank suffix to the checkpoint filename for distributed training checkpoints

Return Value

Returns an Optional[Path]: the resolved checkpoint path if the file exists, or None if no checkpoint was found at the resolved location.

Dependencies

  • audiocraft.train -- accessed to retrieve the Dora experiment root directory via train.main.dora.dir
  • audiocraft.environment.AudioCraftEnvironment -- used for reference path resolution when given a direct path
  • flashy -- used indirectly through checkpoint_name() for distributed rank detection

How It Works

from audiocraft.utils.checkpoint import resolve_checkpoint_path

# Resolve from a Dora experiment signature
path = resolve_checkpoint_path('//sig/abc123de', name='best')
# Resolves to: <dora_dir>/xps/abc123de/checkpoint_best.th

# Resolve from a direct filesystem path
path = resolve_checkpoint_path('/path/to/my/training/run', name='best')
# Resolves to: /path/to/my/training/run/checkpoint_best.th

# For FSDP checkpoint on rank 1
path = resolve_checkpoint_path('//sig/abc123de', name='best', use_fsdp=True)
# Resolves to: <dora_dir>/xps/abc123de/checkpoint_best.th.1 (on rank 1)

The implementation logic:

def resolve_checkpoint_path(sig_or_path, name=None, use_fsdp=False):
    from audiocraft import train
    xps_root = train.main.dora.dir / 'xps'
    sig_or_path = str(sig_or_path)
    if sig_or_path.startswith('//sig/'):
        sig = sig_or_path[len('//sig/'):]
        path = xps_root / sig
    else:
        path = Path(sig_or_path)
        path = AudioCraftEnvironment.resolve_reference_path(path)

    if path.is_dir():
        path = path / checkpoint_name(name, use_fsdp=use_fsdp)

    if path.exists():
        return path
    else:
        return None

Supporting Function: get_solver_from_sig

For loading a full solver (with model, optimizer, etc.) from a signature:

def get_solver_from_sig(sig: str, *args, **kwargs):
    """Return Solver object from Dora signature."""
    xp = main.get_xp_from_sig(sig)
    return get_solver_from_xp(xp, *args, **kwargs)

Source: audiocraft/train.py, lines 97-102

Related Implementations

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment