Skip to content

Commit 25d8a7a

Browse files
authored
Make tutorials available on the site (#420)
1 parent 839664c commit 25d8a7a

File tree

8 files changed

+99
-25
lines changed

8 files changed

+99
-25
lines changed

docs/Tutorials/ReadMe.MD

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/source/_static/logo-icon.svg

Lines changed: 12 additions & 0 deletions
Loading

docs/source/conf.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def get_version_path():
6565
"sphinx_gallery.gen_gallery",
6666
]
6767

68+
html_favicon = "_static/logo-icon.svg"
69+
6870
html_baseurl = (
6971
f"https://meta-pytorch.org/forge/{version_path}" # needed for sphinx-sitemap
7072
)
@@ -82,8 +84,14 @@ def get_version_path():
8284
"_templates",
8385
os.path.join(os.path.dirname(pytorch_sphinx_theme2.__file__), "templates"),
8486
]
85-
exclude_patterns = ["tutorials/index.rst", "tutorials/template_tutorial.rst"]
8687

88+
exclude_patterns = [
89+
"tutorials/index.rst",
90+
"tutorials/template_tutorial.rst",
91+
"tutorials/**/index.rst",
92+
"tutorial_sources/**/*.md", # Exclude all markdown files from tutorial_sources
93+
"tutorial_sources/**/*.MD", # Also exclude uppercase .MD files
94+
]
8795
html_static_path = ["_static"]
8896
html_css_files = ["custom.css"]
8997
html_js_files = ["custom.js"]
@@ -167,6 +175,9 @@ def get_version_path():
167175
"html_image",
168176
]
169177

178+
# Configure MyST parser to treat mermaid code blocks as mermaid directives
179+
myst_fence_as_directive = ["mermaid"]
180+
170181
autodoc_default_options = {
171182
"members": True,
172183
"undoc-members": True,
@@ -204,14 +215,15 @@ def get_version_path():
204215
sphinx_gallery_conf = {
205216
"examples_dirs": "tutorial_sources", # Path to examples directory
206217
"gallery_dirs": "tutorials", # Path to generate gallery
207-
"filename_pattern": ".*", # Include all files
218+
"filename_pattern": r".*\.py$", # Only process .py files, not .md files
208219
"download_all_examples": False,
209220
"first_notebook_cell": "%matplotlib inline",
210221
"plot_gallery": "True",
211222
"promote_jupyter_magic": True,
212223
"backreferences_dir": None,
213224
"show_signature": False,
214225
"write_computation_times": False,
226+
"ignore_pattern": r".*\.md$|.*\.MD$", # Explicitly ignore markdown files
215227
}
216228

217229

@@ -222,5 +234,42 @@ def clean_docstring_indentation(app, what, name, obj, options, lines):
222234
lines.append("")
223235

224236

237+
def copy_markdown_tutorials(app):
238+
"""Copy markdown files from tutorial_sources to tutorials directory.
239+
240+
This runs after the builder is initialized but before sphinx-gallery processes files,
241+
ensuring markdown files are available alongside generated .py tutorials.
242+
"""
243+
import shutil
244+
from pathlib import Path
245+
246+
source_dir = Path(app.srcdir) / "tutorial_sources"
247+
target_dir = Path(app.srcdir) / "tutorials"
248+
249+
# Ensure target directory exists
250+
target_dir.mkdir(parents=True, exist_ok=True)
251+
252+
# Walk through tutorial_sources and copy all .md files
253+
for md_file in source_dir.rglob("*.md"):
254+
# Skip README files
255+
if md_file.name.lower() in ["readme.md", "readme.txt"]:
256+
continue
257+
258+
# Calculate relative path from tutorial_sources
259+
rel_path = md_file.relative_to(source_dir)
260+
261+
# Create target path in tutorials directory
262+
target_path = target_dir / rel_path
263+
target_path.parent.mkdir(parents=True, exist_ok=True)
264+
265+
# Copy the file
266+
shutil.copy2(md_file, target_path)
267+
print(
268+
f"[Forge Docs] Copied {md_file.name} to {target_path.relative_to(app.srcdir)}"
269+
)
270+
271+
225272
def setup(app):
226273
app.connect("autodoc-process-docstring", clean_docstring_indentation)
274+
# Use builder-inited to ensure it runs before source files are read
275+
app.connect("builder-inited", copy_markdown_tutorials)

docs/Tutorials/1_RL_and_Forge_Fundamentals.MD renamed to docs/source/tutorial_sources/zero-to-forge/1_RL_and_Forge_Fundamentals.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Here's the key insight: **Each RL component becomes a Forge service**. The toy e
7676
```mermaid
7777
graph LR
7878
subgraph Concepts["RL Concepts"]
79+
direction TB
7980
C1["Dataset"]
8081
C2["Policy"]
8182
C3["Reward Model"]
@@ -85,6 +86,7 @@ graph LR
8586
end
8687
8788
subgraph Services["Forge Services (Real Classes)"]
89+
direction TB
8890
S1["DatasetActor"]
8991
S2["Policy"]
9092
S3["RewardActor"]
@@ -392,4 +394,4 @@ score = await reward_actor.evaluate_response.route(
392394

393395
This is fundamentally different from monolithic RL implementations where any component failure stops everything!
394396

395-
In the next Section, we will go a layer deeper and learn how ForgeServices work. Continue to [Part 2 here](./2_Forge_Internals.MD)
397+
In the next Section, we will go a layer deeper and learn how ForgeServices work. Continue to [Part 2 here](./2_Forge_Internals.md)

docs/Tutorials/2_Forge_Internals.MD renamed to docs/source/tutorial_sources/zero-to-forge/2_Forge_Internals.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Part 2: Peeling Back the Abstraction - What Are Services?
22

3-
We highly recommend reading [Part 1](./1_RL_and_Forge_Fundamentals.MD) before this, it explains RL Concepts and how they land in Forge.
3+
We highly recommend reading [Part 1](./1_RL_and_Forge_Fundamentals) before this, it explains RL Concepts and how they land in Forge.
44

55
Now that you see the power of the service abstraction, let's understand what's actually happening under the hood, Grab your chai!
66

@@ -668,4 +668,4 @@ print("All services shut down successfully!")
668668

669669
This is the power of the service abstraction - complex distributed coordination looks like simple async Python code.
670670

671-
In the next part we will learn about [Monarch internals](./3_Monarch_101.MD)
671+
In the next part we will learn about [Monarch internals](./3_Monarch_101.md)

docs/Tutorials/3_Monarch_101.MD renamed to docs/source/tutorial_sources/zero-to-forge/3_Monarch_101.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Part 3: The Forge-Monarch Connection
22

3-
This is part 3 of our series, in the previous sections: we learned Part 1: [RL Concepts and how they map to Forge](./1_RL_and_Forge_Fundamentals.MD), Part 2: [Forge Internals](./2_Forge_Internals.MD).
3+
This is part 3 of our series, in the previous sections: we learned Part 1: [RL Concepts and how they map to Forge](./1_RL_and_Forge_Fundamentals), Part 2: [Forge Internals](./2_Forge_Internals).
44

55
Now let's peel back the layers. Forge services are built on top of **Monarch**, PyTorch's distributed actor framework. Understanding this connection is crucial for optimization and debugging.
66

docs/source/tutorials.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
```{toctree}
77
:maxdepth: 1
88
9+
zero-to-forge-intro
910
```

docs/source/zero-to-forge-intro.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Zero to Forge: From RL Theory to Production-Scale Implementation
2+
3+
A comprehensive guide for ML Engineers building distributed RL systems for language models.
4+
5+
Some of the examples mentioned below will be conceptual in nature for understanding.
6+
Please refer to [API Docs](./api) for more details.
7+
8+
Welcome to the Tutorials section! This section is inspired by the A-Z
9+
PyTorch tutorial, shoutout to our PyTorch friends that remember!
10+
11+
## Tutorial Structure
12+
13+
This section currently is structured in 3 detailed parts:
14+
15+
1. [RL Fundamentals and Understanding Forge Terminology](tutorials/zero-to-forge/1_RL_and_Forge_Fundamentals): This gives a quick refresher of Reinforcement Learning and teaches you Forge Fundamentals
16+
2. [Forge Internals](tutorials/zero-to-forge/2_Forge_Internals): Goes a layer deeper and explains the internals of Forge
17+
3. [Monarch 101](tutorials/zero-to-forge/3_Monarch_101): It's a 101 to Monarch and how Forge Talks to Monarch
18+
19+
Each part builds upon the next and the entire section can be consumed in roughly an hour - Grab a Chai and Enjoy!
20+
21+
If you're eager, please checkout our SFT Tutorial too (Coming soon!)!
22+
23+
```{toctree}
24+
:maxdepth: 1
25+
:hidden:
26+
tutorials/zero-to-forge/1_RL_and_Forge_Fundamentals
27+
tutorials/zero-to-forge/2_Forge_Internals
28+
tutorials/zero-to-forge/3_Monarch_101
29+
```

0 commit comments

Comments
 (0)