Skip to content

Commit e924d33

Browse files
authored
docs: Link uv's installation instructions to uv's website (#837)
Signed-off-by: Shang Wang <[email protected]>
1 parent bbbb3d6 commit e924d33

File tree

3 files changed

+89
-37
lines changed

3 files changed

+89
-37
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ repos:
33
rev: v4.4.0
44
hooks:
55
- id: end-of-file-fixer
6-
# only include python files
7-
files: \.py$
6+
types_or: [python, pyi] # Only include Python files.
87
- id: trailing-whitespace
9-
# only include python files
10-
files: \.py$
8+
types_or: [python, pyi] # Only include Python files.
119

1210
- repo: https://github.com/astral-sh/ruff-pre-commit
1311
rev: "v0.9.9" # Use the appropriate version
@@ -36,8 +34,15 @@ repos:
3634
exclude: '^\.github/'
3735
types: [file]
3836

39-
- repo: https://github.com/facebook/pyrefly
40-
rev: 0.24.2
37+
- repo: local
4138
hooks:
4239
- id: pyrefly-typecheck
43-
files: \.py$
40+
name: pyrefly check
41+
entry: uv run --group dev pyrefly check
42+
types_or: [python, pyi]
43+
language: system
44+
pass_filenames: false # Pyrefly reads config & project roots itself.
45+
args: []
46+
require_serial: true
47+
additional_dependencies: []
48+
minimum_pre_commit_version: "2.9.2"

README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,41 +105,37 @@ sudo apt-get update
105105
sudo apt-get install cudnn-cuda-12
106106
```
107107

108-
Install `uv`.
109-
```sh
110-
# For faster setup and environment isolation, we use `uv`
111-
pip install uv
108+
For faster setup and environment isolation, we use [uv](https://docs.astral.sh/uv/).
109+
Follow [these instructions](https://docs.astral.sh/uv/getting-started/installation/) to install uv.
112110

113-
# Initialize NeMo RL project virtual environment
114-
# NOTE: Please do not use -p/--python and instead allow uv venv to read it from .python-version
115-
# This ensures that the version of python used is always what we prescribe.
111+
Then, initialize NeMo RL project virtual environment via:
112+
```sh
116113
uv venv
114+
```
115+
> [!NOTE]
116+
> Please do not use `-p/--python` and instead allow `uv venv` to read it from `.python-version`.
117+
> This ensures that the version of python used is always what we prescribe.
117118
118-
# If working outside a container, it can help to build flash-attn and warm the
119-
# uv cache before your first run. The NeMo RL Dockerfile will warm the uv cache
120-
# with flash-attn. See https://docs.nvidia.com/nemo/rl/latest/docker.html for
121-
# instructions if you are looking for the NeMo RL container.
119+
If working outside a container, it can help to build [flash-attn](https://github.com/Dao-AILab/flash-attention) and warm the uv cache before your first run.
120+
```sh
122121
bash tools/build-flash-attn-in-uv-cache.sh
123-
# If sucessful, you should see "✅ flash-attn successfully added to uv cache"
124-
125-
# If you cannot install at the system level, you can install for your user with
126-
# pip install --user uv
127-
128-
# Use `uv run` to launch all commands. It handles pip installing implicitly and
129-
# ensures your environment is up to date with our lock file.
130-
131-
# Note that it is not recommended to activate the venv and instead use `uv run` since
132-
# it ensures consistent environment usage across different shells and sessions.
133-
# Example: uv run python examples/run_grpo_math.py
134122
```
135-
136-
**Important Notes:**
137-
138-
- Use the `uv run <command>` to execute scripts within the managed environment. This helps maintain consistency across different shells and sessions.
139-
- Ensure you have the necessary CUDA drivers and PyTorch installed compatible with your hardware.
140-
- On the first install, `flash-attn` can take a while to install (~45min with 48 CPU hyperthreads). After it is built once, it is cached in your `uv`'s cache dir making subsequent installs much quicker.
141-
- If you update your environment in `pyproject.toml`, it is necessary to force a rebuild of the virtual environments by setting `NRL_FORCE_REBUILD_VENVS=true` next time you launch a run.
142-
- **Reminder**: Don't forget to set your `HF_HOME`, `WANDB_API_KEY`, and `HF_DATASETS_CACHE` (if needed). You'll need to do a `huggingface-cli login` as well for Llama models.
123+
> [!NOTE]
124+
> On the first install, `flash-attn` can take a while to install (~45min with 48 CPU hyperthreads). After it is built once, it is cached in your uv's cache dir making subsequent installs much quicker.
125+
126+
> [!TIP]
127+
> The NeMo RL Dockerfile will warm the uv cache with flash-attn.
128+
> See https://docs.nvidia.com/nemo/rl/latest/docker.html for instructions if you are looking for the NeMo RL container.
129+
130+
If sucessful, you should see `✅ flash-attn successfully added to uv cache`.
131+
132+
Use `uv run` to launch all commands. It handles pip installing implicitly and ensures your environment is up to date with our lock file.
133+
> [!NOTE]
134+
> - It is not recommended to activate the `venv`, and you should use `uv run <command>` instead to execute scripts within the managed environment.
135+
> This ensures consistent environment usage across different shells and sessions. Example: `uv run python examples/run_grpo_math.py`
136+
> - Ensure you have the necessary CUDA drivers and PyTorch installed compatible with your hardware.
137+
> - If you update your environment in `pyproject.toml`, it is necessary to force a rebuild of the virtual environments by setting `NRL_FORCE_REBUILD_VENVS=true` next time you launch a run.
138+
> - **Reminder**: Don't forget to set your `HF_HOME`, `WANDB_API_KEY`, and `HF_DATASETS_CACHE` (if needed). You'll need to do a `huggingface-cli login` as well for Llama models.
143139
144140
## Training Backends
145141

docs/conf.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,54 @@
9898
},
9999
}
100100
html_extra_path = ["project.json", "versions1.json"]
101+
102+
# -- Supporting rendering GitHub alerts correctly ----------------------------
103+
# https://github.com/executablebooks/MyST-Parser/issues/845
104+
105+
_GITHUB_ADMONITIONS = {
106+
"> [!NOTE]": "note",
107+
"> [!TIP]": "tip",
108+
"> [!IMPORTANT]": "important",
109+
"> [!WARNING]": "warning",
110+
"> [!CAUTION]": "caution",
111+
}
112+
113+
114+
def convert_gh_admonitions(app, relative_path, parent_docname, contents):
115+
# loop through content lines, replace github admonitions
116+
for i, orig_content in enumerate(contents):
117+
orig_line_splits = orig_content.split("\n")
118+
replacing = False
119+
for j, line in enumerate(orig_line_splits):
120+
# look for admonition key
121+
line_roi = line.lstrip()
122+
for admonition_key in _GITHUB_ADMONITIONS:
123+
if line_roi.startswith(admonition_key):
124+
line = line.replace(
125+
admonition_key,
126+
"```{" + _GITHUB_ADMONITIONS[admonition_key] + "}",
127+
)
128+
# start replacing quotes in subsequent lines
129+
replacing = True
130+
break
131+
else: # no break
132+
if not replacing:
133+
continue
134+
# remove GH directive to match MyST directive
135+
# since we are replacing on the original line, this will preserve the right indent, if any
136+
if line_roi.startswith("> "):
137+
line = line.replace("> ", "", 1)
138+
elif line_roi.rstrip() == ">":
139+
line = line.replace(">", "", 1)
140+
else:
141+
# missing "> ", so stop replacing and terminate directive
142+
line = f"```\n{line}"
143+
replacing = False
144+
# swap line back in splits
145+
orig_line_splits[j] = line
146+
# swap line back in original
147+
contents[i] = "\n".join(orig_line_splits)
148+
149+
150+
def setup(app):
151+
app.connect("include-read", convert_gh_admonitions)

0 commit comments

Comments
 (0)