Skip to content

Commit

Permalink
revert NO-FAIR-CARD
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuan Tran committed Dec 11, 2023
1 parent 7248b37 commit 968d351
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
41 changes: 34 additions & 7 deletions doc/reference/asset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,44 @@ fairseq2.asset

``fairseq2.asset`` provides API to load the different model using the "model cards" from different "stores".

A model card is a .YAML file that contains information about a model and instructs a
:py:class:`fairseq2.models.utils.generic_loaders.ModelLoader` on how to load the model into the memory.
A store is a place where all the model cards are stored. By default, fairseq2 will look up the following stores:

.. autosummary::
:toctree: generated/data

AssetStore
AssetCard

Model store
~~~~~~~~~~~

A store is a place where all the model cards are stored. In fairseq2, a store is accessed via
`fairseq2.assets.AssetStore`. Multiple stores are allowed. By default, fairseq2 will look up the following stores:

* System asset store: Cards that are shared by all users. By default, the system store is `/etc/fairseq2/assets`,
but this can be changed via the environment variable `FAIRSEQ2_ASSET_DIR`

* User asset store: Cards that are only available to the user. By default, the user store is
`~/.config/fairseq2/assets`, but this can be changed via the environment variable `FAIRSEQ2_USER_ASSET_DIR`

* (Internal only) Meta asset store: For Meta employees' convenience, we set up a central store that contains
model cards with e.g intermediate checkpoints, extra internal information etc. This store is registered automatically
when one logs into the Fair cluster. If you wish not to use this central store, set the environment variable
`NO_FAIR_CARD=ON`
To register a new store, implement a :py:class:`fairseq2.assets.AssetMetadataProvider` and add them to
:py:class:`fairseq2.assets.asset_store`. Here is an example to register a new directory as a model store:

from pathlib import Path
from fairseq2.assets import FileAssetMetadataProvider, asset_store

my_dir = Path("/path/to/model_store")
asset_store.metadata_providers.append(FileAssetMetadataProvider(my_dir))


Model store
~~~~~~~~~~~

A model card is a .YAML file that contains information about a model and instructs a
:py:class:`fairseq2.models.utils.generic_loaders.ModelLoader` on how to load the model into the memory. Each model card
must have 2 mandatory attributes: `name` and `checkpoint`. `name` will be used to identify the model card, and it must
be unique _across_ all
fairseq2 provides example cards for differen LLMs in
`fairseq2.assets.cards`.

In fairseq2, a model card is accessed via :py:class:`fairseq2.assets.AssetCard`. Alternatively, one can call
:py:method:`fairseq2.assets.AssetMetadataProvider.get_metadata(name: str)` to get the meta data of a given model card name.
4 changes: 0 additions & 4 deletions src/fairseq2/assets/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,6 @@ def _load_faircluster() -> None:
if "FAIR_ENV_CLUSTER" not in os.environ:
return

# Disable the central Fair model store i.e. for debugging
if os.getenv("NO_FAIR_CARD", None):
return

asset_store.env_resolvers.append(lambda: "faircluster")

# This directory is meant to store cluster-wide asset cards.
Expand Down

0 comments on commit 968d351

Please sign in to comment.