xai-org/x-algorithm · error · ValueError

AOT cache directory must be provided.

Error message

AOT cache directory must be provided.

What it means

compile_or_load_all_traced requires an AOT cache directory; passing an empty/None aot_cache_dir raises immediately. The cache dir is where compiled executables and metadata are stored for reuse across runs.

Source

Thrown at phoenix/xrex/utils/aot.py:465

            try:
                os.remove(lock_file)
            except Exception:
                pass


def compile_or_load_all_traced(
    all_traced: Dict[str, TracedWithOptions],
    aot_cache_dir: str | Path,
    fdo_profile_dir: Optional[str] = None,
    run_dir: Optional[str] = None,
    aot_dump: bool = False,
    devices: Sequence[xc.Device] | None = None,
) -> tuple[Dict[str, Compiled], Dict[str, Dict[str, float]]]:
    if devices is None:
        devices = []

    if not aot_cache_dir:
        raise ValueError("AOT cache directory must be provided.")

    aot_cache_dir = Path(aot_cache_dir)
    rank = jax.process_index()
    dump_hlo_dir = Path(run_dir) / "hlos" if run_dir else Path(f"/tmp/hlos/{jax.process_index()}")

    if len(devices) == 0:
        devices = get_backend().devices()
    elif isinstance(devices, np.ndarray):
        devices = devices.flatten()
    assert isinstance(devices[0], xc.Device), (
        f"compile_or_load_all_traced only accepts a list of devices but got: {devices}"
    )

    if rank == 0:
        aot_cache_dir.mkdir(parents=True, exist_ok=True)

    def _compile_or_load(name, traced_with_options, metrics: Dict[str, Dict[str, float]]):
        profile = read_fdo_profile(name, fdo_profile_dir)

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Pass an explicit aot_cache_dir path, e.g. /path/to/aot_cache or run_dir/'aot_cache'
  2. Set the config field / env var that feeds aot_cache_dir
  3. Create the directory beforehand if the caller expects it to exist

Example fix

# before
compiled, meta = compile_or_load_all_traced(traced_fns, aot_cache_dir=None)
# after
compiled, meta = compile_or_load_all_traced(traced_fns, aot_cache_dir=str(run_dir / 'aot_cache'))
Defensive patterns

Strategy: validation

Validate before calling

assert aot_cache_dir, 'aot_cache_dir required for AOT compilation'
aot_cache_dir = aot_cache_dir or str(Path(run_dir) / 'aot_cache')

Prevention

When it happens

Trigger: Calling compile_or_load / compile_or_load_all_traced without setting aot_cache_dir, or with aot_cache_dir='' after a config default fell through to None.

Common situations: Forgetting the cache dir argument when wiring up AOT compilation; configs where the cache dir env var is unset so it resolves to empty.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/587665e4d87696b6. Report an issue: GitHub.