Skip to content

Update ascend quick install documentation with dynamic configuration#107

Merged
hipudding merged 9 commits intoAscend:mainfrom
hipudding:main
Mar 10, 2026
Merged

Update ascend quick install documentation with dynamic configuration#107
hipudding merged 9 commits intoAscend:mainfrom
hipudding:main

Conversation

@hipudding
Copy link
Collaborator

@hipudding hipudding commented Feb 25, 2026

Dynamic ascend version configuration and build fixes
Changes

  • Dynamic config: Fetch ascend version data from hiascend API during build
  • Multithreading: Optimize data fetching with worker pool (CPU core count)
  • macOS build fix: Restrict torch_npu to Linux platform only
  • Makefile optimization: Use target dependencies to skip redundant operations
image

@ascend-robot
Copy link

CLA Signature Pass

hipudding, thanks for your pull request. All authors of the commits have signed the CLA. 👍

2 similar comments
@ascend-robot
Copy link

CLA Signature Pass

hipudding, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@ascend-robot
Copy link

CLA Signature Pass

hipudding, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@hipudding hipudding marked this pull request as ready for review February 28, 2026 02:19
@hipudding hipudding requested review from fffrog and zheliuyu and removed request for zheliuyu February 28, 2026 02:19
cpu_arch_id = task['cpu_arch_id']
os_id = task['os_id']
install_methods = get_install_methods(version_id, hardware_id, cpu_arch_id, os_id)
print(f" [{threading.current_thread().name}] Found {len(install_methods)} install methods for {os_id}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meaning of this log message seems a bit unclear. I think we should either clarify what's happening here or just remove it — either is fine.

Image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been changed to a count to avoid a large number of logs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@git submodule update --init --remote

# Copy documentation from submodules
copy-docs: _repos/verl _repos/VeOmni _repos/LLaMA-Factory _repos/ms-swift
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase this part of the code so we can verify the documentation builds successfully during review.

Image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, should we also provide a jump link for "More Versions" so that users can access other CANN versions?

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Copilot AI review requested due to automatic review settings March 10, 2026 06:42
@ascend-robot
Copy link

CLA Signature Pass

hipudding, thanks for your pull request. All authors of the commits have signed the CLA. 👍

hipudding and others added 8 commits March 10, 2026 14:44
- Add fetch_ascend_data.py script to fetch latest data from hiascend.com
- Add ascend_config.json with version, product series, CPU architectures, OS, and install methods
- Refactor ascend_actions.js to load from config and dynamically generate UI
- Update quick_install.rst to use dynamic selection
- Update Makefile to fetch ascend data on each build
- Fix conf.py to handle missing torch_npu gracefully

The dynamic selection now supports:
- Version selection (8.5.0, 8.5.0.alpha002)
- Product series selection
- CPU architecture selection
- Operating system selection
- Install method selection
- Dynamic display of installation steps and commands
- Use CPU core count for worker threads instead of fixed 10
- Replace absolute output path with relative path
- Implement task queue pattern for parallel API requests
- Delete runtime-generated ascend_config.json from repo
- Fix shell syntax error in Makefile (removed stray 2. and .)
- Restrict torch_npu to Linux platform only (not available on macOS)
- Use venv for building
- Use directory targets for submodules to skip if already exists
- Make copy-docs depend on submodule directories
- Remove clean-submodules call to avoid re-initializing
- Use Make's built-in target mechanism instead of shell checks
- Add "更多版本" button linking to official download page
- Add footer with CANN documentation links
- Simplify fetch_ascend_data.py logging output
- Use dynamic version (git hash) and timestamp in config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ascend-robot
Copy link

CLA Signature Pass

hipudding, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@hipudding hipudding requested a review from zheliuyu March 10, 2026 06:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Ascend “quick install” documentation to render installation steps dynamically from a generated configuration file, and adjusts the docs build pipeline to support that generation while also improving build portability.

Changes:

  • Replaces the static Ascend quick-install content with a JS-driven selector UI backed by a generated _static/ascend_config.json.
  • Adds a Python fetch script to build the Ascend configuration from the hiascend API (with multithreaded fetching).
  • Improves build robustness/portability (Linux-only torch_npu, Makefile dependency wiring, and conf.py ImportError handling for API doc generation).

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
sources/ascend/quick_install.rst Replaces static instructions with a dynamic UI container driven by JS/config.
scripts/fetch_ascend_data.py New build-time script to fetch and serialize Ascend version/install-step data from hiascend.
requirements.txt Restricts torch_npu installation to Linux to avoid macOS build failures.
conf.py Wraps API doc generation to avoid hard failures when torch_npu isn’t importable.
_static/custom.css Adds styling for the “更多版本” link/button and related layout tweaks.
_static/ascend_actions.js Replaces static option logic with config-driven selectors and step rendering.
Makefile Adds config generation + doc-copy prerequisites and introduces submodule-related targets.
.gitignore Updates ignored generated paths (but currently mismatches the new config output path).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +272 to +278
def main():
# 版本列表(手动记录)
versions = [
{'id': '673', 'name': '9.0.0-beta.1'},
{'id': '657', 'name': '8.5.0'},
{'id': '630', 'name': '8.5.0.alpha002'}
]
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says versions are fetched dynamically from the API, but the version list here is still manually maintained. If the API has an endpoint for available versions, consider populating versions from it; otherwise, please update the PR description (or the comment) to reflect that only the per-version detail is dynamic.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no api for versions.

Comment on lines 4 to 10
跟随指导,在您的机器上快速安装昇腾环境。

1. 系统要求
----------------
1.1 前置检查
^^^^^^^^^^^^^
确认昇腾AI处理器已经安装妥当

.. code-block:: bash

lspci | grep 'Processing accelerators'

确认操作系统架构及版本

.. code-block:: bash

uname -m && cat /etc/*release

确认Python版本

.. code-block:: bash

python --version


1.2 软件要求
^^^^^^^^^^^^^
======== ========================================
软件 版本
======== ========================================
操作系统 openEuler20.03/22.03, Ubuntu 20.04/22.04
Python 3.7, 3.8, 3.9, 3.10, 3.11.4
======== ========================================


2. 环境安装
------------------
根据您的需求,选择合适的软件包版本:

.. warning::

以下文档需要使用非root用户进行安装安装

.. raw:: html

<script type="text/javascript" src="../../_static/ascend_actions.js"></script>
<div id="div-installation" style="">
<div class="row">
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page now relies entirely on JS + ascend_config.json to show any installation steps. If JS is disabled, the config is missing, or the network call fails, users will effectively get an empty guide. Consider adding a non-JS fallback (e.g., a prominent link to the official install docs and/or a noscript message) so the page remains usable when dynamic loading isn’t available.

Copilot uses AI. Check for mistakes.
Comment on lines +145 to 148
if (!steps || steps.length === 0) {
$('#install-instructions').html('<p style="color: red;">暂无安装步骤</p>');
return;
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When there are no steps, the code writes an error message then returns, but does not .show() the #install-instructions container (which starts hidden). The user will still see nothing. Show the container (and/or ensure it’s visible when displaying errors).

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +90
def api_call(url):
"""调用hiascend API"""
cmd = [
'curl', '-s',
'-H', 'referer: https://www.hiascend.com/cann/download',
'-H', 'accept: */*',
'-H', 'accept-language: zh-CN,zh;q=0.9',
'-H', 'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Mobile Safari/537.36',
url
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
return json.loads(result.stdout)
return None
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api_call() can hang indefinitely (no timeout) and will raise JSONDecodeError if the response isn’t valid JSON (e.g., transient HTML/captcha page), failing the build. Add a curl timeout (--max-time / --connect-timeout) or switch to a Python HTTP client with timeouts, and catch JSON parsing errors to return a controlled failure.

Copilot uses AI. Check for mistakes.
Makefile Outdated
Comment on lines 66 to 69
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile $(ASCEND_CONFIG) copy-docs
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) No newline at end of file
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch-all % target now depends on $(ASCEND_CONFIG) and copy-docs, so make clean (and any other sphinx-build -M targets) will fetch API data and copy submodule docs before running the requested target. Consider adding explicit build targets (html/dirhtml/etc.) with these prerequisites and keeping clean free of them.

Copilot uses AI. Check for mistakes.
Makefile Outdated
Comment on lines 39 to 41
_repos/verl _repos/VeOmni _repos/LLaMA-Factory _repos/ms-swift:
@echo "Initializing submodules..."
@git submodule update --init --remote
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git submodule update --init --remote makes builds non-reproducible because it updates submodules to the latest remote tracking commits rather than the commits pinned in this repo. If reproducible doc builds are important (especially in CI/RTD), consider removing --remote and relying on the checked-in submodule SHAs (or explicitly documenting why tracking remote heads is required).

Copilot uses AI. Check for mistakes.
Comment on lines +11 to 18
function loadConfig() {
$.getJSON('../../_static/ascend_config.json', function(data) {
config = data;
initializeUI();
}).fail(function() {
console.error('Failed to load ascend_config.json');
$('#install-instructions').html('<p style="color: red;">加载配置文件失败,请检查网络连接。</p>');
});
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config-load failure path updates #install-instructions, but that element is initially display:none in the RST, so the error message won’t be visible. Consider calling .show() (or writing into a visible container) in the .fail() handler so users aren’t left with an empty page when ascend_config.json is missing/unreachable.

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +33
var versionHtml = '<div class="mobile-headings">版本</div>';
versionKeys.forEach(function(key, index) {
var version = versions[key];
var selected = index === 0 ? 'selected' : '';
versionHtml += '<div class="values-element block-' + versionKeys.length + ' install-version ' + selected + '" id="version-' + key + '">' + version.name + '</div>';
});
return os_versions;
}
$('#row-version').html(versionHtml);
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option labels from ascend_config.json (e.g., version.name) are inserted into HTML without escaping. If the config ever contains unexpected characters/markup, this becomes an XSS vector in the rendered docs. Please HTML-escape all user/API-provided strings (version/product/os/install method names) or set text via DOM APIs instead of string concatenation.

Copilot uses AI. Check for mistakes.
Comment on lines +150 to +154
var instructionsHtml = '';
steps.forEach(function(step, index) {
instructionsHtml += '<section>';
instructionsHtml += '<h3>' + (index + 1) + '. ' + step.title + '</h3>';

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

step.title is inserted into the <h3> without escaping. Even if commands are escaped, an unescaped title can still inject markup/scripts if the upstream HTML contains unexpected content. Reuse escapeHtml() (or DOM text nodes) for titles as well.

Copilot uses AI. Check for mistakes.
Comment on lines +168 to +174
// 添加底部提示信息
instructionsHtml += '<section class="install-footer">';
instructionsHtml += '<p>若您需要详细的操作步骤请参考';
instructionsHtml += '<a href="https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/850/quickstart/instg_quick.html" target="_blank">《CANN快速开始》</a>';
instructionsHtml += '或';
instructionsHtml += '<a href="https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/850/softwareinst/instg/instg_0000.html?Mode=PmIns&InstallType=netconda&OS=openEuler" target="_blank">《CANN安装指南》</a>。';
instructionsHtml += '</p>';
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The footer links are hard-coded to CANNCommunityEdition/850, which may not match the selected version (e.g., 9.0.0-beta.1 in the config). If possible, derive these URLs from the selected version or make the link text clearly indicate it’s a fixed reference version to avoid sending users to incompatible docs.

Copilot uses AI. Check for mistakes.
- Add timeout and JSON error handling to API calls
- Use try/finally in worker to prevent deadlock on exceptions
- Cap worker threads to avoid API throttling
- Escape HTML in all UI strings to prevent XSS
- Clamp block CSS class to max 5 for layout stability
- Show error container when config load fails or no steps
- Add noscript fallback for JS-disabled browsers
- Remove --remote from submodule update for reproducible builds
- Separate build targets so clean doesn't trigger data fetch
- Auto-generate ascend_config.json in conf.py for RTD/CI builds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ascend-robot
Copy link

CLA Signature Pass

hipudding, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@hipudding hipudding merged commit a33e771 into Ascend:main Mar 10, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants