diff --git a/.gitmodules b/.gitmodules index 454b7945..297ce922 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "_repos/verl"] path = _repos/verl url = https://github.com/volcengine/verl.git + branch = main [submodule "_repos/LLaMA-Factory"] path = _repos/LLaMA-Factory url = https://github.com/the-seeds/LLaMA-Factory-Doc.git diff --git a/Makefile b/Makefile index 3495e930..28f828c1 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ ONNXRUNTIME_CANN_MD_LOCAL := sources/_generated/sources/onnxruntime/quick_start. help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile copy-docs clean-submodules fetch-config sync-onnxruntime-doc +.PHONY: help Makefile copy-docs clean-submodules fetch-config sync-onnxruntime-doc init-submodules # Fetch ascend config (always run to ensure freshness) .PHONY: $(ASCEND_CONFIG) @@ -58,13 +58,13 @@ sync-onnxruntime-doc: @rm -f "$(ONNXRUNTIME_CANN_MD_LOCAL).tmp" @echo "Synced to $(ONNXRUNTIME_CANN_MD_LOCAL)" -# Initialize submodules if not exists (use pinned commits for reproducibility) -_repos/verl _repos/VeOmni _repos/LLaMA-Factory _repos/ms-swift: - @echo "Initializing submodules..." - @git submodule update --init +# Initialize submodules (always run to handle empty dirs left by git clone) +init-submodules: + @git submodule sync --recursive + @git submodule update --init --remote # Copy documentation from submodules -copy-docs: _repos/verl _repos/VeOmni _repos/LLaMA-Factory _repos/ms-swift +copy-docs: init-submodules @echo "Preparing generated docs directory..." @mkdir -p $(GENERATED_DOCS) diff --git a/_repos/verl b/_repos/verl index 07d40332..77476af8 160000 --- a/_repos/verl +++ b/_repos/verl @@ -1 +1 @@ -Subproject commit 07d403321fb32aedb0b8eff6e23ecfabed559174 +Subproject commit 77476af84cc074edf5a6437f8d5ea418d7a54916 diff --git a/_static/custom.css b/_static/custom.css index b3b2e0c9..3847cc5e 100644 --- a/_static/custom.css +++ b/_static/custom.css @@ -362,4 +362,34 @@ body.onnxruntime-quickstart-page .rst-content .highlight { } -/* card-icon 样式已移至 index.rst 中统一管理 */ \ No newline at end of file +/* ========================================================= + 独立社区侧边栏专属样式 + ========================================================= */ + +#independent-sidebar .custom-sidebar-caption { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; + font-size: 85%; + color: #0066cc; + font-weight: 700; + text-transform: uppercase; + margin-top: 1.5em; + margin-bottom: 0.5em; + padding-left: 15px; + letter-spacing: 0.5px; +} + +#independent-sidebar ul { + margin-bottom: 0 !important; +} + +/* 覆盖菜单基础项的 padding,使其靠左贴齐 */ +#independent-sidebar ul li.toctree-l1 > a { + padding-left: 15px !important; +} + +#independent-sidebar ul li.toctree-l1.current > a { + background: #e6f0fa; /* 当前选中项高亮背景色 */ + color: #0066cc; + border-left: 4px solid #0066cc; + padding-left: 11px !important; /* 减去边框宽度保持对齐 */ +} diff --git a/_templates/layout.html b/_templates/layout.html new file mode 100644 index 00000000..b470b03c --- /dev/null +++ b/_templates/layout.html @@ -0,0 +1,118 @@ +{% extends "!layout.html" %} + +{% block menu %} +{% if is_independent %} + + + + +
+ + +{% else %} + + {{ super() }} +{% endif %} +{% endblock %} \ No newline at end of file diff --git a/conf.py b/conf.py index 3b0a4410..43d6968d 100644 --- a/conf.py +++ b/conf.py @@ -30,14 +30,32 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'recommonmark', 'sphinx.ext.autodoc', 'sphinxext.remoteliteralinclude', 'sphinx_copybutton', 'sphinx_markdown_tables', "sphinx_design", + 'myst_parser', ] +# 这一行非常重要,它允许 MyST 处理复杂的标题层级 +myst_heading_anchors = 3 + +# 允许在 RST 中嵌入 Markdown 内容 +myst_enable_extensions = [ + "colon_fence", + "html_image", +] + +# conf.py +html_theme_options = { + # 仅显示当前页面所属的导航树,不显示全局无关节点 + 'collapse_navigation': True, + 'navigation_depth': 4, + 'includehidden': True, + 'titles_only': False, +} + # 模板路径设置 templates_path = ['_templates'] autosummary_generate = True @@ -180,6 +198,53 @@ def generate_api_doc(): with open(rst_filename, 'w', encoding='utf-8') as f: f.write(rendered_content) +# ========================================================= +# 独立社区页面全局配置 (核心机制:高度可配置化) +# ========================================================= +html_context = { + 'independent_communities': { + 'verl': { + 'display_name': 'verl', + 'sidebar_mapping': { + 'quick_start': '🚀 快速入门', + 'features': '📚 特性指南', + 'profiling': '⚡ 调优指南', + 'examples': '📊 应用与调优实践', + 'faq': '🔆 故障排查(FAQ)', + 'contribution_guide': '🔧 开源开发' + } + }, + } +} + +# 【新增核心代码】:Sphinx 页面上下文注入 Hook +def update_page_context(app, pagename, templatename, context, doctree): + """ + 拦截页面渲染,判断当前路径是否属于独立社区。 + 如果是,向 Jinja 模板注入 is_independent 和对应的 comm_config 变量。 + 支持两种路径格式: + - sources/verl/... (手写页面) + - sources/_generated/sources/verl/... (从子模块拉取的页面) + """ + communities = context.get('independent_communities', {}) + context['is_independent'] = False + + for comm_id, comm_info in communities.items(): + # 匹配两种路径格式 + if pagename.startswith(f"sources/{comm_id}") or pagename.startswith(f"sources/_generated/sources/{comm_id}"): + context['is_independent'] = True + context['current_community_id'] = comm_id + context['comm_config'] = comm_info + break + +def setup(app): + app.add_css_file('custom.css') + app.add_js_file('package_info.js') + app.add_js_file('statistics.js') + + # 【新增 Hook 注册】 + app.connect('html-page-context', update_page_context) + # 在 Sphinx 构建之前调用该函数生成 API 文档 try: generate_api_doc() diff --git a/index.rst b/index.rst index 35887271..76d2d322 100644 --- a/index.rst +++ b/index.rst @@ -207,7 +207,7 @@

verl

用于 LLM 的强化学习训练库,适配昇腾并行计算方案。

- +
diff --git a/requirements.txt b/requirements.txt index 9c9aba78..e0c39870 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ sphinx_markdown_tables sphinx-design torch==2.5.1+cpu; platform_machine == "x86_64" torch==2.5.1; platform_machine == "aarch64" -torch_npu==2.5.1rc1; sys_platform == "linux" +torch_npu==2.5.1rc1;sys_platform == "linux" +myst_parser \ No newline at end of file diff --git a/sources/verl/index.rst b/sources/verl/index.rst index 10a73b06..ecd91308 100644 --- a/sources/verl/index.rst +++ b/sources/verl/index.rst @@ -1,12 +1,184 @@ verl -============ +============================================ + +.. raw:: html + + + +
+ +
+

🚀 verl

+

灵活、高效的大语言模型强化学习训练框架

+ +
+ + +

🚀 快速开始

+
+ +
📚
+

快速入门

+

昇腾环境搭建与基础训练示例

+
+ +
🔧
+

特性指南

+

昇腾后端特性与一致性说明

+
+ +
⚙️
+

应用实践

+

性能分析与最佳实践案例

+
+ +
👨‍💻
+

开源开发

+

CI 流程与贡献指南

+
+
+ + +
+

✨ 核心特性

+
+
🧬 多样化 RL 算法
+
🔗 无缝框架集成
+
📊 灵活设备映射
+
业界领先吞吐量
+
🤗 HuggingFace 集成
+
🎯 昇腾 NPU 支持
+
+
+
+ +---- + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: 🚀 快速入门 + + ../_generated/sources/verl/quick_start/ascend_quick_start + ../_generated/sources/verl/quick_start/ascend_sglang_quick_start + ../_generated/sources/verl/quick_start/dockerfile_build_guidance + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: 📚 特性指南 + + ../_generated/sources/verl/features/ascend_backend_features + ../_generated/sources/verl/features/ascend_consistency + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: ⚡ 调优指南 + + ../_generated/sources/verl/profiling/ascend_profiling_zh + ../_generated/sources/verl/profiling/ascend_profiling_en + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: 📊 应用与调优践实 + + ../_generated/sources/verl/examples/ascend_performance_analysis_guide + ../_generated/sources/verl/examples/ascend_sglang_best_practices + ../_generated/sources/verl/examples/dapo_multi_model_optimization_practice + ../_generated/sources/verl/examples/ascend_retool_best_pratice + ../_generated/sources/verl/examples/run_qwen3_32B_megatron_1k_256k_npu + ../_generated/sources/verl/examples/gspo_optimization_practice + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: 🔆 故障排查(FAQ) + + ../_generated/sources/verl/faq/faq .. toctree:: - :maxdepth: 3 + :maxdepth: 2 + :hidden: + :caption: 🔧 开源开发 - ../_generated/sources/verl/ascend_quick_start - ../_generated/sources/verl/ascend_sglang_quick_start - ../_generated/sources/verl/dockerfile_build_guidance - ../_generated/sources/verl/ascend_profiling_en - ../_generated/sources/verl/ascend_profiling_zh - ../_generated/sources/verl/ascend_consistency + ../_generated/sources/verl/contribution_guide/ascend_ci_guide_zh