已合并
refactor: rename torchao_npu to torchao_ascend repo-wide(统一仓名 torchao-ascend 命名) #140
wanglijun55创建于 9 天前
refactor: rename torchao_npu to torchao_ascend repo-wide(统一仓名 torchao-ascend 命名) #140
已合并
共 169 个文件变更+600-600
| @@ -22,22 +22,22 @@ ignore = | |||
| 22 | SIM102,SIM103,SIM106,SIM112 | 22 | SIM102,SIM103,SIM106,SIM112 |
| 23 | per-file-ignores = | 23 | per-file-ignores = |
| 24 | __init__.py: F401 | 24 | __init__.py: F401 |
| 25 | - # tests import torch_npu / torchao_npu for their side effects | 25 | + # tests import torch_npu / torchao_ascend for their side effects |
| 26 | # (device registration and patch installation) | 26 | # (device registration and patch installation) |
| 27 | test/**: F401,F821 | 27 | test/**: F401,F821 |
| 28 | test/**/__init__.py: F401,F821 | 28 | test/**/__init__.py: F401,F821 |
| 29 | - torchao_npu/__init__.py: F401 | 29 | + torchao_ascend/__init__.py: F401 |
| 30 | optional-ascii-coding = True | 30 | optional-ascii-coding = True |
| 31 | exclude = | 31 | exclude = |
| 32 | ./.git, | 32 | ./.git, |
| 33 | ./build, | 33 | ./build, |
| 34 | ./dist, | 34 | ./dist, |
| 35 | # vendored/patched copies kept in sync with upstream torchao | 35 | # vendored/patched copies kept in sync with upstream torchao |
| 36 | - ./torchao_npu/patches/torchao, | 36 | + ./torchao_ascend/patches/torchao, |
| 37 | ./docs, | 37 | ./docs, |
| 38 | ./examples, | 38 | ./examples, |
| 39 | ./*.egg-info, | 39 | ./*.egg-info, |
| 40 | ./venv, | 40 | ./venv, |
| 41 | ./test/__pycache__, | 41 | ./test/__pycache__, |
| 42 | - ./torchao_npu/__pycache__, | 42 | + ./torchao_ascend/__pycache__, |
| 43 | *.pyi | 43 | *.pyi |
| @@ -1,5 +1,5 @@ | |||
| 1 | # ============================================================================== | 1 | # ============================================================================== |
| 2 | -# case_paths_ci.yml — torchao_npu 测试用例文件级白名单/黑名单 | 2 | +# case_paths_ci.yml — torchao_ascend 测试用例文件级白名单/黑名单 |
| 3 | # ============================================================================== | 3 | # ============================================================================== |
| 4 | # 用途: | 4 | # 用途: |
| 5 | # - 控制 collect stage 中哪些 test_*.py 文件参与用例采集 | 5 | # - 控制 collect stage 中哪些 test_*.py 文件参与用例采集 |
| @@ -11,7 +11,7 @@ | |||
| 11 | # | 11 | # |
| 12 | # 说明: | 12 | # 说明: |
| 13 | # 上游 torchao 测试目录通过 clone 获取, 路径为 torchao_test/ | 13 | # 上游 torchao 测试目录通过 clone 获取, 路径为 torchao_test/ |
| 14 | -# torchao_npu 自有测试目录为 test/ (test/npu/, test/unit/) | 14 | +# torchao_ascend 自有测试目录为 test/ (test/npu/, test/unit/) |
| 15 | # 两个目录的 test_*.py 文件均会被扫描 | 15 | # 两个目录的 test_*.py 文件均会被扫描 |
| 16 | # | 16 | # |
| 17 | # 扩展策略: | 17 | # 扩展策略: |
| @@ -1,5 +1,5 @@ | |||
| 1 | { | 1 | { |
| 2 | - "_description": "torchao_npu 方法级禁用清单 — 一条覆盖该方法的所有参数化变体", | 2 | + "_description": "torchao_ascend 方法级禁用清单 — 一条覆盖该方法的所有参数化变体", |
| 3 | "_usage": "在 test stage 中由 nightly_run_npu_test_shard.py 读取, pytest 执行前匹配 nodeid 的方法级前缀, 命中则直接标记 skipped (不启动 pytest)", | 3 | "_usage": "在 test stage 中由 nightly_run_npu_test_shard.py 读取, pytest 执行前匹配 nodeid 的方法级前缀, 命中则直接标记 skipped (不启动 pytest)", |
| 4 | "_format": "\"方法级 nodeid (不带 [参数] 后缀)\": \"禁用原因\"", | 4 | "_format": "\"方法级 nodeid (不带 [参数] 后缀)\": \"禁用原因\"", |
| 5 | "_matching": "前缀匹配 (startswith): nodeid 归一化 (去掉 test/ 或 torchao_test/ 树前缀) 后与方法键做 startswith 匹配, 键也做同样归一化", | 5 | "_matching": "前缀匹配 (startswith): nodeid 归一化 (去掉 test/ 或 torchao_test/ 树前缀) 后与方法键做 startswith 匹配, 键也做同样归一化", |
| @@ -534,7 +534,7 @@ def _ensure_test_package_shim(test_dir: Path) -> Optional[str]: | |||
| 534 | try: | 534 | try: |
| 535 | target = str(test_dir.resolve()) | 535 | target = str(test_dir.resolve()) |
| 536 | key = hashlib.md5(target.encode("utf-8")).hexdigest()[:12] | 536 | key = hashlib.md5(target.encode("utf-8")).hexdigest()[:12] |
| 537 | - shim_root = Path(tempfile.gettempdir()) / f"torchao_npu_test_shim_{key}" | 537 | + shim_root = Path(tempfile.gettempdir()) / f"torchao_ascend_test_shim_{key}" |
| 538 | shim_root.mkdir(parents=True, exist_ok=True) | 538 | shim_root.mkdir(parents=True, exist_ok=True) |
| 539 | link = shim_root / "test" | 539 | link = shim_root / "test" |
| 540 | if link.is_symlink() and os.path.realpath(link) != target: | 540 | if link.is_symlink() and os.path.realpath(link) != target: |
| @@ -1305,7 +1305,7 @@ def collect_one_category( | |||
| 1305 | # 错误日志按 source/category 分目录存放。display_name 已剥离树前缀 | 1305 | # 错误日志按 source/category 分目录存放。display_name 已剥离树前缀 |
| 1306 | # (test/ 或 torchao_test/), own 与 upstream 的同名测试文件若共用一个 | 1306 | # (test/ 或 torchao_test/), own 与 upstream 的同名测试文件若共用一个 |
| 1307 | # 目录会互相覆盖 (open 'w' 直接写同名 .log), 导致 own 源的失败日志丢失。 | 1307 | # 目录会互相覆盖 (open 'w' 直接写同名 .log), 导致 own 源的失败日志丢失。 |
| 1308 | - # source 标识优先用 shard_prefix (upstream / torchao_npu), 兜底用树目录名。 | 1308 | + # source 标识优先用 shard_prefix (upstream / torchao_ascend), 兜底用树目录名。 |
| 1309 | error_source_dir = spec.shard_prefix or spec.test_dir.name | 1309 | error_source_dir = spec.shard_prefix or spec.test_dir.name |
| 1310 | error_cat_dir = error_log_dir / error_source_dir / cat_name | 1310 | error_cat_dir = error_log_dir / error_source_dir / cat_name |
| 1311 | 1311 | ||
| @@ -1386,15 +1386,15 @@ def collect_source( | |||
| 1386 | 1386 | ||
| 1387 | 1387 | ||
| 1388 | def _dump_env_versions(output_dir: Path) -> None: | 1388 | def _dump_env_versions(output_dir: Path) -> None: |
| 1389 | - """Record the installed versions of torch/torch_npu/torchao/torchao_npu. | 1389 | + """Record the installed versions of torch/torch_npu/torchao/torchao_ascend. |
| 1390 | 1390 | ||
| 1391 | A single subprocess prints the versions one by one; each line is flushed as | 1391 | A single subprocess prints the versions one by one; each line is flushed as |
| 1392 | it is produced, so versions probed before a crash are still preserved. | 1392 | it is produced, so versions probed before a crash are still preserved. |
| 1393 | """ | 1393 | """ |
| 1394 | - mods = ("torch", "torch_npu", "torchao", "torchao_npu") | 1394 | + mods = ("torch", "torch_npu", "torchao", "torchao_ascend") |
| 1395 | probe_code = ( | 1395 | probe_code = ( |
| 1396 | "import os, importlib\n" | 1396 | "import os, importlib\n" |
| 1397 | - "mods = ('torch', 'torch_npu', 'torchao', 'torchao_npu')\n" | 1397 | + "mods = ('torch', 'torch_npu', 'torchao', 'torchao_ascend')\n" |
| 1398 | "for m in mods:\n" | 1398 | "for m in mods:\n" |
| 1399 | " try:\n" | 1399 | " try:\n" |
| 1400 | " mod = importlib.import_module(m)\n" | 1400 | " mod = importlib.import_module(m)\n" |
| @@ -1519,7 +1519,7 @@ def main(): | |||
| 1519 | s2_skipped = s2_result.skipped | 1519 | s2_skipped = s2_result.skipped |
| 1520 | 1520 | ||
| 1521 | # Merge per-source category summaries. Keyed by test_type (e.g. | 1521 | # Merge per-source category summaries. Keyed by test_type (e.g. |
| 1522 | - # upstream_regular / torchao_npu_regular) instead of the category name | 1522 | + # upstream_regular / torchao_ascend_regular) instead of the category name |
| 1523 | # (e.g. "regular"): both sources use the same category name, so a plain | 1523 | # (e.g. "regular"): both sources use the same category name, so a plain |
| 1524 | # dict-union would let one source overwrite the other. | 1524 | # dict-union would let one source overwrite the other. |
| 1525 | merged_categories = {} | 1525 | merged_categories = {} |
| @@ -1742,7 +1742,7 @@ def parse_args(): | |||
| 1742 | ) | 1742 | ) |
| 1743 | parser.add_argument( | 1743 | parser.add_argument( |
| 1744 | "--own-shard-prefix", type=str, default=None, | 1744 | "--own-shard-prefix", type=str, default=None, |
| 1745 | - help="Shard file name prefix for the own test dir (e.g. 'torchao_npu').", | 1745 | + help="Shard file name prefix for the own test dir (e.g. 'torchao_ascend').", |
| 1746 | ) | 1746 | ) |
| 1747 | parser.add_argument( | 1747 | parser.add_argument( |
| 1748 | "--own-regular-shards", type=int, default=None, | 1748 | "--own-regular-shards", type=int, default=None, |
| @@ -3,7 +3,7 @@ | |||
| 3 | Generate a consolidated markdown/json report for the NPU full test workflow. | 3 | Generate a consolidated markdown/json report for the NPU full test workflow. |
| 4 | 4 | ||
| 5 | Output files (names are controlled by the CLI flags, e.g. the nightly pipeline | 5 | Output files (names are controlled by the CLI flags, e.g. the nightly pipeline |
| 6 | -uses torchao-npu-test-summary.*): | 6 | +uses torchao-ascend-test-summary.*): |
| 7 | - <--output-markdown>: Markdown summary (aggregated stats + per-file results) | 7 | - <--output-markdown>: Markdown summary (aggregated stats + per-file results) |
| 8 | - <--output-json>: Lightweight JSON summary with aggregated stats only | 8 | - <--output-json>: Lightweight JSON summary with aggregated stats only |
| 9 | - <source>_cases_results_by_file.jsonl: Case-level results grouped by file | 9 | - <source>_cases_results_by_file.jsonl: Case-level results grouped by file |
| @@ -35,7 +35,7 @@ STATUS_NO_TESTS = "NO TESTS" | |||
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | def parse_args(): | 37 | def parse_args(): |
| 38 | - parser = argparse.ArgumentParser(description="Generate consolidated torchao_npu test report") | 38 | + parser = argparse.ArgumentParser(description="Generate consolidated torchao_ascend test report") |
| 39 | parser.add_argument("--reports-root", required=True, help="Root directory containing shard report files") | 39 | parser.add_argument("--reports-root", required=True, help="Root directory containing shard report files") |
| 40 | parser.add_argument("--output-markdown", required=True, help="Path to write markdown report") | 40 | parser.add_argument("--output-markdown", required=True, help="Path to write markdown report") |
| 41 | parser.add_argument("--output-json", required=True, help="Path to write JSON summary") | 41 | parser.add_argument("--output-json", required=True, help="Path to write JSON summary") |
| @@ -89,7 +89,7 @@ def parse_requested_shards(raw: str) -> List[Tuple[str, int]]: | |||
| 89 | "dist": "distributed", | 89 | "dist": "distributed", |
| 90 | "reg": "regular", | 90 | "reg": "regular", |
| 91 | "upstream": "upstream", | 91 | "upstream": "upstream", |
| 92 | - "own": "torchao_npu", | 92 | + "own": "torchao_ascend", |
| 93 | "custom": "custom", | 93 | "custom": "custom", |
| 94 | } | 94 | } |
| 95 | 95 | ||
| @@ -180,7 +180,7 @@ def discover_shard_files( | |||
| 180 | Filename format: shard_{type}-{number}_{suffix} | 180 | Filename format: shard_{type}-{number}_{suffix} |
| 181 | e.g., shard_dist-1_stats.json -> ("distributed", 1) | 181 | e.g., shard_dist-1_stats.json -> ("distributed", 1) |
| 182 | shard_reg-1_stats.json -> ("regular", 1) | 182 | shard_reg-1_stats.json -> ("regular", 1) |
| 183 | - shard_own-1_stats.json -> ("torchao_npu", 1) | 183 | + shard_own-1_stats.json -> ("torchao_ascend", 1) |
| 184 | shard_upstream-1_stats.json -> ("upstream", 1) | 184 | shard_upstream-1_stats.json -> ("upstream", 1) |
| 185 | shard_custom-1_stats.json -> ("custom", 1) | 185 | shard_custom-1_stats.json -> ("custom", 1) |
| 186 | """ | 186 | """ |
| @@ -189,7 +189,7 @@ def discover_shard_files( | |||
| 189 | for prefix, shard_type in [ | 189 | for prefix, shard_type in [ |
| 190 | ("dist", "distributed"), | 190 | ("dist", "distributed"), |
| 191 | ("reg", "regular"), | 191 | ("reg", "regular"), |
| 192 | - ("own", "torchao_npu"), | 192 | + ("own", "torchao_ascend"), |
| 193 | ("upstream", "upstream"), | 193 | ("upstream", "upstream"), |
| 194 | ("custom", "custom"), | 194 | ("custom", "custom"), |
| 195 | ]: | 195 | ]: |
| @@ -218,15 +218,15 @@ def discover_shard_files( | |||
| 218 | 218 | ||
| 219 | 219 | ||
| 220 | def _source_of_shard_type(shard_type: str) -> str: | 220 | def _source_of_shard_type(shard_type: str) -> str: |
| 221 | - """Map shard_type (e.g. upstream_regular / torchao_npu_regular) to a source key. | 221 | + """Map shard_type (e.g. upstream_regular / torchao_ascend_regular) to a source key. |
| 222 | 222 | ||
| 223 | Upstream and own sources can contain the same relative test path; keying by | 223 | Upstream and own sources can contain the same relative test path; keying by |
| 224 | source keeps them separate in the file-level summary. | 224 | source keeps them separate in the file-level summary. |
| 225 | """ | 225 | """ |
| 226 | if shard_type.startswith("upstream"): | 226 | if shard_type.startswith("upstream"): |
| 227 | return "upstream" | 227 | return "upstream" |
| 228 | - if shard_type.startswith("torchao_npu"): | 228 | + if shard_type.startswith("torchao_ascend"): |
| 229 | - return "torchao_npu" | 229 | + return "torchao_ascend" |
| 230 | return shard_type or "regular" | 230 | return shard_type or "regular" |
| 231 | 231 | ||
| 232 | 232 | ||
| @@ -333,7 +333,7 @@ def render_table(headers: List[str], rows: List[List[str]]) -> List[str]: | |||
| 333 | return lines | 333 | return lines |
| 334 | 334 | ||
| 335 | 335 | ||
| 336 | -def markdown_to_html(markdown_text: str, title: str = "Torchao NPU Test Summary") -> str: | 336 | +def markdown_to_html(markdown_text: str, title: str = "TorchAO-Ascend Test Summary") -> str: |
| 337 | """Convert the generated markdown report to a self-contained HTML page. | 337 | """Convert the generated markdown report to a self-contained HTML page. |
| 338 | 338 | ||
| 339 | Handles the subset of markdown produced by this script: | 339 | Handles the subset of markdown produced by this script: |
| @@ -766,7 +766,7 @@ def main(): | |||
| 766 | ["torch", f"`{env_versions.get('torch', 'N/A')}`"], | 766 | ["torch", f"`{env_versions.get('torch', 'N/A')}`"], |
| 767 | ["torch_npu", f"`{env_versions.get('torch_npu', 'N/A')}`"], | 767 | ["torch_npu", f"`{env_versions.get('torch_npu', 'N/A')}`"], |
| 768 | ["torchao", f"`{torchao_version}`"], | 768 | ["torchao", f"`{torchao_version}`"], |
| 769 | - ["torchao_npu", f"`{env_versions.get('torchao_npu', 'N/A')}`"], | 769 | + ["torchao_ascend", f"`{env_versions.get('torchao_ascend', 'N/A')}`"], |
| 770 | ["Patches applied", str(args.patch_count)], | 770 | ["Patches applied", str(args.patch_count)], |
| 771 | ["Docker image", f"`{args.docker_image}`"], | 771 | ["Docker image", f"`{args.docker_image}`"], |
| 772 | ["Runner", f"`{args.runner}`"], | 772 | ["Runner", f"`{args.runner}`"], |
| @@ -797,7 +797,7 @@ def main(): | |||
| 797 | overview_rows.append(["Special tests expected", str(len(special_test_names))]) | 797 | overview_rows.append(["Special tests expected", str(len(special_test_names))]) |
| 798 | 798 | ||
| 799 | markdown_lines = [ | 799 | markdown_lines = [ |
| 800 | - "# Torchao NPU Test Summary", | 800 | + "# TorchAO-Ascend Test Summary", |
| 801 | "", | 801 | "", |
| 802 | "## Overview", | 802 | "## Overview", |
| 803 | ] | 803 | ] |
| @@ -851,7 +851,7 @@ def main(): | |||
| 851 | # Map shard type prefix -> jsonl filename and test_type label | 851 | # Map shard type prefix -> jsonl filename and test_type label |
| 852 | _jsonl_specs = [ | 852 | _jsonl_specs = [ |
| 853 | ("upstream_regular_cases_by_file.jsonl", "upstream"), | 853 | ("upstream_regular_cases_by_file.jsonl", "upstream"), |
| 854 | - ("torchao_npu_regular_cases_by_file.jsonl", "torchao_npu"), | 854 | + ("torchao_ascend_regular_cases_by_file.jsonl", "torchao_ascend"), |
| 855 | ] | 855 | ] |
| 856 | for jsonl_name, test_type_label in _jsonl_specs: | 856 | for jsonl_name, test_type_label in _jsonl_specs: |
| 857 | jsonl_path = cases_by_file_dir / jsonl_name | 857 | jsonl_path = cases_by_file_dir / jsonl_name |
| @@ -1010,7 +1010,7 @@ def main(): | |||
| 1010 | # Process all shard types' cases_by_file JSONL files | 1010 | # Process all shard types' cases_by_file JSONL files |
| 1011 | _jsonl_specs = [ | 1011 | _jsonl_specs = [ |
| 1012 | ("upstream_regular_cases_by_file.jsonl", "upstream"), | 1012 | ("upstream_regular_cases_by_file.jsonl", "upstream"), |
| 1013 | - ("torchao_npu_regular_cases_by_file.jsonl", "torchao_npu"), | 1013 | + ("torchao_ascend_regular_cases_by_file.jsonl", "torchao_ascend"), |
| 1014 | ] | 1014 | ] |
| 1015 | for jsonl_name, test_type_label in _jsonl_specs: | 1015 | for jsonl_name, test_type_label in _jsonl_specs: |
| 1016 | jsonl_path = cases_by_file_dir / jsonl_name | 1016 | jsonl_path = cases_by_file_dir / jsonl_name |
| @@ -203,7 +203,7 @@ def save_case_log( | |||
| 203 | # Generate safe filename | 203 | # Generate safe filename |
| 204 | safe_name = sanitize_nodeid_for_filename(nodeid) | 204 | safe_name = sanitize_nodeid_for_filename(nodeid) |
| 205 | # 与 stats/info/cases 文件的前缀保持一致 (get_shard_type_prefix): | 205 | # 与 stats/info/cases 文件的前缀保持一致 (get_shard_type_prefix): |
| 206 | - # upstream_regular -> "upstream", torchao_npu_regular -> "own" 等 | 206 | + # upstream_regular -> "upstream", torchao_ascend_regular -> "own" 等 |
| 207 | prefix = parse_test_results.get_shard_type_prefix(shard_type) | 207 | prefix = parse_test_results.get_shard_type_prefix(shard_type) |
| 208 | log_filename = f"{prefix}-{shard}_{case_idx}_{safe_name}.log" | 208 | log_filename = f"{prefix}-{shard}_{case_idx}_{safe_name}.log" |
| 209 | log_path = cases_logs_dir / log_filename | 209 | log_path = cases_logs_dir / log_filename |
| @@ -748,11 +748,11 @@ def build_execution_env( | |||
| 748 | updates = { | 748 | updates = { |
| 749 | "PYTHONPATH": os.pathsep.join(pythonpath_parts), | 749 | "PYTHONPATH": os.pathsep.join(pythonpath_parts), |
| 750 | "PYTORCH_TEST_NPU": "1", | 750 | "PYTORCH_TEST_NPU": "1", |
| 751 | - # torchao_npu autoload: TORCH_DEVICE_BACKEND_AUTOLOAD=1 triggers | 751 | + # torchao_ascend autoload: TORCH_DEVICE_BACKEND_AUTOLOAD=1 triggers |
| 752 | - # torch_npu + torchao_npu auto-activation via torch.backends entry point. | 752 | + # torch_npu + torchao_ascend auto-activation via torch.backends entry point. |
| 753 | - # torchao_npu hooks into import torchao to apply monkey-patches. | 753 | + # torchao_ascend hooks into import torchao to apply monkey-patches. |
| 754 | "TORCH_DEVICE_BACKEND_AUTOLOAD": "1", | 754 | "TORCH_DEVICE_BACKEND_AUTOLOAD": "1", |
| 755 | - "TORCHAO_NPU_AUTO_ACTIVATE": "1", | 755 | + "TORCHAO_ASCEND_AUTO_ACTIVATE": "1", |
| 756 | "NO_TD": "1", | 756 | "NO_TD": "1", |
| 757 | "PYTHONUNBUFFERED": "1", | 757 | "PYTHONUNBUFFERED": "1", |
| 758 | } | 758 | } |
| @@ -65,10 +65,10 @@ _TYPE_TO_PREFIX = { | |||
| 65 | "distributed": "dist", | 65 | "distributed": "dist", |
| 66 | "regular": "reg", | 66 | "regular": "reg", |
| 67 | "custom": "custom", | 67 | "custom": "custom", |
| 68 | - "torchao_npu": "own", | 68 | + "torchao_ascend": "own", |
| 69 | "upstream": "upstream", | 69 | "upstream": "upstream", |
| 70 | "upstream_regular": "upstream", | 70 | "upstream_regular": "upstream", |
| 71 | - "torchao_npu_regular": "own", | 71 | + "torchao_ascend_regular": "own", |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | 74 | ||
R.gitcode/scripts/setup_torchao_npu_env_deps.sh→.gitcode/scripts/setup_torchao_ascend_env_deps.sh+18-18文件内容审核中,请稍后刷新重试
| @@ -54,18 +54,18 @@ jobs: | |||
| 54 | gcc --version | head -1 >> build_msg.txt | 54 | gcc --version | head -1 >> build_msg.txt |
| 55 | echo "=== Build Info End ===" >> build_msg.txt | 55 | echo "=== Build Info End ===" >> build_msg.txt |
| 56 | 56 | ||
| 57 | - - name: Install torchao_npu dependency | 57 | + - name: Install torchao_ascend dependency |
| 58 | run: | | 58 | run: | |
| 59 | - bash .gitcode/scripts/setup_torchao_npu_env_deps.sh --stage build --python python${{ inputs.PYTHON_VERSION }} | 59 | + bash .gitcode/scripts/setup_torchao_ascend_env_deps.sh --stage build --python python${{ inputs.PYTHON_VERSION }} |
| 60 | 60 | ||
| 61 | - - name: Build torchao_npu wheel | 61 | + - name: Build torchao_ascend wheel |
| 62 | id: build | 62 | id: build |
| 63 | run: | | 63 | run: | |
| 64 | - bash ci/build.sh --python="${{ inputs.PYTHON_VERSION }}" 2>&1 | tee /tmp/build_torchao_npu.log | 64 | + bash ci/build.sh --python="${{ inputs.PYTHON_VERSION }}" 2>&1 | tee /tmp/build_torchao_ascend.log |
| 65 | BUILD_STATUS=${PIPESTATUS[0]} | 65 | BUILD_STATUS=${PIPESTATUS[0]} |
| 66 | echo "status=${BUILD_STATUS}" >> $ATOMGIT_OUTPUT | 66 | echo "status=${BUILD_STATUS}" >> $ATOMGIT_OUTPUT |
| 67 | if [ ${BUILD_STATUS} -eq 0 ]; then | 67 | if [ ${BUILD_STATUS} -eq 0 ]; then |
| 68 | - WHL=$(ls dist/torchao_npu*.whl 2>/dev/null | head -1) | 68 | + WHL=$(ls dist/torchao_ascend*.whl 2>/dev/null | head -1) |
| 69 | echo "wheel=${WHL}" >> $ATOMGIT_OUTPUT | 69 | echo "wheel=${WHL}" >> $ATOMGIT_OUTPUT |
| 70 | echo "Build succeeded: ${WHL}" | 70 | echo "Build succeeded: ${WHL}" |
| 71 | echo "Wheel: ${WHL##*/}" >> build_msg.txt | 71 | echo "Wheel: ${WHL##*/}" >> build_msg.txt |
| @@ -75,11 +75,11 @@ jobs: | |||
| 75 | fi | 75 | fi |
| 76 | exit ${BUILD_STATUS} | 76 | exit ${BUILD_STATUS} |
| 77 | 77 | ||
| 78 | - - name: Upload torchao_npu wheel as artifact | 78 | + - name: Upload torchao_ascend wheel as artifact |
| 79 | uses: upload-artifact | 79 | uses: upload-artifact |
| 80 | with: | 80 | with: |
| 81 | - name: torchao-npu-wheel | 81 | + name: torchao-ascend-wheel |
| 82 | - path: "dist/torchao_npu*.whl" | 82 | + path: "dist/torchao_ascend*.whl" |
| 83 | retention-days: 14 | 83 | retention-days: 14 |
| 84 | overwrite: true | 84 | overwrite: true |
| 85 | 85 | ||
| @@ -27,7 +27,7 @@ on: | |||
| 27 | type: string | 27 | type: string |
| 28 | default: "3" | 28 | default: "3" |
| 29 | OWN_SHARDS: | 29 | OWN_SHARDS: |
| 30 | - description: Number of shards for torchao_npu own tests | 30 | + description: Number of shards for torchao_ascend own tests |
| 31 | required: false | 31 | required: false |
| 32 | type: string | 32 | type: string |
| 33 | default: "1" | 33 | default: "1" |
| @@ -55,15 +55,15 @@ jobs: | |||
| 55 | - name: checkout | 55 | - name: checkout |
| 56 | uses: checkout | 56 | uses: checkout |
| 57 | 57 | ||
| 58 | - - name: Download torchao-npu-wheel | 58 | + - name: Download torchao-ascend-wheel |
| 59 | uses: download-artifact | 59 | uses: download-artifact |
| 60 | with: | 60 | with: |
| 61 | - name: torchao-npu-wheel | 61 | + name: torchao-ascend-wheel |
| 62 | path: ./ | 62 | path: ./ |
| 63 | 63 | ||
| 64 | - - name: Setup torchao_npu test environment | 64 | + - name: Setup torchao_ascend test environment |
| 65 | run: | | 65 | run: | |
| 66 | - bash .gitcode/scripts/setup_torchao_npu_env_deps.sh \ | 66 | + bash .gitcode/scripts/setup_torchao_ascend_env_deps.sh \ |
| 67 | --stage collect \ | 67 | --stage collect \ |
| 68 | --wheel-artifact-dir ./ \ | 68 | --wheel-artifact-dir ./ \ |
| 69 | --python python${{ inputs.PYTHON_VERSION }} | 69 | --python python${{ inputs.PYTHON_VERSION }} |
| @@ -100,13 +100,13 @@ jobs: | |||
| 100 | --disabled-methods .gitcode/config/disabled_test_methods.json \ | 100 | --disabled-methods .gitcode/config/disabled_test_methods.json \ |
| 101 | --upstream-override-dir test/upstream \ | 101 | --upstream-override-dir test/upstream \ |
| 102 | --upstream-shard-prefix upstream \ | 102 | --upstream-shard-prefix upstream \ |
| 103 | - --own-shard-prefix torchao_npu | 103 | + --own-shard-prefix torchao_ascend |
| 104 | 104 | ||
| 105 | - name: Check shard availability | 105 | - name: Check shard availability |
| 106 | id: check_shards | 106 | id: check_shards |
| 107 | run: | | 107 | run: | |
| 108 | echo "has_upstream=$(test -f cases_shards/upstream_regular_cases_shard_1.json && echo true || echo false)" >> $ATOMGIT_OUTPUT | 108 | echo "has_upstream=$(test -f cases_shards/upstream_regular_cases_shard_1.json && echo true || echo false)" >> $ATOMGIT_OUTPUT |
| 109 | - echo "has_own=$(test -f cases_shards/torchao_npu_regular_cases_shard_1.json && echo true || echo false)" >> $ATOMGIT_OUTPUT | 109 | + echo "has_own=$(test -f cases_shards/torchao_ascend_regular_cases_shard_1.json && echo true || echo false)" >> $ATOMGIT_OUTPUT |
| 110 | echo "=== Shard availability ===" | 110 | echo "=== Shard availability ===" |
| 111 | cat $ATOMGIT_OUTPUT | 111 | cat $ATOMGIT_OUTPUT |
| 112 | 112 | ||
| @@ -51,9 +51,9 @@ jobs: | |||
| 51 | run: | | 51 | run: | |
| 52 | python${{ inputs.PYTHON_VERSION }} .gitcode/scripts/nightly_generate_test_report.py \ | 52 | python${{ inputs.PYTHON_VERSION }} .gitcode/scripts/nightly_generate_test_report.py \ |
| 53 | --reports-root . \ | 53 | --reports-root . \ |
| 54 | - --output-markdown torchao-npu-test-summary.md \ | 54 | + --output-markdown torchao-ascend-test-summary.md \ |
| 55 | - --output-json torchao-npu-test-summary.json \ | 55 | + --output-json torchao-ascend-test-summary.json \ |
| 56 | - --output-html torchao-npu-test-report.html \ | 56 | + --output-html torchao-ascend-test-report.html \ |
| 57 | --shard-matrix-json '["upstream-1","upstream-2","upstream-3","own-1"]' \ | 57 | --shard-matrix-json '["upstream-1","upstream-2","upstream-3","own-1"]' \ |
| 58 | --cases-summary cases_shards/cases_collection_summary.json \ | 58 | --cases-summary cases_shards/cases_collection_summary.json \ |
| 59 | --cases-by-file-dir cases_shards \ | 59 | --cases-by-file-dir cases_shards \ |
| @@ -61,17 +61,17 @@ jobs: | |||
| 61 | --runner "self-hosted" | 61 | --runner "self-hosted" |
| 62 | 62 | ||
| 63 | echo "=== Test Report Summary ===" | 63 | echo "=== Test Report Summary ===" |
| 64 | - cat torchao-npu-test-summary.md | 64 | + cat torchao-ascend-test-summary.md |
| 65 | 65 | ||
| 66 | - name: Upload reports as artifact | 66 | - name: Upload reports as artifact |
| 67 | uses: upload-artifact | 67 | uses: upload-artifact |
| 68 | with: | 68 | with: |
| 69 | - name: torchao-npu-test-report | 69 | + name: torchao-ascend-test-report |
| 70 | path: | | 70 | path: | |
| 71 | - torchao-npu-test-summary.md | 71 | + torchao-ascend-test-summary.md |
| 72 | - torchao-npu-test-summary.json | 72 | + torchao-ascend-test-summary.json |
| 73 | - torchao-npu-test-report.html | 73 | + torchao-ascend-test-report.html |
| 74 | upstream_cases_results_by_file.jsonl | 74 | upstream_cases_results_by_file.jsonl |
| 75 | - torchao_npu_cases_results_by_file.jsonl | 75 | + torchao_ascend_cases_results_by_file.jsonl |
| 76 | retention-days: 14 | 76 | retention-days: 14 |
| 77 | overwrite: true | 77 | overwrite: true |
| @@ -32,7 +32,7 @@ jobs: | |||
| 32 | ref: ${{ inputs.merge_ref }} | 32 | ref: ${{ inputs.merge_ref }} |
| 33 | allow-unsafe-pr-checkout: true | 33 | allow-unsafe-pr-checkout: true |
| 34 | 34 | ||
| 35 | - - name: Build torchao_npu wheel | 35 | + - name: Build torchao_ascend wheel |
| 36 | env: | 36 | env: |
| 37 | EXPECTED_ARCH: ${{ inputs.wheel_arch }} | 37 | EXPECTED_ARCH: ${{ inputs.wheel_arch }} |
| 38 | PIP_INDEX_URL: https://mirrors.huaweicloud.com/repository/pypi/simple | 38 | PIP_INDEX_URL: https://mirrors.huaweicloud.com/repository/pypi/simple |
| @@ -48,12 +48,12 @@ jobs: | |||
| 48 | python3.10 -m venv "$build_env" | 48 | python3.10 -m venv "$build_env" |
| 49 | "$build_env/bin/python" -m pip install build | 49 | "$build_env/bin/python" -m pip install build |
| 50 | bash ci/build.sh --python="$build_env/bin/python" | 50 | bash ci/build.sh --python="$build_env/bin/python" |
| 51 | - set -- dist/torchao_npu*.whl | 51 | + set -- dist/torchao_ascend*.whl |
| 52 | test "$#" -eq 1 && test -f "$1" | 52 | test "$#" -eq 1 && test -f "$1" |
| 53 | 53 | ||
| 54 | - name: Upload wheel to GitCode Artifacts | 54 | - name: Upload wheel to GitCode Artifacts |
| 55 | uses: upload-artifact | 55 | uses: upload-artifact |
| 56 | with: | 56 | with: |
| 57 | - name: torchao-npu-wheel-${{ inputs.wheel_arch }} | 57 | + name: torchao-ascend-wheel-${{ inputs.wheel_arch }} |
| 58 | - path: dist/torchao_npu*.whl | 58 | + path: dist/torchao_ascend*.whl |
| 59 | overwrite: true | 59 | overwrite: true |
R.gitcode/workflows/nightly-pipeline-torchao-npu.yml→.gitcode/workflows/nightly-pipeline-torchao-ascend.yml+8-8
| @@ -1,14 +1,14 @@ | |||
| 1 | -# TorchaoNPU 每日自动化验证流水线 | 1 | +# TorchAO-Ascend 每日自动化验证流水线 |
| 2 | # 流程: build → collect → test(4 job) → report | 2 | # 流程: build → collect → test(4 job) → report |
| 3 | # | 3 | # |
| 4 | # 四个阶段说明: | 4 | # 四个阶段说明: |
| 5 | -# 1. stage_build 安装依赖 + 构建 torchao_npu wheel | 5 | +# 1. stage_build 安装依赖 + 构建 torchao_ascend wheel |
| 6 | # 2. stage_collect 克隆上游 torchao test/ + 采集用例并分片 (上游 3 分片 + 自有 1 分片) | 6 | # 2. stage_collect 克隆上游 torchao test/ + 采集用例并分片 (上游 3 分片 + 自有 1 分片) |
| 7 | # 3. stage_test 执行测试, 共 4 个 job: | 7 | # 3. stage_test 执行测试, 共 4 个 job: |
| 8 | # - 上游 torchao 测试 3 分片 (test_upstream_1..3) | 8 | # - 上游 torchao 测试 3 分片 (test_upstream_1..3) |
| 9 | -# - torchao_npu 自有测试 1 分片 (test_own_1, 含 npu + unit + upstream) | 9 | +# - torchao_ascend 自有测试 1 分片 (test_own_1, 含 npu + unit + upstream) |
| 10 | # 4. stage_report 汇总测试报告 (always 执行) | 10 | # 4. stage_report 汇总测试报告 (always 执行) |
| 11 | -name: Torchao NPU Test Nightly | 11 | +name: TorchAO-Ascend Test Nightly |
| 12 | 12 | ||
| 13 | on: | 13 | on: |
| 14 | schedule: | 14 | schedule: |
| @@ -16,13 +16,13 @@ on: | |||
| 16 | pull_request: | 16 | pull_request: |
| 17 | branches: [master] | 17 | branches: [master] |
| 18 | paths: | 18 | paths: |
| 19 | - - ".gitcode/workflows/nightly-pipeline-torchao-npu.yml" | 19 | + - ".gitcode/workflows/nightly-pipeline-torchao-ascend.yml" |
| 20 | - ".gitcode/workflows/_nightly_build.yml" | 20 | - ".gitcode/workflows/_nightly_build.yml" |
| 21 | - ".gitcode/workflows/_nightly_collect.yml" | 21 | - ".gitcode/workflows/_nightly_collect.yml" |
| 22 | - ".gitcode/workflows/_nightly_test_job.yml" | 22 | - ".gitcode/workflows/_nightly_test_job.yml" |
| 23 | - ".gitcode/workflows/_nightly_report.yml" | 23 | - ".gitcode/workflows/_nightly_report.yml" |
| 24 | - ".gitcode/scripts/install_pytorch_from_requirements.py" | 24 | - ".gitcode/scripts/install_pytorch_from_requirements.py" |
| 25 | - - ".gitcode/scripts/setup_torchao_npu_env_deps.sh" | 25 | + - ".gitcode/scripts/setup_torchao_ascend_env_deps.sh" |
| 26 | - ".gitcode/scripts/fetch_torchao_test_code.sh" | 26 | - ".gitcode/scripts/fetch_torchao_test_code.sh" |
| 27 | - ".gitcode/scripts/collect_all_cases.py" | 27 | - ".gitcode/scripts/collect_all_cases.py" |
| 28 | - ".gitcode/scripts/discover_test_files.py" | 28 | - ".gitcode/scripts/discover_test_files.py" |
| @@ -141,13 +141,13 @@ stages: | |||
| 141 | CONTAINER_OPTIONS: ${{ env.CONTAINER_OPTS_NPU }} | 141 | CONTAINER_OPTIONS: ${{ env.CONTAINER_OPTS_NPU }} |
| 142 | NPU_LABEL: ${{ env.NPU_LABEL_TEST }} | 142 | NPU_LABEL: ${{ env.NPU_LABEL_TEST }} |
| 143 | 143 | ||
| 144 | - # torchao_npu 自有测试: 1 分片 (含 npu + unit + upstream) | 144 | + # torchao_ascend 自有测试: 1 分片 (含 npu + unit + upstream) |
| 145 | test_own_1: | 145 | test_own_1: |
| 146 | name: test-own-1 | 146 | name: test-own-1 |
| 147 | select: selected_by_default | 147 | select: selected_by_default |
| 148 | uses: .gitcode/workflows/_nightly_test_job.yml | 148 | uses: .gitcode/workflows/_nightly_test_job.yml |
| 149 | with: | 149 | with: |
| 150 | - SHARD_FILE: torchao_npu_regular_cases_shard_1.json | 150 | + SHARD_FILE: torchao_ascend_regular_cases_shard_1.json |
| 151 | TEST_DIR_NAME: test | 151 | TEST_DIR_NAME: test |
| 152 | REPORT_NAME: test-reports-own-1 | 152 | REPORT_NAME: test-reports-own-1 |
| 153 | CASE_TIMEOUT: ${{ env.CASE_TIMEOUT }} | 153 | CASE_TIMEOUT: ${{ env.CASE_TIMEOUT }} |
| @@ -10,7 +10,7 @@ Thank you for considering contributing to Ascend for TorchAO! We welcome contrib | |||
| 10 | 10 | ||
| 11 | ```text | 11 | ```text |
| 12 | torchao-ascend/ | 12 | torchao-ascend/ |
| 13 | -├── torchao_npu/ # Public Python package and patch entry point | 13 | +├── torchao_ascend/ # Public Python package and patch entry point |
| 14 | │ ├── patches/ # Operator patches for torchao (FP8 / Blockwise FP8 / MX) | 14 | │ ├── patches/ # Operator patches for torchao (FP8 / Blockwise FP8 / MX) |
| 15 | │ └── hifloat8/ # NPU-native HiFloat8: tensor, training and inference | 15 | │ └── hifloat8/ # NPU-native HiFloat8: tensor, training and inference |
| 16 | ├── test/ # Basic functional tests (NPU environment) | 16 | ├── test/ # Basic functional tests (NPU environment) |
| @@ -84,7 +84,7 @@ If you are able to solve problems raised by others, we warmly welcome you to sha | |||
| 84 | 3. **Create a development branch**: | 84 | 3. **Create a development branch**: |
| 85 | 85 | ||
| 86 | ```bash | 86 | ```bash |
| 87 | - git checkout -b {new_branch_name} origin/master | 87 | + git checkout -b {new_branch_name} origin/main |
| 88 | ``` | 88 | ``` |
| 89 | 89 | ||
| 90 | 4. **Develop the code**: Follow the [Code Style](#code-style) guidelines | 90 | 4. **Develop the code**: Follow the [Code Style](#code-style) guidelines |
| @@ -4,7 +4,7 @@ Copyright 2023 Meta | |||
| 4 | All contributions by Arm: | 4 | All contributions by Arm: |
| 5 | Copyright (c) 2024-2026 Arm Limited and/or its affiliates | 5 | Copyright (c) 2024-2026 Arm Limited and/or its affiliates |
| 6 | 6 | ||
| 7 | -torchao_npu uses a copyright model similar to torchao: each contributor holds | 7 | +torchao-ascend uses a copyright model similar to torchao: each contributor holds |
| 8 | copyright over their contributions to this project. The project versioning | 8 | copyright over their contributions to this project. The project versioning |
| 9 | records all such contribution and copyright details. If a contributor wants | 9 | records all such contribution and copyright details. If a contributor wants |
| 10 | to further mark their specific copyright on a particular contribution, they | 10 | to further mark their specific copyright on a particular contribution, they |
| @@ -47,9 +47,9 @@ | |||
| 47 | 47 | ||
| 48 | ## 编译安装 | 48 | ## 编译安装 |
| 49 | 49 | ||
| 50 | -### 下载master分支代码 | 50 | +### 下载main分支代码 |
| 51 | 51 | ||
| 52 | -执行以下命令下载 master 分支代码并进入 TorchAONPU 插件根目录: | 52 | +执行以下命令下载 main 分支代码并进入 TorchAO-Ascend 插件根目录: |
| 53 | ```bash | 53 | ```bash |
| 54 | git clone https://gitcode.com/Ascend/torchao-ascend.git | 54 | git clone https://gitcode.com/Ascend/torchao-ascend.git |
| 55 | cd torchao-ascend | 55 | cd torchao-ascend |
| @@ -170,7 +170,7 @@ optimizer.step() | |||
| 170 | 170 | ||
| 171 | ## 环境变量说明 | 171 | ## 环境变量说明 |
| 172 | 172 | ||
| 173 | -TorchAONPU复用PyTorch的device-backend自动加载通道,NPU环境下首次`import torchao`时自动激活,无需显式`import torchao_npu`;如需关闭自动激活,请参见[环境变量列表](./docs/zh/api/environment_variable/env_variable_list.md)。 | 173 | +TorchAO-Ascend复用PyTorch的device-backend自动加载通道,NPU环境下首次`import torchao`时自动激活,无需显式`import torchao_ascend`;如需关闭自动激活,请参见[环境变量列表](./docs/zh/api/environment_variable/env_variable_list.md)。 |
| 174 | 174 | ||
| 175 | ## 社区交流 | 175 | ## 社区交流 |
| 176 | 176 | ||
| @@ -47,9 +47,9 @@ For the compatibility between torch_npu and CANN, refer to the [TorchNPU version | |||
| 47 | 47 | ||
| 48 | ## Build and Installation | 48 | ## Build and Installation |
| 49 | 49 | ||
| 50 | -### Download the master branch code | 50 | +### Download the main branch code |
| 51 | 51 | ||
| 52 | -Run the following commands to download the master branch code and enter the TorchAONPU plugin root directory: | 52 | +Run the following commands to download the main branch code and enter the TorchAO-Ascend plugin root directory: |
| 53 | ```bash | 53 | ```bash |
| 54 | git clone https://gitcode.com/Ascend/torchao-ascend.git | 54 | git clone https://gitcode.com/Ascend/torchao-ascend.git |
| 55 | cd torchao-ascend | 55 | cd torchao-ascend |
| @@ -172,7 +172,7 @@ This table shows the feature support status of torchao-ascend across different h | |||
| 172 | 172 | ||
| 173 | ## Environment Variables | 173 | ## Environment Variables |
| 174 | 174 | ||
| 175 | -TorchAONPU reuses PyTorch's device-backend auto-loading channel. It is activated automatically the first time `import torchao` is executed in an NPU environment, without requiring an explicit `import torchao_npu`. To disable auto-activation, see the [environment variable list](./docs/zh/api/environment_variable/env_variable_list.md) (in Chinese). | 175 | +TorchAO-Ascend reuses PyTorch's device-backend auto-loading channel. It is activated automatically the first time `import torchao` is executed in an NPU environment, without requiring an explicit `import torchao_ascend`. To disable auto-activation, see the [environment variable list](./docs/zh/api/environment_variable/env_variable_list.md) (in Chinese). |
| 176 | 176 | ||
| 177 | ## Community | 177 | ## Community |
| 178 | 178 | ||
| @@ -1,12 +1,12 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd |
| 2 | 2 | ||
| 3 | -"""torch device-backend autoload entry point for torchao_npu. | 3 | +"""torch device-backend autoload entry point for torchao_ascend. |
| 4 | 4 | ||
| 5 | Torch calls ``bootstrap()`` at the end of ``import torch`` (via the | 5 | Torch calls ``bootstrap()`` at the end of ``import torch`` (via the |
| 6 | ``torch.backends`` entry-points group, the same channel torch_npu uses). | 6 | ``torch.backends`` entry-points group, the same channel torch_npu uses). |
| 7 | On NPU machines this installs a ``sys.meta_path`` hook that activates | 7 | On NPU machines this installs a ``sys.meta_path`` hook that activates |
| 8 | -torchao_npu right after the first ``import torchao`` finishes executing, | 8 | +torchao_ascend right after the first ``import torchao`` finishes executing, |
| 9 | -so users never need to import torchao_npu explicitly: | 9 | +so users never need to import torchao_ascend explicitly: |
| 10 | 10 | ||
| 11 | import torch | 11 | import torch |
| 12 | from torchao import w4a8 # NPU extensions available, zero explicit import | 12 | from torchao import w4a8 # NPU extensions available, zero explicit import |
| @@ -14,8 +14,8 @@ so users never need to import torchao_npu explicitly: | |||
| 14 | Escape hatches (two levels): | 14 | Escape hatches (two levels): |
| 15 | * ``TORCH_DEVICE_BACKEND_AUTOLOAD=0`` -- torch-level: disables every | 15 | * ``TORCH_DEVICE_BACKEND_AUTOLOAD=0`` -- torch-level: disables every |
| 16 | device-backend autoload (including torch_npu). | 16 | device-backend autoload (including torch_npu). |
| 17 | - * ``TORCHAO_NPU_AUTO_ACTIVATE=0`` -- torchao_npu-level: disables only | 17 | + * ``TORCHAO_ASCEND_AUTO_ACTIVATE=0`` -- torchao_ascend-level: disables only |
| 18 | - this auto-activation; explicit ``import torchao_npu`` still works. | 18 | + this auto-activation; explicit ``import torchao_ascend`` still works. |
| 19 | 19 | ||
| 20 | If ``torchao`` was imported before torch's autoload ran (its find_spec | 20 | If ``torchao`` was imported before torch's autoload ran (its find_spec |
| 21 | already executed and its body may still be running), the one-shot hook | 21 | already executed and its body may still be running), the one-shot hook |
| @@ -23,10 +23,10 @@ can never fire: bootstrap warns with guidance instead of installing it, | |||
| 23 | so the loss of activation is never silent. | 23 | so the loss of activation is never silent. |
| 24 | 24 | ||
| 25 | This module MUST stay a standalone top-level module: pointing the entry | 25 | This module MUST stay a standalone top-level module: pointing the entry |
| 26 | -point at ``torchao_npu:_autoload`` would execute the whole torchao_npu | 26 | +point at ``torchao_ascend:_autoload`` would execute the whole torchao_ascend |
| 27 | package ``__init__`` (which imports torchao) while ``import torch`` has | 27 | package ``__init__`` (which imports torchao) while ``import torch`` has |
| 28 | not returned yet. All heavy work is deferred to the meta-path hook, and | 28 | not returned yet. All heavy work is deferred to the meta-path hook, and |
| 29 | -activation itself reuses the idempotent ``torchao_npu.activate()``. | 29 | +activation itself reuses the idempotent ``torchao_ascend.activate()``. |
| 30 | """ | 30 | """ |
| 31 | from __future__ import annotations | 31 | from __future__ import annotations |
| 32 | 32 | ||
| @@ -52,18 +52,18 @@ def bootstrap() -> None: | |||
| 52 | _bootstrap() | 52 | _bootstrap() |
| 53 | except Exception as exc: # pragma: no cover - defensive by design | 53 | except Exception as exc: # pragma: no cover - defensive by design |
| 54 | warnings.warn( | 54 | warnings.warn( |
| 55 | - f"torchao_npu autoload skipped: {exc!r}", | 55 | + f"torchao_ascend autoload skipped: {exc!r}", |
| 56 | RuntimeWarning, | 56 | RuntimeWarning, |
| 57 | stacklevel=2, | 57 | stacklevel=2, |
| 58 | ) | 58 | ) |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | def _bootstrap() -> None: | 61 | def _bootstrap() -> None: |
| 62 | - if os.environ.get("TORCHAO_NPU_AUTO_ACTIVATE", "1") != "1": | 62 | + if os.environ.get("TORCHAO_ASCEND_AUTO_ACTIVATE", "1") != "1": |
| 63 | - return # escape hatch: torchao_npu-level switch (default on) | 63 | + return # escape hatch: torchao_ascend-level switch (default on) |
| 64 | - if "torchao_npu" in sys.modules: | 64 | + if "torchao_ascend" in sys.modules: |
| 65 | - # Circular guard: torchao_npu is already (being) initialized, e.g. | 65 | + # Circular guard: torchao_ascend is already (being) initialized, e.g. |
| 66 | - # the user's very first import was ``import torchao_npu``; its own | 66 | + # the user's very first import was ``import torchao_ascend``; its own |
| 67 | # ``__init__`` calls activate() already, so no hook is needed. | 67 | # ``__init__`` calls activate() already, so no hook is needed. |
| 68 | return | 68 | return |
| 69 | if importlib.util.find_spec("torch_npu") is None: | 69 | if importlib.util.find_spec("torch_npu") is None: |
| @@ -74,9 +74,9 @@ def _bootstrap() -> None: | |||
| 74 | # cache short-circuits meta_path) and its body may still be executing | 74 | # cache short-circuits meta_path) and its body may still be executing |
| 75 | # (too early to patch). Warn instead of silently losing activation. | 75 | # (too early to patch). Warn instead of silently losing activation. |
| 76 | warnings.warn( | 76 | warnings.warn( |
| 77 | - "torchao_npu auto-activation skipped: 'torchao' was imported before " | 77 | + "torchao_ascend auto-activation skipped: 'torchao' was imported before " |
| 78 | "the torch device-backend autoload ran; NPU support will not be " | 78 | "the torch device-backend autoload ran; NPU support will not be " |
| 79 | - "auto-activated for this module. Import torchao_npu explicitly to " | 79 | + "auto-activated for this module. Import torchao_ascend explicitly to " |
| 80 | "enable it.", | 80 | "enable it.", |
| 81 | RuntimeWarning, | 81 | RuntimeWarning, |
| 82 | stacklevel=2, | 82 | stacklevel=2, |
| @@ -89,7 +89,7 @@ class _TorchaoImportHook(importlib.abc.MetaPathFinder): | |||
| 89 | """Intercept the first ``import torchao``. | 89 | """Intercept the first ``import torchao``. |
| 90 | 90 | ||
| 91 | The hook wraps ``exec_module`` so that torchao's module body fully | 91 | The hook wraps ``exec_module`` so that torchao's module body fully |
| 92 | - executes before torchao_npu patches it, and the patches land before | 92 | + executes before torchao_ascend patches it, and the patches land before |
| 93 | any user ``from torchao... import name`` binding. | 93 | any user ``from torchao... import name`` binding. |
| 94 | """ | 94 | """ |
| 95 | 95 | ||
| @@ -119,29 +119,29 @@ class _TorchaoImportHook(importlib.abc.MetaPathFinder): | |||
| 119 | if spec is None or spec.loader is None: | 119 | if spec is None or spec.loader is None: |
| 120 | return None | 120 | return None |
| 121 | original_exec = spec.loader.exec_module | 121 | original_exec = spec.loader.exec_module |
| 122 | - if getattr(original_exec, "_torchao_npu_wrapped", False): | 122 | + if getattr(original_exec, "_torchao_ascend_wrapped", False): |
| 123 | return spec # this loader already carries our wrapper: never wrap twice | 123 | return spec # this loader already carries our wrapper: never wrap twice |
| 124 | 124 | ||
| 125 | def wrapped_exec(module): | 125 | def wrapped_exec(module): |
| 126 | self._detach() # one-shot only on module execution | 126 | self._detach() # one-shot only on module execution |
| 127 | original_exec(module) # 1) run torchao's module body completely | 127 | original_exec(module) # 1) run torchao's module body completely |
| 128 | - _try_activate() # 2) only then activate torchao_npu | 128 | + _try_activate() # 2) only then activate torchao_ascend |
| 129 | - wrapped_exec._torchao_npu_wrapped = True | 129 | + wrapped_exec._torchao_ascend_wrapped = True |
| 130 | spec.loader.exec_module = wrapped_exec | 130 | spec.loader.exec_module = wrapped_exec |
| 131 | return spec | 131 | return spec |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | def _try_activate() -> None: | 134 | def _try_activate() -> None: |
| 135 | - """Hook callback: activate torchao_npu after torchao's body executed. | 135 | + """Hook callback: activate torchao_ascend after torchao's body executed. |
| 136 | 136 | ||
| 137 | - Failures only warn, so a broken torchao_npu install can never break | 137 | + Failures only warn, so a broken torchao_ascend install can never break |
| 138 | ``import torchao`` / ``import torch``. | 138 | ``import torchao`` / ``import torch``. |
| 139 | """ | 139 | """ |
| 140 | try: | 140 | try: |
| 141 | - import torchao_npu # noqa: F401 trigger path 1: __init__ activates | 141 | + import torchao_ascend # noqa: F401 trigger path 1: __init__ activates |
| 142 | except Exception as exc: # pragma: no cover - defensive by design | 142 | except Exception as exc: # pragma: no cover - defensive by design |
| 143 | warnings.warn( | 143 | warnings.warn( |
| 144 | - f"torchao_npu auto-activation failed: {exc!r}", | 144 | + f"torchao_ascend auto-activation failed: {exc!r}", |
| 145 | RuntimeWarning, | 145 | RuntimeWarning, |
| 146 | stacklevel=2, | 146 | stacklevel=2, |
| 147 | ) | 147 | ) |
| @@ -26,7 +26,7 @@ import inspect | |||
| 26 | 26 | ||
| 27 | import torch | 27 | import torch |
| 28 | import torch_npu # noqa: F401 registers the NPU with torch.accelerator | 28 | import torch_npu # noqa: F401 registers the NPU with torch.accelerator |
| 29 | -import torchao_npu # noqa: F401 activates the MXFP8/Float8 patches | 29 | +import torchao_ascend # noqa: F401 activates the MXFP8/Float8 patches |
| 30 | from torchao.prototype.moe_training.fp8_grouped_mm import _Float8GroupedMM | 30 | from torchao.prototype.moe_training.fp8_grouped_mm import _Float8GroupedMM |
| 31 | 31 | ||
| 32 | from probe import ScopeDef | 32 | from probe import ScopeDef |
| @@ -51,7 +51,7 @@ def install(metadata): | |||
| 51 | profiled call so each call's attribution is isolated. | 51 | profiled call so each call's attribution is isolated. |
| 52 | """ | 52 | """ |
| 53 | patch_mod = importlib.import_module( | 53 | patch_mod = importlib.import_module( |
| 54 | - "torchao_npu.patches.torchao.prototype.moe_training.fp8_grouped_mm" | 54 | + "torchao_ascend.patches.torchao.prototype.moe_training.fp8_grouped_mm" |
| 55 | ) | 55 | ) |
| 56 | originals = [] | 56 | originals = [] |
| 57 | 57 | ||
| @@ -9,7 +9,7 @@ from pathlib import Path | |||
| 9 | from typing import Callable, Optional | 9 | from typing import Callable, Optional |
| 10 | 10 | ||
| 11 | import torch | 11 | import torch |
| 12 | -import torchao_npu # noqa: F401 activates MXFP8/Float8 patches + injects KernelPreference.NPU | 12 | +import torchao_ascend # noqa: F401 activates MXFP8/Float8 patches + injects KernelPreference.NPU |
| 13 | 13 | ||
| 14 | from torchao.prototype.moe_training.fp8_grouped_mm import _Float8GroupedMM | 14 | from torchao.prototype.moe_training.fp8_grouped_mm import _Float8GroupedMM |
| 15 | from torchao.prototype.moe_training.config import ( | 15 | from torchao.prototype.moe_training.config import ( |
| @@ -201,7 +201,7 @@ def _mxfp8_builder(recipe_enum: MXFP8TrainingRecipe) -> Callable[[int], Callable | |||
| 201 | through the upstream dispatcher, which forwards kernel_preference / | 201 | through the upstream dispatcher, which forwards kernel_preference / |
| 202 | wgrad_with_hp from the config; AUTO keeps the upstream SM100 meaning and | 202 | wgrad_with_hp from the config; AUTO keeps the upstream SM100 meaning and |
| 203 | would assert _SM100_KERNELS_AVAILABLE on NPU, so route explicitly to the | 203 | would assert _SM100_KERNELS_AVAILABLE on NPU, so route explicitly to the |
| 204 | - torchao_npu CANN kernels. | 204 | + torchao_ascend CANN kernels. |
| 205 | """ | 205 | """ |
| 206 | def builder(alignment_size: int) -> Callable: | 206 | def builder(alignment_size: int) -> Callable: |
| 207 | cfg = MXFP8TrainingOpConfig.from_recipe(recipe_enum) | 207 | cfg = MXFP8TrainingOpConfig.from_recipe(recipe_enum) |
| @@ -72,8 +72,8 @@ TND 的 Q、K、打分系数形状分别为 `[Tq, Nq, 128]`、`[Tk, 1, 128]`、` | |||
| 72 | ```python | 72 | ```python |
| 73 | import torch | 73 | import torch |
| 74 | from torchao.quantization import quantize_ | 74 | from torchao.quantization import quantize_ |
| 75 | -from torchao_npu.features.inference.lightning_indexer import LightningIndexerMXFP4Config | 75 | +from torchao_ascend.features.inference.lightning_indexer import LightningIndexerMXFP4Config |
| 76 | -from torchao_npu.features.qat.lightning_indexer import ( | 76 | +from torchao_ascend.features.qat.lightning_indexer import ( |
| 77 | LightningIndexerQATConfig, | 77 | LightningIndexerQATConfig, |
| 78 | lightning_indexer_filter, | 78 | lightning_indexer_filter, |
| 79 | ) | 79 | ) |
| @@ -117,7 +117,7 @@ optimizer = torch.optim.AdamW(model.parameters(), lr=1e-4) | |||
| 117 | 先使用主注意力的 Q、K、掩码和缩放系数计算 teacher: | 117 | 先使用主注意力的 Q、K、掩码和缩放系数计算 teacher: |
| 118 | 118 | ||
| 119 | ```python | 119 | ```python |
| 120 | -from torchao_npu.features.qat.lightning_indexer import compute_indexer_attention_teacher | 120 | +from torchao_ascend.features.qat.lightning_indexer import compute_indexer_attention_teacher |
| 121 | 121 | ||
| 122 | optimizer.zero_grad(set_to_none=True) | 122 | optimizer.zero_grad(set_to_none=True) |
| 123 | indices, carrier = model.indexer(hidden_states, compressed_states, cmp_residual_key) | 123 | indices, carrier = model.indexer(hidden_states, compressed_states, cmp_residual_key) |
| @@ -151,7 +151,7 @@ with torch.no_grad(): | |||
| 151 | 随后通过 `indexer_teacher_loss` 将 teacher 接入反向传播,并完成参数更新: | 151 | 随后通过 `indexer_teacher_loss` 将 teacher 接入反向传播,并完成参数更新: |
| 152 | 152 | ||
| 153 | ```python | 153 | ```python |
| 154 | -from torchao_npu.features.qat.lightning_indexer import indexer_teacher_loss | 154 | +from torchao_ascend.features.qat.lightning_indexer import indexer_teacher_loss |
| 155 | 155 | ||
| 156 | aux_loss = indexer_teacher_loss( | 156 | aux_loss = indexer_teacher_loss( |
| 157 | carrier, teacher.unsqueeze(2), coefficient=1.0, softmax_scale=attention_scale | 157 | carrier, teacher.unsqueeze(2), coefficient=1.0, softmax_scale=attention_scale |
| @@ -198,7 +198,7 @@ with torch.no_grad(): | |||
| 198 | ```python | 198 | ```python |
| 199 | import torch | 199 | import torch |
| 200 | from torchao.quantization import quantize_ | 200 | from torchao.quantization import quantize_ |
| 201 | -from torchao_npu.features.inference.lightning_indexer import ( | 201 | +from torchao_ascend.features.inference.lightning_indexer import ( |
| 202 | LightningIndexerMXFP4Config, | 202 | LightningIndexerMXFP4Config, |
| 203 | LightningIndexerMXFP4ReplaceConfig, | 203 | LightningIndexerMXFP4ReplaceConfig, |
| 204 | lightning_indexer_filter, | 204 | lightning_indexer_filter, |
| @@ -237,9 +237,9 @@ with torch.no_grad(): | |||
| 237 | 237 | ||
| 238 | ```python | 238 | ```python |
| 239 | from torchao.quantization import FqnToConfig, quantize_ | 239 | from torchao.quantization import FqnToConfig, quantize_ |
| 240 | -from torchao_npu.features.inference.lightning_indexer import LightningIndexerMXFP4Config | 240 | +from torchao_ascend.features.inference.lightning_indexer import LightningIndexerMXFP4Config |
| 241 | -from torchao_npu.features.qat.lightning_indexer import LightningIndexerQATConfig | 241 | +from torchao_ascend.features.qat.lightning_indexer import LightningIndexerQATConfig |
| 242 | -from torchao_npu.features.qat.w4a8 import W4A8QATConfig | 242 | +from torchao_ascend.features.qat.w4a8 import W4A8QATConfig |
| 243 | 243 | ||
| 244 | indexer_config = LightningIndexerQATConfig( | 244 | indexer_config = LightningIndexerQATConfig( |
| 245 | indexer_config=LightningIndexerMXFP4Config( | 245 | indexer_config=LightningIndexerMXFP4Config( |
| @@ -50,7 +50,7 @@ optimizer step 边界的清理由注入方负责。 | |||
| 50 | ## 接口与参数 | 50 | ## 接口与参数 |
| 51 | 51 | ||
| 52 | ```python | 52 | ```python |
| 53 | -from torchao_npu.features.qat.w4a16 import ( | 53 | +from torchao_ascend.features.qat.w4a16 import ( |
| 54 | W4A16LinearConfig, # dense Linear 配置 | 54 | W4A16LinearConfig, # dense Linear 配置 |
| 55 | W4A16GMMConfig, # 融合 MoE 专家配置 | 55 | W4A16GMMConfig, # 融合 MoE 专家配置 |
| 56 | W4A16Linear, # 类交换后的 Linear 类型 | 56 | W4A16Linear, # 类交换后的 Linear 类型 |
| @@ -112,7 +112,7 @@ config = W4A16LinearConfig( | |||
| 112 | import torch | 112 | import torch |
| 113 | import torch_npu # noqa: F401 | 113 | import torch_npu # noqa: F401 |
| 114 | from torchao.quantization import quantize_ | 114 | from torchao.quantization import quantize_ |
| 115 | -from torchao_npu.features.qat.w4a16 import ( | 115 | +from torchao_ascend.features.qat.w4a16 import ( |
| 116 | W4A16GMM, | 116 | W4A16GMM, |
| 117 | W4A16GMMConfig, | 117 | W4A16GMMConfig, |
| 118 | W4A16Linear, | 118 | W4A16Linear, |
| @@ -167,7 +167,7 @@ fc1_out = w4a8_experts_forward( | |||
| 167 | ## LP-AG 低精度 all-gather | 167 | ## LP-AG 低精度 all-gather |
| 168 | 168 | ||
| 169 | `enable_lp_all_gather=True` 时,prepare 步骤把 BF16 master 权重包装为 | 169 | `enable_lp_all_gather=True` 时,prepare 步骤把 BF16 master 权重包装为 |
| 170 | -`PreQuantWeight`(复用 `torchao_npu.features.distributed` 的通用 LP-AG | 170 | +`PreQuantWeight`(复用 `torchao_ascend.features.distributed` 的通用 LP-AG |
| 171 | 基础设施,与 mxfp8 特性同源)。FSDP2 unshard 时经其原生的 | 171 | 基础设施,与 mxfp8 特性同源)。FSDP2 unshard 时经其原生的 |
| 172 | `fsdp_pre_all_gather` / `fsdp_post_all_gather` 子类协议: | 172 | `fsdp_pre_all_gather` / `fsdp_post_all_gather` 子类协议: |
| 173 | 173 | ||
| @@ -191,7 +191,7 @@ config 字段(由训练框架在 `quantize_` 前注入,镜像 | |||
| 191 | | `_recompute_aware` | 框架置 True 时启用重算感知的权重相位机(与 activation checkpointing 配合) | | 191 | | `_recompute_aware` | 框架置 True 时启用重算感知的权重相位机(与 activation checkpointing 配合) | |
| 192 | 192 | ||
| 193 | 注意:backward 解析活权重要求调用链传入 `weight_owner` / | 193 | 注意:backward 解析活权重要求调用链传入 `weight_owner` / |
| 194 | -`weight_attr`——torchao_npu 自身的三条调用路径(容器 forward 本地路径、 | 194 | +`weight_attr`——torchao-ascend 自身的三条调用路径(容器 forward 本地路径、 |
| 195 | 继承的 `_ep_forward`、`w4a8_experts_forward`)均已传入;框架自定义 dispatcher | 195 | 继承的 `_ep_forward`、`w4a8_experts_forward`)均已传入;框架自定义 dispatcher |
| 196 | 直接调用 `w4a8_grouped_mm` 时须显式传递,否则 LP-AG 反向 fail-closed 报错。 | 196 | 直接调用 `w4a8_grouped_mm` 时须显式传递,否则 LP-AG 反向 fail-closed 报错。 |
| 197 | 197 | ||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | ## 版本说明 | 11 | ## 版本说明 |
| 12 | 12 | ||
| 13 | -本清单对应 torchao 0.18.0 版本,适配 PyTorch ≥ 2.11.0 且 TorchNPU ≥ 2.11.0,并确保 PyTorch、TorchNPU 与 CANN 版本配套。torchao-ascend 通过 monkey-patcher 方案在 NPU 后端适配 torchao 原生接口,底层 kernel 调用经 `torchao_npu.ops.npu` 转发至 `torch_npu` / `cann_ops_nn` 低精度内核。 | 13 | +本清单对应 torchao 0.18.0 版本,适配 PyTorch ≥ 2.11.0 且 TorchNPU ≥ 2.11.0,并确保 PyTorch、TorchNPU 与 CANN 版本配套。torchao-ascend 通过 monkey-patcher 方案在 NPU 后端适配 torchao 原生接口,底层 kernel 调用经 `torchao_ascend.ops.npu` 转发至 `torch_npu` / `cann_ops_nn` 低精度内核。 |
| 14 | 14 | ||
| 15 | 版本变更依据:[torchao 0.18.0 发布说明](https://github.com/pytorch/ao/releases)。 | 15 | 版本变更依据:[torchao 0.18.0 发布说明](https://github.com/pytorch/ao/releases)。 |
| 16 | 16 | ||
Rdocs/zh/api/environment_variable/auto_activation/TORCHAO_NPU_AUTO_ACTIVATE.md→docs/zh/api/environment_variable/auto_activation/TORCHAO_ASCEND_AUTO_ACTIVATE.md+6-6
| @@ -2,22 +2,22 @@ | |||
| 2 | 2 | ||
| 3 | ## 功能描述 | 3 | ## 功能描述 |
| 4 | 4 | ||
| 5 | -通过此环境变量可控制是否关闭TorchAONPU的自动激活功能。 | 5 | +通过此环境变量可控制是否关闭TorchAO-Ascend的自动激活功能。 |
| 6 | 6 | ||
| 7 | -TorchAONPU复用PyTorch的device-backend自动加载通道(与TorchNPU使用的通道相同):NPU环境下,用户`import torch`后首次`import torchao`时,TorchAONPU自动完成激活(注册`quantize_`处理器、加载HiFloat8/W4A8等NPU原生能力),无需显式`import torchao_npu`。 | 7 | +TorchAO-Ascend复用PyTorch的device-backend自动加载通道(与TorchNPU使用的通道相同):NPU环境下,用户`import torch`后首次`import torchao`时,TorchAO-Ascend自动完成激活(注册`quantize_`处理器、加载HiFloat8/W4A8等NPU原生能力),无需显式`import torchao_ascend`。 |
| 8 | 8 | ||
| 9 | -通过此环境变量可在保留其他设备后端自动加载的前提下,单独关闭TorchAONPU的自动激活。设置为“0”时关闭自动激活,设置为“1”或未设置时开启。默认配置为1。 | 9 | +通过此环境变量可在保留其他设备后端自动加载的前提下,单独关闭TorchAO-Ascend的自动激活。设置为“0”时关闭自动激活,设置为“1”或未设置时开启。默认配置为1。 |
| 10 | 10 | ||
| 11 | ## 配置示例 | 11 | ## 配置示例 |
| 12 | 12 | ||
| 13 | ```bash | 13 | ```bash |
| 14 | -export TORCHAO_NPU_AUTO_ACTIVATE=0 | 14 | +export TORCHAO_ASCEND_AUTO_ACTIVATE=0 |
| 15 | ``` | 15 | ``` |
| 16 | 16 | ||
| 17 | ## 使用约束 | 17 | ## 使用约束 |
| 18 | 18 | ||
| 19 | -- 该环境变量需在`import torch`之前设置。TorchAONPU的自动加载入口在`import torch`结束时执行,之后再设置对当前进程不生效。 | 19 | +- 该环境变量需在`import torch`之前设置。TorchAO-Ascend的自动加载入口在`import torch`结束时执行,之后再设置对当前进程不生效。 |
| 20 | -- 该环境变量仅关闭自动激活路径。显式`import torchao_npu`和显式调用`torchao_npu.activate()`的用法不受影响,行为与原有版本完全一致。 | 20 | +- 该环境变量仅关闭自动激活路径。显式`import torchao_ascend`和显式调用`torchao_ascend.activate()`的用法不受影响,行为与原有版本完全一致。 |
| 21 | - 自动激活全程防御式执行:任何激活失败仅产生`RuntimeWarning`告警并降级,不会中断`import torch`或`import torchao`。 | 21 | - 自动激活全程防御式执行:任何激活失败仅产生`RuntimeWarning`告警并降级,不会中断`import torch`或`import torchao`。 |
| 22 | 22 | ||
| 23 | ## 支持的型号 | 23 | ## 支持的型号 |
| @@ -1,9 +1,9 @@ | |||
| 1 | # 环境变量列表 | 1 | # 环境变量列表 |
| 2 | 2 | ||
| 3 | -本手册描述开发者在TorchAONPU训练和在线推理过程中可使用的环境变量。PyTorch引入的环境变量(如`TORCH_DEVICE_BACKEND_AUTOLOAD`)不在本手册范围内,以[PyTorch官方文档](https://docs.pytorch.org/docs/stable/miscellaneous_environment_variables.html)为准。 | 3 | +本手册描述开发者在TorchAO-Ascend训练和在线推理过程中可使用的环境变量。PyTorch引入的环境变量(如`TORCH_DEVICE_BACKEND_AUTOLOAD`)不在本手册范围内,以[PyTorch官方文档](https://docs.pytorch.org/docs/stable/miscellaneous_environment_variables.html)为准。 |
| 4 | 4 | ||
| 5 | **表 1** 自动激活环境变量列表 | 5 | **表 1** 自动激活环境变量列表 |
| 6 | 6 | ||
| 7 | |环境变量名称|简介| | 7 | |环境变量名称|简介| |
| 8 | |--|--| | 8 | |--|--| |
| 9 | -|[TORCHAO_NPU_AUTO_ACTIVATE](auto_activation/TORCHAO_NPU_AUTO_ACTIVATE.md)|通过此环境变量可单独关闭TorchAONPU的自动激活,不影响TorchNPU等其他后端,显式`import torchao_npu`用法不受影响。默认开启。| | 9 | +|[TORCHAO_ASCEND_AUTO_ACTIVATE](auto_activation/TORCHAO_ASCEND_AUTO_ACTIVATE.md)|通过此环境变量可单独关闭TorchAO-Ascend的自动激活,不影响TorchNPU等其他后端,显式`import torchao_ascend`用法不受影响。默认开启。| |
| @@ -15,7 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | - **量化目标**:仅支持**融合布局 MoE 专家**——`gate_up_proj [E, K, 2N]` 与 `down_proj [E, N, K]`;dense `nn.Linear` 不支持,布局失配会响亮报错(防止静默漏量)。激活函数(SiLU/GLU 等)经 `glu_activation()` 或自定义 callable 传入。 | 16 | - **量化目标**:仅支持**融合布局 MoE 专家**——`gate_up_proj [E, K, 2N]` 与 `down_proj [E, N, K]`;dense `nn.Linear` 不支持,布局失配会响亮报错(防止静默漏量)。激活函数(SiLU/GLU 等)经 `glu_activation()` 或自定义 callable 传入。 |
| 17 | - **配置项**:`W4A8QATConfig(block_size=32/128, quantize_weights=True, step="prepare"/"convert")`。 | 17 | - **配置项**:`W4A8QATConfig(block_size=32/128, quantize_weights=True, step="prepare"/"convert")`。 |
| 18 | -- **注入机制**:`prepare` 将 `_w4a8_moe_forward` 以 `MethodType` 挂到模块实例的 `forward` 上(`torchao_npu/features/qat/w4a8/moe_qat.py`)。不替换模块对象、不动参数对象,与 FSDP2/FSDPTurbo 的参数切分和状态管理零冲突。 | 18 | +- **注入机制**:`prepare` 将 `_w4a8_moe_forward` 以 `MethodType` 挂到模块实例的 `forward` 上(`torchao_ascend/features/qat/w4a8/moe_qat.py`)。不替换模块对象、不动参数对象,与 FSDP2/FSDPTurbo 的参数切分和状态管理零冲突。 |
| 19 | - **生命周期**: | 19 | - **生命周期**: |
| 20 | - `step="prepare"`:幂等;patch forward,进入在线量化训练态(BF16 master + 权重逐次量化到 MXFP4 网格 + 激活动态 MXFP8); | 20 | - `step="prepare"`:幂等;patch forward,进入在线量化训练态(BF16 master + 权重逐次量化到 MXFP4 网格 + 激活动态 MXFP8); |
| 21 | - `step="convert"`:恢复原 forward、移除 QAT 属性、master 权重固化落格并冻结;**对未 prepare 的模块原样返回(no-op)**——因此 PTQ 场景必须先 prepare 再立即 convert; | 21 | - `step="convert"`:恢复原 forward、移除 QAT 属性、master 权重固化落格并冻结;**对未 prepare 的模块原样返回(no-op)**——因此 PTQ 场景必须先 prepare 再立即 convert; |
| @@ -19,7 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | ### HiFloat8(HIF8) | 20 | ### HiFloat8(HIF8) |
| 21 | 21 | ||
| 22 | -- **模块层**:仅支持 `torch.nn.Linear`,模块被替换为 `HiFloat8Linear`(`torchao_npu/features/training/hifloat8/hifloat8_linear.py`)。 | 22 | +- **模块层**:仅支持 `torch.nn.Linear`,模块被替换为 `HiFloat8Linear`(`torchao_ascend/features/training/hifloat8/hifloat8_linear.py`)。 |
| 23 | - **算子层**:前向 / dgrad / wgrad 三个 GEMM 统一走 `_HiFloat8MM` autograd Function,内核为 `npu_quant_matmul` + `npu_dynamic_quant`(per-tensor)。 | 23 | - **算子层**:前向 / dgrad / wgrad 三个 GEMM 统一走 `_HiFloat8MM` autograd Function,内核为 `npu_quant_matmul` + `npu_dynamic_quant`(per-tensor)。 |
| 24 | - **入口**:`quantize_(model, HiFloat8LinearConfig(), filter_fn=...)`,函数式 `hifloat8_linear`。 | 24 | - **入口**:`quantize_(model, HiFloat8LinearConfig(), filter_fn=...)`,函数式 `hifloat8_linear`。 |
| 25 | - **限制**:仅 per-tensor 缩放,无 CPU 回退;不支持 conv / bmm / grouped mm。aten 算子级拦截(`hifloat8_tensor.py`)属推理路径,不覆盖训练。 | 25 | - **限制**:仅 per-tensor 缩放,无 CPU 回退;不支持 conv / bmm / grouped mm。aten 算子级拦截(`hifloat8_tensor.py`)属推理路径,不覆盖训练。 |
| @@ -43,7 +43,7 @@ | |||
| 43 | ### MXFP8 / MX 系列(含 W8A8、W4A8 变体) | 43 | ### MXFP8 / MX 系列(含 W8A8、W4A8 变体) |
| 44 | 44 | ||
| 45 | - **dense Linear**:`MXFP8LinearConfig` handler **就地 patch module.forward**(不替换模块类、不动参数对象),内部调上游 `mx_mm`,其 forward/backward 已在 NPU 侧重绑定(plain 路径 `torch._scaled_mm`,lp_ag / jit_quant 路径 `mx_quant_matmul`)。约束:block_size=32、缩放 AUTO、舍入 FLOOR/RCEIL;任一维度 <64 的 Linear 自动跳过(`filters.py`)。 | 45 | - **dense Linear**:`MXFP8LinearConfig` handler **就地 patch module.forward**(不替换模块类、不动参数对象),内部调上游 `mx_mm`,其 forward/backward 已在 NPU 侧重绑定(plain 路径 `torch._scaled_mm`,lp_ag / jit_quant 路径 `mx_quant_matmul`)。约束:block_size=32、缩放 AUTO、舍入 FLOOR/RCEIL;任一维度 <64 的 Linear 自动跳过(`filters.py`)。 |
| 46 | -- **MoE 专家**:`MXFP8GMMConfig` 将 MoE 专家容器**模块替换**为 `MXFP8GMM`(permute → grouped GMM → swiglu → grouped GMM → unpermute),可微内核 `MxGroupedMatmul` 的 dgrad / wgrad 均为真低精 grouped GEMM(`torchao_npu/features/training/mxfp8/`)。 | 46 | +- **MoE 专家**:`MXFP8GMMConfig` 将 MoE 专家容器**模块替换**为 `MXFP8GMM`(permute → grouped GMM → swiglu → grouped GMM → unpermute),可微内核 `MxGroupedMatmul` 的 dgrad / wgrad 均为真低精 grouped GEMM(`torchao_ascend/features/training/mxfp8/`)。 |
| 47 | - **变体**: | 47 | - **变体**: |
| 48 | - `quant_format="W4A8"`:权重先量化到 MXFP4,再经 `mx_to_block_mx_quant` 无损重缩放为 FP8 载荷复用 FP8 GEMM(dense / LP-AG / MoE GMM 三条路径均支持); | 48 | - `quant_format="W4A8"`:权重先量化到 MXFP4,再经 `mx_to_block_mx_quant` 无损重缩放为 FP8 载荷复用 FP8 GEMM(dense / LP-AG / MoE GMM 三条路径均支持); |
| 49 | - E4M3 / HYBRID / HIF8 格式即 W8A8 训练形态。 | 49 | - E4M3 / HYBRID / HIF8 格式即 W8A8 训练形态。 |
| @@ -37,8 +37,8 @@ from torchao.quantization import quantize_ | |||
| 37 | from torchao.quantization.granularity import PerRow | 37 | from torchao.quantization.granularity import PerRow |
| 38 | from torchao.quantization.quantize_.workflows.float8.float8_tensor import Float8Tensor | 38 | from torchao.quantization.quantize_.workflows.float8.float8_tensor import Float8Tensor |
| 39 | 39 | ||
| 40 | -from torchao_npu.features.training.mxfp8 import MXFP8LinearConfig | 40 | +from torchao_ascend.features.training.mxfp8 import MXFP8LinearConfig |
| 41 | -from torchao_npu.serialization import load_safetensors, save_safetensors | 41 | +from torchao_ascend.serialization import load_safetensors, save_safetensors |
| 42 | 42 | ||
| 43 | TEST_NPU = torch.npu.is_available() | 43 | TEST_NPU = torch.npu.is_available() |
| 44 | 44 | ||
| @@ -10,7 +10,7 @@ | |||
| 10 | int8_static(激活固定逐 token scale,需 calib 段,逐层 + 逐 token 校准) | 10 | int8_static(激活固定逐 token scale,需 calib 段,逐层 + 逐 token 校准) |
| 11 | ② quantize_:一次性将 Linear 权重替换为量化张量(模块类与 state_dict | 11 | ② quantize_:一次性将 Linear 权重替换为量化张量(模块类与 state_dict |
| 12 | 键不变,只换 Parameter.data) | 12 | 键不变,只换 Parameter.data) |
| 13 | - ③ 前向:INT8 计算经 torchao_npu 的 intmm patch 走 NPU 量化 GEMM | 13 | + ③ 前向:INT8 计算经 torchao_ascend 的 intmm patch 走 NPU 量化 GEMM |
| 14 | ④ 评估:与 bf16 基线对比 loss/ppl、logits 余弦相似度、吞吐与显存 | 14 | ④ 评估:与 bf16 基线对比 loss/ppl、logits 余弦相似度、吞吐与显存 |
| 15 | ⑤ 保存(可选):量化后 state_dict 可直接 torch.save(NPU 栈默认 copy_ | 15 | ⑤ 保存(可选):量化后 state_dict 可直接 torch.save(NPU 栈默认 copy_ |
| 16 | 加载对量化子类受限,恢复时建议 load_state_dict(..., assign=True)) | 16 | 加载对量化子类受限,恢复时建议 load_state_dict(..., assign=True)) |
| @@ -53,7 +53,7 @@ from torchao.quantization import ( | |||
| 53 | ) | 53 | ) |
| 54 | from torchao.quantization.quantize_.workflows.int8.int8_tensor import Int8Tensor | 54 | from torchao.quantization.quantize_.workflows.int8.int8_tensor import Int8Tensor |
| 55 | 55 | ||
| 56 | -import torchao_npu # noqa: F401 -- import 即生效 intmm 等 NPU patch | 56 | +import torchao_ascend # noqa: F401 -- import 即生效 intmm 等 NPU patch |
| 57 | 57 | ||
| 58 | logger = logging.getLogger(__name__) | 58 | logger = logging.getLogger(__name__) |
| 59 | 59 | ||
| @@ -17,7 +17,7 @@ QAT(量化感知训练)与推理场景(一次性 quantize_ + 在线前向 | |||
| 17 | ② train:小步数真实训练更新 BF16 master 权重(训练语料 _TRAIN_TEXT 与评估 | 17 | ② train:小步数真实训练更新 BF16 master 权重(训练语料 _TRAIN_TEXT 与评估 |
| 18 | 语料 _EVAL_TEXT 分离,自包含无外部数据依赖); | 18 | 语料 _EVAL_TEXT 分离,自包含无外部数据依赖); |
| 19 | ③ convert:``step="convert"`` —— FakeQuantizedLinear 换回真量化权重 | 19 | ③ convert:``step="convert"`` —— FakeQuantizedLinear 换回真量化权重 |
| 20 | - (IntxUnpackedToInt8Tensor),推理经 torchao_npu 的 intmm patch 走 | 20 | + (IntxUnpackedToInt8Tensor),推理经 torchao_ascend 的 intmm patch 走 |
| 21 | NPU 量化 GEMM。 | 21 | NPU 量化 GEMM。 |
| 22 | 22 | ||
| 23 | 评估口径(对照 prepare 前的 bf16 基线): | 23 | 评估口径(对照 prepare 前的 bf16 基线): |
| @@ -51,7 +51,7 @@ from torchao.quantization import quantize_ | |||
| 51 | from torchao.quantization.qat import QATConfig | 51 | from torchao.quantization.qat import QATConfig |
| 52 | from torchao.quantization.quant_api import Int8DynamicActivationIntxWeightConfig | 52 | from torchao.quantization.quant_api import Int8DynamicActivationIntxWeightConfig |
| 53 | 53 | ||
| 54 | -import torchao_npu # noqa: F401 -- import 即生效 intmm 等 NPU patch | 54 | +import torchao_ascend # noqa: F401 -- import 即生效 intmm 等 NPU patch |
| 55 | 55 | ||
| 56 | logger = logging.getLogger(__name__) | 56 | logger = logging.getLogger(__name__) |
| 57 | 57 | ||
| @@ -39,7 +39,7 @@ from pathlib import Path | |||
| 39 | 39 | ||
| 40 | import torch | 40 | import torch |
| 41 | import torch_npu # noqa: F401 -- register the NPU backend | 41 | import torch_npu # noqa: F401 -- register the NPU backend |
| 42 | -import torchao_npu # noqa: F401 -- import 即生效 intmm 等 NPU patch | 42 | +import torchao_ascend # noqa: F401 -- import 即生效 intmm 等 NPU patch |
| 43 | import yaml | 43 | import yaml |
| 44 | from torch import nn | 44 | from torch import nn |
| 45 | from transformers import AutoModelForCausalLM, AutoTokenizer | 45 | from transformers import AutoModelForCausalLM, AutoTokenizer |
| @@ -52,7 +52,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer | |||
| 52 | from torchao.quantization import IntxWeightOnlyConfig, PerGroup, quantize_ | 52 | from torchao.quantization import IntxWeightOnlyConfig, PerGroup, quantize_ |
| 53 | from torchao.quantization.qat import QATConfig | 53 | from torchao.quantization.qat import QATConfig |
| 54 | 54 | ||
| 55 | -import torchao_npu # noqa: F401 -- import 即生效 NPU patch | 55 | +import torchao_ascend # noqa: F401 -- import 即生效 NPU patch |
| 56 | 56 | ||
| 57 | logger = logging.getLogger(__name__) | 57 | logger = logging.getLogger(__name__) |
| 58 | 58 | ||
| @@ -61,7 +61,7 @@ from pathlib import Path | |||
| 61 | 61 | ||
| 62 | import torch | 62 | import torch |
| 63 | import torch_npu # noqa: F401 -- register the NPU backend | 63 | import torch_npu # noqa: F401 -- register the NPU backend |
| 64 | -import torchao_npu # noqa: F401 -- import 即生效 NPU patch | 64 | +import torchao_ascend # noqa: F401 -- import 即生效 NPU patch |
| 65 | import yaml | 65 | import yaml |
| 66 | from torch import nn | 66 | from torch import nn |
| 67 | from transformers import AutoModelForCausalLM, AutoTokenizer | 67 | from transformers import AutoModelForCausalLM, AutoTokenizer |
| @@ -61,7 +61,7 @@ from pathlib import Path | |||
| 61 | 61 | ||
| 62 | import torch | 62 | import torch |
| 63 | import torch_npu # noqa: F401 -- register the NPU backend | 63 | import torch_npu # noqa: F401 -- register the NPU backend |
| 64 | -import torchao_npu # noqa: F401 -- import 即生效 NPU patch | 64 | +import torchao_ascend # noqa: F401 -- import 即生效 NPU patch |
| 65 | import yaml | 65 | import yaml |
| 66 | from torch import nn | 66 | from torch import nn |
| 67 | from transformers import AutoModelForCausalLM, AutoTokenizer | 67 | from transformers import AutoModelForCausalLM, AutoTokenizer |
| @@ -278,7 +278,7 @@ def resolve_device(name: str) -> torch.device: | |||
| 278 | 278 | ||
| 279 | def main() -> None: | 279 | def main() -> None: |
| 280 | """读取配置并执行三阶段 QAT(prepare -> train -> convert)主流程。""" | 280 | """读取配置并执行三阶段 QAT(prepare -> train -> convert)主流程。""" |
| 281 | - parser = argparse.ArgumentParser(description="Qwen2.5 QAT(MXFP8, torchao NPU)") | 281 | + parser = argparse.ArgumentParser(description="Qwen2.5 QAT(MXFP8, torchao-ascend)") |
| 282 | parser.add_argument("--config", default="", | 282 | parser.add_argument("--config", default="", |
| 283 | help=f"配置文件路径(默认 {BASE_DIR / CONFIG_FILE})") | 283 | help=f"配置文件路径(默认 {BASE_DIR / CONFIG_FILE})") |
| 284 | parser.add_argument("--steps", type=int, default=None, | 284 | parser.add_argument("--steps", type=int, default=None, |
| @@ -60,7 +60,7 @@ from pathlib import Path | |||
| 60 | 60 | ||
| 61 | import torch | 61 | import torch |
| 62 | import torch_npu # noqa: F401 -- register the NPU backend | 62 | import torch_npu # noqa: F401 -- register the NPU backend |
| 63 | -import torchao_npu # noqa: F401 -- import 即生效 NPU patch | 63 | +import torchao_ascend # noqa: F401 -- import 即生效 NPU patch |
| 64 | import yaml | 64 | import yaml |
| 65 | from torch import nn | 65 | from torch import nn |
| 66 | from transformers import AutoModelForCausalLM, AutoTokenizer | 66 | from transformers import AutoModelForCausalLM, AutoTokenizer |
| @@ -3,7 +3,7 @@ | |||
| 3 | # qwen2.5-0.5B MXFP8 QAT Launch Script (prepare -> train -> convert) | 3 | # qwen2.5-0.5B MXFP8 QAT Launch Script (prepare -> train -> convert) |
| 4 | # ============================================================ | 4 | # ============================================================ |
| 5 | # dependency: torch, torch_npu, transformers, pandas, pyyaml | 5 | # dependency: torch, torch_npu, transformers, pandas, pyyaml |
| 6 | -# dependency: torchao, torchao_npu(安装方式见仓库 README) | 6 | +# dependency: torchao, torchao_ascend(安装方式见仓库 README) |
| 7 | # | 7 | # |
| 8 | # 用法: | 8 | # 用法: |
| 9 | # bash train.sh # 全部使用 qwen2_5_mxfp8_w8a8_qat_config.yaml 默认值 | 9 | # bash train.sh # 全部使用 qwen2_5_mxfp8_w8a8_qat_config.yaml 默认值 |
| @@ -48,7 +48,7 @@ def _grouped_experts_forward(self, hidden_states, top_k_index, top_k_weights, ** | |||
| 48 | 核心 ``torch._grouped_mm(input, weight.transpose(-2,-1), offs=cumsum_counts)`` | 48 | 核心 ``torch._grouped_mm(input, weight.transpose(-2,-1), offs=cumsum_counts)`` |
| 49 | 与 torchtitan 逐字相同——这正是 Float8TrainingOpConfig 的 wrapper __torch_function__ | 49 | 与 torchtitan 逐字相同——这正是 Float8TrainingOpConfig 的 wrapper __torch_function__ |
| 50 | 拦截的 op:BF16 走原生 grouped_mm,套 wrapper 后同一条调用自动路由到 | 50 | 拦截的 op:BF16 走原生 grouped_mm,套 wrapper 后同一条调用自动路由到 |
| 51 | - ``_to_fp8_rowwise_then_scaled_grouped_mm``(NPU 上经 torchao_npu patch 分派到 | 51 | + ``_to_fp8_rowwise_then_scaled_grouped_mm``(NPU 上经 torchao_ascend patch 分派到 |
| 52 | npu_dynamic_quant + npu_grouped_matmul)。 | 52 | npu_dynamic_quant + npu_grouped_matmul)。 |
| 53 | 53 | ||
| 54 | 与 torchtitan 的三处差异(均有明确出处,非自创): | 54 | 与 torchtitan 的三处差异(均有明确出处,非自创): |
| @@ -4,7 +4,7 @@ | |||
| 4 | """Qwen3.5-MoE 路由专家 FP8 rowwise 训练(Float8TrainingOpConfig,GMM 替换路径)。 | 4 | """Qwen3.5-MoE 路由专家 FP8 rowwise 训练(Float8TrainingOpConfig,GMM 替换路径)。 |
| 5 | 5 | ||
| 6 | quantize_ 把专家权重包成 Float8TrainingWeightWrapperTensor,前向 torch._grouped_mm 被 | 6 | quantize_ 把专家权重包成 Float8TrainingWeightWrapperTensor,前向 torch._grouped_mm 被 |
| 7 | -wrapper 拦截 -> FP8 grouped GEMM(NPU 上经 torchao_npu patch 分派到 npu_dynamic_quant + | 7 | +wrapper 拦截 -> FP8 grouped GEMM(NPU 上经 torchao_ascend patch 分派到 npu_dynamic_quant + |
| 8 | npu_grouped_matmul)。这是 GMM 替换路径,不是逐 Linear _scaled_mm。前向改写与 torchtitan | 8 | npu_grouped_matmul)。这是 GMM 替换路径,不是逐 Linear _scaled_mm。前向改写与 torchtitan |
| 9 | 权威实现的对照见 modeling_qwen3_5_moe.py 的 docstring。 | 9 | 权威实现的对照见 modeling_qwen3_5_moe.py 的 docstring。 |
| 10 | 10 | ||
| @@ -37,7 +37,7 @@ from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM | |||
| 37 | # NPU 分派:把 _to_fp8_rowwise_then_scaled_grouped_mm 重绑定到 npu_dynamic_quant + | 37 | # NPU 分派:把 _to_fp8_rowwise_then_scaled_grouped_mm 重绑定到 npu_dynamic_quant + |
| 38 | # npu_grouped_matmul(上游 triton 量化核在 triton-ascend 上 MLIRCompilationError)。 | 38 | # npu_grouped_matmul(上游 triton 量化核在 triton-ascend 上 MLIRCompilationError)。 |
| 39 | # GMM 路径不用 torch._scaled_mm,无需 base scaled_mm patch。 | 39 | # GMM 路径不用 torch._scaled_mm,无需 base scaled_mm patch。 |
| 40 | -from torchao_npu.patches.torchao.prototype.moe_training import fp8_grouped_mm as _fp8_gmm_patch | 40 | +from torchao_ascend.patches.torchao.prototype.moe_training import fp8_grouped_mm as _fp8_gmm_patch |
| 41 | _fp8_gmm_patch.apply() | 41 | _fp8_gmm_patch.apply() |
| 42 | 42 | ||
| 43 | from torchao.prototype.moe_training.config import Float8TrainingOpConfig, Float8TrainingRecipe | 43 | from torchao.prototype.moe_training.config import Float8TrainingOpConfig, Float8TrainingRecipe |
| @@ -157,7 +157,7 @@ def ensure_dataset(cfg: Config) -> tuple[Path, Path]: | |||
| 157 | 157 | ||
| 158 | # ---------------- FP8 配置 ---------------- | 158 | # ---------------- FP8 配置 ---------------- |
| 159 | # FP8 rowwise 训练 master 权重只接受 bfloat16。NPU 上 npu_dynamic_quant 只收 | 159 | # FP8 rowwise 训练 master 权重只接受 bfloat16。NPU 上 npu_dynamic_quant 只收 |
| 160 | -# fp16/bf16(fp32 直接 raise,见 torchao_npu fp8_grouped_mm patch _compute_fwd 的 | 160 | +# fp16/bf16(fp32 直接 raise,见 torchao_ascend fp8_grouped_mm patch _compute_fwd 的 |
| 161 | # A/B dtype assert);fp16 虽被该算子接受,但 NPU 注意力等算子对 fp16 支持不全/易溢出。 | 161 | # A/B dtype assert);fp16 虽被该算子接受,但 NPU 注意力等算子对 fp16 支持不全/易溢出。 |
| 162 | _HP_DTYPE_MAP = { | 162 | _HP_DTYPE_MAP = { |
| 163 | "bfloat16": torch.bfloat16, | 163 | "bfloat16": torch.bfloat16, |
| @@ -174,7 +174,7 @@ def self_check(fp8_cfg, device: torch.device, align: int) -> None: | |||
| 174 | """自检(不调用 grouped_mm,NPU/CPU 均可跑): | 174 | """自检(不调用 grouped_mm,NPU/CPU 均可跑): |
| 175 | (1) Float8TrainingOpConfig 经 _swap_params 把专家权重 .data 包成 wrapper | 175 | (1) Float8TrainingOpConfig 经 _swap_params 把专家权重 .data 包成 wrapper |
| 176 | (wrapper 才能拦截 torch._grouped_mm); | 176 | (wrapper 才能拦截 torch._grouped_mm); |
| 177 | - (2) torchao_npu fp8_grouped_mm patch 已把 _to_fp8_rowwise_then_scaled_grouped_mm | 177 | + (2) torchao_ascend fp8_grouped_mm patch 已把 _to_fp8_rowwise_then_scaled_grouped_mm |
| 178 | 重绑为 NPU 版(否则 NPU 上走上游 triton -> MLIRCompilationError)。 | 178 | 重绑为 NPU 版(否则 NPU 上走上游 triton -> MLIRCompilationError)。 |
| 179 | """ | 179 | """ |
| 180 | if fp8_cfg is None: | 180 | if fp8_cfg is None: |
| @@ -207,8 +207,8 @@ def self_check(fp8_cfg, device: torch.device, align: int) -> None: | |||
| 207 | if "wgrad_with_hp" not in inspect.getsource( | 207 | if "wgrad_with_hp" not in inspect.getsource( |
| 208 | _up_gmm._to_fp8_rowwise_then_scaled_grouped_mm): | 208 | _up_gmm._to_fp8_rowwise_then_scaled_grouped_mm): |
| 209 | raise RuntimeError( | 209 | raise RuntimeError( |
| 210 | - "torchao_npu fp8_grouped_mm patch 未生效:_to_fp8_rowwise_then_scaled_grouped_mm " | 210 | + "torchao_ascend fp8_grouped_mm patch 未生效:_to_fp8_rowwise_then_scaled_grouped_mm " |
| 211 | - "仍是上游 triton 版(NPU 上会 MLIRCompilationError)。确认 torchao_npu 已安装且 " | 211 | + "仍是上游 triton 版(NPU 上会 MLIRCompilationError)。确认 torchao_ascend 已安装且 " |
| 212 | "fp8_grouped_mm.apply() 已执行。") | 212 | "fp8_grouped_mm.apply() 已执行。") |
| 213 | logger.info(f"[check] wrapper + NPU fp8_grouped_mm patch 均生效(align={align})") | 213 | logger.info(f"[check] wrapper + NPU fp8_grouped_mm patch 均生效(align={align})") |
| 214 | 214 | ||
| @@ -320,7 +320,7 @@ def load_model(cfg: Config, hp_dtype: torch.dtype, device: torch.device): | |||
| 320 | 320 | ||
| 321 | def main() -> None: | 321 | def main() -> None: |
| 322 | """读取配置并执行:BF16 基线 -> FP8 量化 -> 训练 -> 评测。""" | 322 | """读取配置并执行:BF16 基线 -> FP8 量化 -> 训练 -> 评测。""" |
| 323 | - parser = argparse.ArgumentParser(description="Qwen3.5-MoE FP8 rowwise 训练(torchao NPU)") | 323 | + parser = argparse.ArgumentParser(description="Qwen3.5-MoE FP8 rowwise 训练(torchao-ascend)") |
| 324 | parser.add_argument("--config", default="", | 324 | parser.add_argument("--config", default="", |
| 325 | help=f"配置文件路径(默认 {BASE_DIR / CONFIG_FILE})") | 325 | help=f"配置文件路径(默认 {BASE_DIR / CONFIG_FILE})") |
| 326 | parser.add_argument("--steps", type=int, default=None, | 326 | parser.add_argument("--steps", type=int, default=None, |
| @@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"] | |||
| 3 | build-backend = "setuptools.build_meta" | 3 | build-backend = "setuptools.build_meta" |
| 4 | 4 | ||
| 5 | [project] | 5 | [project] |
| 6 | -name = "torchao_npu" | 6 | +name = "torchao-ascend" |
| 7 | version = "0.18.0" | 7 | version = "0.18.0" |
| 8 | description = "AscendNPU integration for torchao" | 8 | description = "AscendNPU integration for torchao" |
| 9 | readme = "README.md" | 9 | readme = "README.md" |
| @@ -36,18 +36,18 @@ Repository = "https://gitcode.com/Ascend/torchao-ascend" | |||
| 36 | 36 | ||
| 37 | # torch device-backend autoload channel (same channel torch_npu uses): | 37 | # torch device-backend autoload channel (same channel torch_npu uses): |
| 38 | # `import torch` calls bootstrap() at the end of its __init__, which installs | 38 | # `import torch` calls bootstrap() at the end of its __init__, which installs |
| 39 | -# a meta-path hook so torchao_npu activates automatically on NPU machines. | 39 | +# a meta-path hook so torchao_ascend activates automatically on NPU machines. |
| 40 | # The entry point MUST target a standalone top-level module, never the | 40 | # The entry point MUST target a standalone top-level module, never the |
| 41 | -# torchao_npu package itself (see _torchao_npu_autoload.py docstring). | 41 | +# torchao_ascend package itself (see _torchao_ascend_autoload.py docstring). |
| 42 | [project.entry-points."torch.backends"] | 42 | [project.entry-points."torch.backends"] |
| 43 | -torchao_npu = "_torchao_npu_autoload:bootstrap" | 43 | +torchao_ascend = "_torchao_ascend_autoload:bootstrap" |
| 44 | 44 | ||
| 45 | [tool.setuptools] | 45 | [tool.setuptools] |
| 46 | include-package-data = true | 46 | include-package-data = true |
| 47 | -py-modules = ["_torchao_npu_autoload"] | 47 | +py-modules = ["_torchao_ascend_autoload"] |
| 48 | 48 | ||
| 49 | [tool.setuptools.packages.find] | 49 | [tool.setuptools.packages.find] |
| 50 | -include = ["torchao_npu*"] | 50 | +include = ["torchao_ascend*"] |
| 51 | namespaces = true | 51 | namespaces = true |
| 52 | 52 | ||
| 53 | [tool.pytest.ini_options] | 53 | [tool.pytest.ini_options] |
| @@ -40,18 +40,18 @@ def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo[None]): | |||
| 40 | report = outcome.get_result() | 40 | report = outcome.get_result() |
| 41 | if report.when == "setup": | 41 | if report.when == "setup": |
| 42 | if report.failed: | 42 | if report.failed: |
| 43 | - item._torchao_npu_progress_outcome = "SETUP-FAILED" | 43 | + item._torchao_ascend_progress_outcome = "SETUP-FAILED" |
| 44 | elif report.skipped: | 44 | elif report.skipped: |
| 45 | - item._torchao_npu_progress_outcome = "SKIPPED" | 45 | + item._torchao_ascend_progress_outcome = "SKIPPED" |
| 46 | elif report.when == "call": | 46 | elif report.when == "call": |
| 47 | if report.passed: | 47 | if report.passed: |
| 48 | - item._torchao_npu_progress_outcome = "PASSED" | 48 | + item._torchao_ascend_progress_outcome = "PASSED" |
| 49 | elif report.failed: | 49 | elif report.failed: |
| 50 | - item._torchao_npu_progress_outcome = "FAILED" | 50 | + item._torchao_ascend_progress_outcome = "FAILED" |
| 51 | elif report.skipped: | 51 | elif report.skipped: |
| 52 | - item._torchao_npu_progress_outcome = "SKIPPED" | 52 | + item._torchao_ascend_progress_outcome = "SKIPPED" |
| 53 | elif report.when == "teardown" and report.failed: | 53 | elif report.when == "teardown" and report.failed: |
| 54 | - item._torchao_npu_progress_outcome = "TEARDOWN-FAILED" | 54 | + item._torchao_ascend_progress_outcome = "TEARDOWN-FAILED" |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | @pytest.hookimpl(hookwrapper=True) | 57 | @pytest.hookimpl(hookwrapper=True) |
| @@ -60,5 +60,5 @@ def pytest_runtest_protocol(item: pytest.Item, nextitem: pytest.Item | None): | |||
| 60 | _write_progress(item.config, f"[test] START {item.nodeid}") | 60 | _write_progress(item.config, f"[test] START {item.nodeid}") |
| 61 | yield | 61 | yield |
| 62 | elapsed = time.perf_counter() - start | 62 | elapsed = time.perf_counter() - start |
| 63 | - outcome = getattr(item, "_torchao_npu_progress_outcome", "UNKNOWN") | 63 | + outcome = getattr(item, "_torchao_ascend_progress_outcome", "UNKNOWN") |
| 64 | _write_progress(item.config, f"[test] END {item.nodeid} [{outcome}] {elapsed:.2f}s") | 64 | _write_progress(item.config, f"[test] END {item.nodeid} [{outcome}] {elapsed:.2f}s") |
| @@ -30,7 +30,7 @@ from torchao.prototype.moe_training.ep.kernels import ( | |||
| 30 | from torchao.prototype.mx_formats.mx_tensor import MXTensor | 30 | from torchao.prototype.mx_formats.mx_tensor import MXTensor |
| 31 | from torchao.float8.float8_utils import compute_error | 31 | from torchao.float8.float8_utils import compute_error |
| 32 | 32 | ||
| 33 | -import torchao_npu # noqa: F401 # trigger patch activation | 33 | +import torchao_ascend # noqa: F401 # trigger patch activation |
| 34 | 34 | ||
| 35 | DEVICE = "npu:0" | 35 | DEVICE = "npu:0" |
| 36 | BLOCK = 32 | 36 | BLOCK = 32 |
| @@ -66,10 +66,10 @@ class TestFp8GroupedMMNPU(TestCase): | |||
| 66 | def _apply_patches(): | 66 | def _apply_patches(): |
| 67 | # Isolated: only base (_scaled_mm ABI) + fp8_grouped_mm rebind — not | 67 | # Isolated: only base (_scaled_mm ABI) + fp8_grouped_mm rebind — not |
| 68 | # enable()-all, so unrelated patches can't mask the patch's grouped + dense paths. | 68 | # enable()-all, so unrelated patches can't mask the patch's grouped + dense paths. |
| 69 | - from torchao_npu.patches.torchao._base_patch import ( | 69 | + from torchao_ascend.patches.torchao._base_patch import ( |
| 70 | apply_scaled_mm_base_patch, | 70 | apply_scaled_mm_base_patch, |
| 71 | ) | 71 | ) |
| 72 | - from torchao_npu.patches.torchao.prototype.moe_training import ( | 72 | + from torchao_ascend.patches.torchao.prototype.moe_training import ( |
| 73 | fp8_grouped_mm as patch_mod, | 73 | fp8_grouped_mm as patch_mod, |
| 74 | ) | 74 | ) |
| 75 | 75 | ||
| @@ -62,7 +62,7 @@ from torchao.prototype.moe_training.mxfp8_grouped_mm import ( # noqa: E402 | |||
| 62 | from torchao.prototype.moe_training.utils import generate_jagged_offs # noqa: E402 | 62 | from torchao.prototype.moe_training.utils import generate_jagged_offs # noqa: E402 |
| 63 | from torchao.prototype.mx_formats.mx_tensor import MXTensor # noqa: E402 | 63 | from torchao.prototype.mx_formats.mx_tensor import MXTensor # noqa: E402 |
| 64 | 64 | ||
| 65 | -import torchao_npu # noqa: F401,E402 # trigger patch activation | 65 | +import torchao_ascend # noqa: F401,E402 # trigger patch activation |
| 66 | 66 | ||
| 67 | # to_mx is replaced in place by the patch: bind through the module object | 67 | # to_mx is replaced in place by the patch: bind through the module object |
| 68 | # AFTER activation so the NPU path is picked up (an early ``from`` import | 68 | # AFTER activation so the NPU path is picked up (an early ``from`` import |
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | 覆盖工作流(量化推理路线): | 6 | 覆盖工作流(量化推理路线): |
| 7 | - 动态:``quantize_(Int8DynamicActivationInt8WeightConfig)`` → INT8 计算 | 7 | - 动态:``quantize_(Int8DynamicActivationInt8WeightConfig)`` → INT8 计算 |
| 8 | - (经 torchao_npu intmm patch 路由 NPU 量化 GEMM)→ 保存恢复/切片/Tensor 操作; | 8 | + (经 torchao_ascend intmm patch 路由 NPU 量化 GEMM)→ 保存恢复/切片/Tensor 操作; |
| 9 | - 静态:两段式校准(上游标准范式)→ 固定激活 qparams → 推理(静态性证明); | 9 | - 静态:两段式校准(上游标准范式)→ 固定激活 qparams → 推理(静态性证明); |
| 10 | - 跨场景闭环:多层选层、intmm patch 注册守护(int8/intx GEMM 防 CPU 回退)、 | 10 | - 跨场景闭环:多层选层、intmm patch 注册守护(int8/intx GEMM 防 CPU 回退)、 |
| 11 | torch.compile parity(环境门控); | 11 | torch.compile parity(环境门控); |
| @@ -22,7 +22,7 @@ import torch | |||
| 22 | from torch.testing._internal import common_utils | 22 | from torch.testing._internal import common_utils |
| 23 | 23 | ||
| 24 | try: | 24 | try: |
| 25 | - import torchao_npu # noqa: F401 -- 必须先于 torchao 使用,激活 NPU 后端 patch | 25 | + import torchao_ascend # noqa: F401 -- 必须先于 torchao 使用,激活 NPU 后端 patch |
| 26 | _NPU_BACKEND_READY = True | 26 | _NPU_BACKEND_READY = True |
| 27 | except Exception: # noqa: BLE001 -- 非 NPU 环境允许收集,由 skipIf 统一跳过 | 27 | except Exception: # noqa: BLE001 -- 非 NPU 环境允许收集,由 skipIf 统一跳过 |
| 28 | _NPU_BACKEND_READY = False | 28 | _NPU_BACKEND_READY = False |
| @@ -157,7 +157,7 @@ def _assert_weight_slice_dequant(test, config): | |||
| 157 | 157 | ||
| 158 | @unittest.skipIf( | 158 | @unittest.skipIf( |
| 159 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), | 159 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), |
| 160 | - "Need torchao_npu backend and an available accelerator", | 160 | + "Need torchao_ascend backend and an available accelerator", |
| 161 | ) | 161 | ) |
| 162 | @common_utils.instantiate_parametrized_tests | 162 | @common_utils.instantiate_parametrized_tests |
| 163 | class TestInt8DynamicQuantInference(TorchAOIntegrationTestCase): | 163 | class TestInt8DynamicQuantInference(TorchAOIntegrationTestCase): |
| @@ -251,7 +251,7 @@ class TestInt8DynamicQuantInference(TorchAOIntegrationTestCase): | |||
| 251 | 251 | ||
| 252 | @unittest.skipIf( | 252 | @unittest.skipIf( |
| 253 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), | 253 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), |
| 254 | - "Need torchao_npu backend and an available accelerator", | 254 | + "Need torchao_ascend backend and an available accelerator", |
| 255 | ) | 255 | ) |
| 256 | @common_utils.instantiate_parametrized_tests | 256 | @common_utils.instantiate_parametrized_tests |
| 257 | class TestInt8StaticQuantInference(common_utils.TestCase): | 257 | class TestInt8StaticQuantInference(common_utils.TestCase): |
| @@ -348,7 +348,7 @@ class TestInt8StaticQuantInference(common_utils.TestCase): | |||
| 348 | 348 | ||
| 349 | @unittest.skipIf( | 349 | @unittest.skipIf( |
| 350 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), | 350 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), |
| 351 | - "Need torchao_npu backend and an available accelerator", | 351 | + "Need torchao_ascend backend and an available accelerator", |
| 352 | ) | 352 | ) |
| 353 | class TestInt8ScenarioClosure(common_utils.TestCase): | 353 | class TestInt8ScenarioClosure(common_utils.TestCase): |
| 354 | """int8 场景闭环:多层选层 / intmm patch 注册守护 / torch.compile parity。""" | 354 | """int8 场景闭环:多层选层 / intmm patch 注册守护 / torch.compile parity。""" |
| @@ -372,21 +372,21 @@ class TestInt8ScenarioClosure(common_utils.TestCase): | |||
| 372 | """int8/intx GEMM 必须经 NPU 量化 GEMM 路由(防静默 CPU 回归)。 | 372 | """int8/intx GEMM 必须经 NPU 量化 GEMM 路由(防静默 CPU 回归)。 |
| 373 | 373 | ||
| 374 | 上游 ``int_scaled_matmul`` 在 NPU 上静默回退 CPU(``aten::_int_mm`` 无 | 374 | 上游 ``int_scaled_matmul`` 在 NPU 上静默回退 CPU(``aten::_int_mm`` 无 |
| 375 | - NPU 实现,实测量化 Linear 远慢于 bf16);本断言确保 torchao_npu 的 | 375 | + NPU 实现,实测量化 Linear 远慢于 bf16);本断言确保 torchao_ascend 的 |
| 376 | intmm patch 已注册生效,守护 int8 量化推理与 intx QAT convert 两条路径。 | 376 | intmm patch 已注册生效,守护 int8 量化推理与 intx QAT convert 两条路径。 |
| 377 | """ | 377 | """ |
| 378 | from torchao.kernel import intmm as intmm_mod | 378 | from torchao.kernel import intmm as intmm_mod |
| 379 | 379 | ||
| 380 | self.assertTrue( | 380 | self.assertTrue( |
| 381 | - getattr(intmm_mod.int_scaled_matmul, "_torchao_npu_patch", False), | 381 | + getattr(intmm_mod.int_scaled_matmul, "_torchao_ascend_patch", False), |
| 382 | - "torchao_npu intmm patch is not registered: int8/intx GEMM would " | 382 | + "torchao_ascend intmm patch is not registered: int8/intx GEMM would " |
| 383 | "silently fall back to CPU", | 383 | "silently fall back to CPU", |
| 384 | ) | 384 | ) |
| 385 | 385 | ||
| 386 | 386 | ||
| 387 | @unittest.skipIf( | 387 | @unittest.skipIf( |
| 388 | not (_NPU_BACKEND_READY and torch.accelerator.is_available() and _qwen_configs_ready()), | 388 | not (_NPU_BACKEND_READY and torch.accelerator.is_available() and _qwen_configs_ready()), |
| 389 | - "Need torchao_npu backend, an accelerator and Qwen config.json files", | 389 | + "Need torchao_ascend backend, an accelerator and Qwen config.json files", |
| 390 | ) | 390 | ) |
| 391 | @common_utils.instantiate_parametrized_tests | 391 | @common_utils.instantiate_parametrized_tests |
| 392 | class TestQwenRealShapeInt8(common_utils.TestCase): | 392 | class TestQwenRealShapeInt8(common_utils.TestCase): |
| @@ -23,7 +23,7 @@ import torch | |||
| 23 | from torch.testing._internal import common_utils | 23 | from torch.testing._internal import common_utils |
| 24 | 24 | ||
| 25 | try: | 25 | try: |
| 26 | - import torchao_npu # noqa: F401 -- 必须先于 torchao 使用,激活 NPU 后端 patch | 26 | + import torchao_ascend # noqa: F401 -- 必须先于 torchao 使用,激活 NPU 后端 patch |
| 27 | _NPU_BACKEND_READY = True | 27 | _NPU_BACKEND_READY = True |
| 28 | except Exception: # noqa: BLE001 -- 非 NPU 环境允许收集,由 skipIf 统一跳过 | 28 | except Exception: # noqa: BLE001 -- 非 NPU 环境允许收集,由 skipIf 统一跳过 |
| 29 | _NPU_BACKEND_READY = False | 29 | _NPU_BACKEND_READY = False |
| @@ -151,7 +151,7 @@ def _assert_weight_slice_dequant(test, config): | |||
| 151 | 151 | ||
| 152 | @unittest.skipIf( | 152 | @unittest.skipIf( |
| 153 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), | 153 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), |
| 154 | - "Need torchao_npu backend and an available accelerator", | 154 | + "Need torchao_ascend backend and an available accelerator", |
| 155 | ) | 155 | ) |
| 156 | @common_utils.instantiate_parametrized_tests | 156 | @common_utils.instantiate_parametrized_tests |
| 157 | class TestIntxWeightOnlyInference(common_utils.TestCase): | 157 | class TestIntxWeightOnlyInference(common_utils.TestCase): |
| @@ -223,7 +223,7 @@ class TestIntxWeightOnlyInference(common_utils.TestCase): | |||
| 223 | 223 | ||
| 224 | @unittest.skipIf( | 224 | @unittest.skipIf( |
| 225 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), | 225 | not (_NPU_BACKEND_READY and torch.accelerator.is_available()), |
| 226 | - "Need torchao_npu backend and an available accelerator", | 226 | + "Need torchao_ascend backend and an available accelerator", |
| 227 | ) | 227 | ) |
| 228 | class TestIntxScenarioClosure(common_utils.TestCase): | 228 | class TestIntxScenarioClosure(common_utils.TestCase): |
| 229 | """intx weight-only 场景闭环:torch.compile parity。""" | 229 | """intx weight-only 场景闭环:torch.compile parity。""" |
| @@ -254,7 +254,7 @@ class TestIntxScenarioClosure(common_utils.TestCase): | |||
| 254 | 254 | ||
| 255 | @unittest.skipIf( | 255 | @unittest.skipIf( |
| 256 | not (_NPU_BACKEND_READY and torch.accelerator.is_available() and _qwen_configs_ready()), | 256 | not (_NPU_BACKEND_READY and torch.accelerator.is_available() and _qwen_configs_ready()), |
| 257 | - "Need torchao_npu backend, an accelerator and Qwen config.json files", | 257 | + "Need torchao_ascend backend, an accelerator and Qwen config.json files", |
| 258 | ) | 258 | ) |
| 259 | @common_utils.instantiate_parametrized_tests | 259 | @common_utils.instantiate_parametrized_tests |
| 260 | class TestQwenRealShapeIntx(common_utils.TestCase): | 260 | class TestQwenRealShapeIntx(common_utils.TestCase): |
| @@ -1,7 +1,7 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd |
| 2 | 2 | ||
| 3 | # -*- coding: utf-8 -*- | 3 | # -*- coding: utf-8 -*- |
| 4 | -"""torchao_npu.ops.npu(mx_ops)单元测试。 | 4 | +"""torchao_ascend.ops.npu(mx_ops)单元测试。 |
| 5 | 5 | ||
| 6 | 两层验证: | 6 | 两层验证: |
| 7 | - 透传契约(CPU 可跑):mock torch_npu / torch.ops.cann_ops_nn,断言每个 | 7 | - 透传契约(CPU 可跑):mock torch_npu / torch.ops.cann_ops_nn,断言每个 |
| @@ -12,7 +12,7 @@ | |||
| 12 | """ | 12 | """ |
| 13 | import torch | 13 | import torch |
| 14 | import torch_npu # noqa: F401 | 14 | import torch_npu # noqa: F401 |
| 15 | -from torchao_npu.ops import npu | 15 | +from torchao_ascend.ops import npu |
| 16 | 16 | ||
| 17 | try: | 17 | try: |
| 18 | from torch_npu.testing.testcase import TestCase, run_tests | 18 | from torch_npu.testing.testcase import TestCase, run_tests |
| @@ -8,7 +8,7 @@ from torchao.prototype.mx_formats.config import ScaleCalculationMode | |||
| 8 | from torchao.prototype.mx_formats.mx_tensor import MXTensor | 8 | from torchao.prototype.mx_formats.mx_tensor import MXTensor |
| 9 | from torchao.quantization.quantize_.common import KernelPreference | 9 | from torchao.quantization.quantize_.common import KernelPreference |
| 10 | 10 | ||
| 11 | -from torchao_npu.patches.torchao.prototype.mx_formats import utils as mx_utils | 11 | +from torchao_ascend.patches.torchao.prototype.mx_formats import utils as mx_utils |
| 12 | 12 | ||
| 13 | try: | 13 | try: |
| 14 | from torch_npu.testing.testcase import TestCase, run_tests | 14 | from torch_npu.testing.testcase import TestCase, run_tests |
| @@ -27,8 +27,8 @@ from torchao.prototype.mx_formats.mx_tensor import MXTensor | |||
| 27 | from torchao.quantization.quantize_.common import KernelPreference | 27 | from torchao.quantization.quantize_.common import KernelPreference |
| 28 | from torchao.quantization import quantize_ | 28 | from torchao.quantization import quantize_ |
| 29 | 29 | ||
| 30 | -import torchao_npu # noqa: F401 # trigger patch activation | 30 | +import torchao_ascend # noqa: F401 # trigger patch activation |
| 31 | -from torchao_npu.patches.torchao.prototype.moe_training import ( | 31 | +from torchao_ascend.patches.torchao.prototype.moe_training import ( |
| 32 | mxfp8_grouped_mm as npu_gmm, | 32 | mxfp8_grouped_mm as npu_gmm, |
| 33 | utils as npu_utils, | 33 | utils as npu_utils, |
| 34 | ) | 34 | ) |
| @@ -8,7 +8,7 @@ from torchao.prototype.mx_formats.config import ScaleCalculationMode | |||
| 8 | from torchao.prototype.mx_formats.mx_tensor import MXTensor | 8 | from torchao.prototype.mx_formats.mx_tensor import MXTensor |
| 9 | from torchao.quantization.quantize_.common import KernelPreference | 9 | from torchao.quantization.quantize_.common import KernelPreference |
| 10 | 10 | ||
| 11 | -from torchao_npu.patches.torchao.prototype.mx_formats import utils as mx_utils | 11 | +from torchao_ascend.patches.torchao.prototype.mx_formats import utils as mx_utils |
| 12 | 12 | ||
| 13 | try: | 13 | try: |
| 14 | from torch_npu.testing.testcase import TestCase, run_tests | 14 | from torch_npu.testing.testcase import TestCase, run_tests |
| @@ -28,11 +28,11 @@ import torch_npu # noqa: F401 | |||
| 28 | 28 | ||
| 29 | from torchao.quantization import quantize_ | 29 | from torchao.quantization import quantize_ |
| 30 | 30 | ||
| 31 | -import torchao_npu.features.qat.w4a16.w4a16_gmm as w4a16_gmm_module | 31 | +import torchao_ascend.features.qat.w4a16.w4a16_gmm as w4a16_gmm_module |
| 32 | -from torchao_npu.features.qat import w4a16 | 32 | +from torchao_ascend.features.qat import w4a16 |
| 33 | -from torchao_npu.features.qat.w4a16 import fakequant_rebuild as w4a16_fakequant_rebuild | 33 | +from torchao_ascend.features.qat.w4a16 import fakequant_rebuild as w4a16_fakequant_rebuild |
| 34 | -from torchao_npu.features.qat.w4a16.w4a16_linear import matmul_with_hp_or_lp_weight | 34 | +from torchao_ascend.features.qat.w4a16.w4a16_linear import matmul_with_hp_or_lp_weight |
| 35 | -from torchao_npu.ops.npu import dynamic_mx_quant | 35 | +from torchao_ascend.ops.npu import dynamic_mx_quant |
| 36 | 36 | ||
| 37 | try: | 37 | try: |
| 38 | from torch_npu.testing.testcase import TestCase, run_tests | 38 | from torch_npu.testing.testcase import TestCase, run_tests |
| @@ -12,7 +12,7 @@ | |||
| 12 | - V5/V6:**LP-AG 等价性** —— 收集低精对直接消费 vs 在线量化的逐位一致性, | 12 | - V5/V6:**LP-AG 等价性** —— 收集低精对直接消费 vs 在线量化的逐位一致性, |
| 13 | 以及 prepare/convert 的包装往返。 | 13 | 以及 prepare/convert 的包装往返。 |
| 14 | 14 | ||
| 15 | -运行方式(在 torchao_npu 仓根目录):: | 15 | +运行方式(在 torchao-ascend 仓根目录):: |
| 16 | 16 | ||
| 17 | pytest test/npu/test_w4a8_950_validation.py -v -s | 17 | pytest test/npu/test_w4a8_950_validation.py -v -s |
| 18 | # 或 | 18 | # 或 |
| @@ -24,7 +24,7 @@ | |||
| 24 | import torch | 24 | import torch |
| 25 | import torch.nn as nn | 25 | import torch.nn as nn |
| 26 | import torch_npu # noqa: F401 | 26 | import torch_npu # noqa: F401 |
| 27 | -import torchao_npu # noqa: F401 (mounts w4a8 into torchao) | 27 | +import torchao_ascend # noqa: F401 (mounts w4a8 into torchao) |
| 28 | 28 | ||
| 29 | from torchao.quantization import quantize_ | 29 | from torchao.quantization import quantize_ |
| 30 | from torchao.w4a8 import ( | 30 | from torchao.w4a8 import ( |
| @@ -35,8 +35,8 @@ from torchao.w4a8 import ( | |||
| 35 | w4a8_moe_filter, | 35 | w4a8_moe_filter, |
| 36 | ) | 36 | ) |
| 37 | 37 | ||
| 38 | -from torchao_npu.features.distributed import PostQuantWeight, PreQuantWeight | 38 | +from torchao_ascend.features.distributed import PostQuantWeight, PreQuantWeight |
| 39 | -from torchao_npu.features.training.mxfp8.mx_gmm import ( | 39 | +from torchao_ascend.features.training.mxfp8.mx_gmm import ( |
| 40 | mx_quant_group_gemm, | 40 | mx_quant_group_gemm, |
| 41 | weight_quant_gmm, | 41 | weight_quant_gmm, |
| 42 | ) | 42 | ) |
| @@ -13,7 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | 测试中的 ``_FusedExpertsGLU``/``_FusedExpertsSitu`` 是"模型框架 MoE 专家层" | 14 | 测试中的 ``_FusedExpertsGLU``/``_FusedExpertsSitu`` 是"模型框架 MoE 专家层" |
| 15 | 的最小替身:融合布局权重(``gate_up_proj`` [E, K, 2N] / ``down_proj`` | 15 | 的最小替身:融合布局权重(``gate_up_proj`` [E, K, 2N] / ``down_proj`` |
| 16 | -[E, N, K])+ 训练框架专家调用约定;torchao_npu 自身不提供专家容器。 | 16 | +[E, N, K])+ 训练框架专家调用约定;torchao_ascend 自身不提供专家容器。 |
| 17 | """ | 17 | """ |
| 18 | from contextlib import contextmanager | 18 | from contextlib import contextmanager |
| 19 | from unittest.mock import Mock | 19 | from unittest.mock import Mock |
| @@ -22,11 +22,11 @@ import torch | |||
| 22 | import torch.nn as nn | 22 | import torch.nn as nn |
| 23 | import torch.nn.functional as F | 23 | import torch.nn.functional as F |
| 24 | import torch_npu # noqa: F401 | 24 | import torch_npu # noqa: F401 |
| 25 | -import torchao_npu # noqa: F401 (mounts w4a8 into torchao) | 25 | +import torchao_ascend # noqa: F401 (mounts w4a8 into torchao) |
| 26 | import torchao.w4a8.moe_qat as moe_qat | 26 | import torchao.w4a8.moe_qat as moe_qat |
| 27 | from torchao.quantization import quantize_ | 27 | from torchao.quantization import quantize_ |
| 28 | 28 | ||
| 29 | -from torchao_npu.features.distributed import PostQuantWeight, PreQuantWeight | 29 | +from torchao_ascend.features.distributed import PostQuantWeight, PreQuantWeight |
| 30 | from torchao.w4a8 import ( | 30 | from torchao.w4a8 import ( |
| 31 | W4A8QATConfig, | 31 | W4A8QATConfig, |
| 32 | convert_w4a8_qat_, | 32 | convert_w4a8_qat_, |
| @@ -118,7 +118,7 @@ def _gemm_kernel_patched(): | |||
| 118 | """Patch the unified GEMM entry at both binding sites (the container hooks | 118 | """Patch the unified GEMM entry at both binding sites (the container hooks |
| 119 | resolve it in the mx_gmm module globals; the functional entry holds its | 119 | resolve it in the mx_gmm module globals; the functional entry holds its |
| 120 | own binding in moe_qat).""" | 120 | own binding in moe_qat).""" |
| 121 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 121 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 122 | 122 | ||
| 123 | saved = (mx_gmm_mod.mx_quant_group_gemm, moe_qat.mx_quant_group_gemm) | 123 | saved = (mx_gmm_mod.mx_quant_group_gemm, moe_qat.mx_quant_group_gemm) |
| 124 | mx_gmm_mod.mx_quant_group_gemm = _fake_gemm | 124 | mx_gmm_mod.mx_quant_group_gemm = _fake_gemm |
| @@ -480,8 +480,8 @@ class TestW4A8QATPatch(TestCase): | |||
| 480 | """prepare 后模块类替换为 W4A8QATGMM(MXFP8GMM 子类):EP 入口 | 480 | """prepare 后模块类替换为 W4A8QATGMM(MXFP8GMM 子类):EP 入口 |
| 481 | ep_forward_eager/fused 由类继承(框架 dispatcher 经 getattr 发现);框架类保留在 MRO(isinstance 与类常量仍可用); | 481 | ep_forward_eager/fused 由类继承(框架 dispatcher 经 getattr 发现);框架类保留在 MRO(isinstance 与类常量仍可用); |
| 482 | convert 恢复原类。""" | 482 | convert 恢复原类。""" |
| 483 | - from torchao_npu.features.qat.w4a8 import W4A8QATGMM | 483 | + from torchao_ascend.features.qat.w4a8 import W4A8QATGMM |
| 484 | - from torchao_npu.features.training.mxfp8.mx_gmm import MXFP8GMM | 484 | + from torchao_ascend.features.training.mxfp8.mx_gmm import MXFP8GMM |
| 485 | 485 | ||
| 486 | model = self._make_model() | 486 | model = self._make_model() |
| 487 | experts = model[0].experts | 487 | experts = model[0].experts |
| @@ -672,7 +672,7 @@ class TestW4A8DispatchCPU(TestCase): | |||
| 672 | """补丁 forward 的路由 dispatch 数值(内核替换为 BF16 参考,CPU 可跑)。""" | 672 | """补丁 forward 的路由 dispatch 数值(内核替换为 BF16 参考,CPU 可跑)。""" |
| 673 | 673 | ||
| 674 | def _patch_kernel(self): | 674 | def _patch_kernel(self): |
| 675 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 675 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 676 | 676 | ||
| 677 | self._saved_gemm = (mx_gmm_mod.mx_quant_group_gemm, moe_qat.mx_quant_group_gemm) | 677 | self._saved_gemm = (mx_gmm_mod.mx_quant_group_gemm, moe_qat.mx_quant_group_gemm) |
| 678 | mx_gmm_mod.mx_quant_group_gemm = _fake_gemm | 678 | mx_gmm_mod.mx_quant_group_gemm = _fake_gemm |
| @@ -680,7 +680,7 @@ class TestW4A8DispatchCPU(TestCase): | |||
| 680 | 680 | ||
| 681 | def tearDown(self): | 681 | def tearDown(self): |
| 682 | if hasattr(self, "_saved_gemm"): | 682 | if hasattr(self, "_saved_gemm"): |
| 683 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 683 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 684 | 684 | ||
| 685 | (mx_gmm_mod.mx_quant_group_gemm, moe_qat.mx_quant_group_gemm) = self._saved_gemm | 685 | (mx_gmm_mod.mx_quant_group_gemm, moe_qat.mx_quant_group_gemm) = self._saved_gemm |
| 686 | del self._saved_gemm | 686 | del self._saved_gemm |
| @@ -815,8 +815,8 @@ class TestW4A8UnifiedGemmPath(TestCase): | |||
| 815 | def setUp(self): | 815 | def setUp(self): |
| 816 | from unittest.mock import patch | 816 | from unittest.mock import patch |
| 817 | 817 | ||
| 818 | - import torchao_npu.features.training.mxfp8.grouped_matmul as gmm_autograd_mod | 818 | + import torchao_ascend.features.training.mxfp8.grouped_matmul as gmm_autograd_mod |
| 819 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 819 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 820 | 820 | ||
| 821 | self._calls = {"x_quant": 0, "w_quant": 0, "w_rescale": 0, "fwd_pair": 0, "bwd_pair": 0} | 821 | self._calls = {"x_quant": 0, "w_quant": 0, "w_rescale": 0, "fwd_pair": 0, "bwd_pair": 0} |
| 822 | 822 | ||
| @@ -887,8 +887,8 @@ class TestW4A8UnifiedGemmPath(TestCase): | |||
| 887 | gate_up = (torch.randn(e, k, 2 * n) * 0.05).bfloat16() | 887 | gate_up = (torch.randn(e, k, 2 * n) * 0.05).bfloat16() |
| 888 | x = torch.randn(m, k, dtype=torch.bfloat16) | 888 | x = torch.randn(m, k, dtype=torch.bfloat16) |
| 889 | 889 | ||
| 890 | - from torchao_npu.features.qat.w4a8.config import W4A8QATConfig | 890 | + from torchao_ascend.features.qat.w4a8.config import W4A8QATConfig |
| 891 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 891 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 892 | 892 | ||
| 893 | cfg = W4A8QATConfig() | 893 | cfg = W4A8QATConfig() |
| 894 | gl = torch.tensor([m // 2, m], dtype=torch.int64) | 894 | gl = torch.tensor([m // 2, m], dtype=torch.int64) |
| @@ -903,8 +903,8 @@ class TestW4A8UnifiedGemmPath(TestCase): | |||
| 903 | x = torch.randn(m, k, dtype=torch.bfloat16) | 903 | x = torch.randn(m, k, dtype=torch.bfloat16) |
| 904 | group_list = torch.tensor([m // 2, m], dtype=torch.int64) | 904 | group_list = torch.tensor([m // 2, m], dtype=torch.int64) |
| 905 | 905 | ||
| 906 | - from torchao_npu.features.qat.w4a8.config import W4A8QATConfig | 906 | + from torchao_ascend.features.qat.w4a8.config import W4A8QATConfig |
| 907 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 907 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 908 | 908 | ||
| 909 | out = mx_gmm_mod.mx_quant_group_gemm( | 909 | out = mx_gmm_mod.mx_quant_group_gemm( |
| 910 | x=x, weight=pq, group_list=group_list, config=W4A8QATConfig() | 910 | x=x, weight=pq, group_list=group_list, config=W4A8QATConfig() |
| @@ -922,8 +922,8 @@ class TestW4A8UnifiedGemmPath(TestCase): | |||
| 922 | x = torch.randn(m, k, dtype=torch.bfloat16, requires_grad=True) | 922 | x = torch.randn(m, k, dtype=torch.bfloat16, requires_grad=True) |
| 923 | group_list = torch.tensor([m // 2, m], dtype=torch.int64) | 923 | group_list = torch.tensor([m // 2, m], dtype=torch.int64) |
| 924 | 924 | ||
| 925 | - from torchao_npu.features.qat.w4a8.config import W4A8QATConfig | 925 | + from torchao_ascend.features.qat.w4a8.config import W4A8QATConfig |
| 926 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 926 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 927 | 927 | ||
| 928 | out = mx_gmm_mod.mx_quant_group_gemm( | 928 | out = mx_gmm_mod.mx_quant_group_gemm( |
| 929 | x=x, weight=pq, group_list=group_list, config=W4A8QATConfig(), | 929 | x=x, weight=pq, group_list=group_list, config=W4A8QATConfig(), |
| @@ -940,8 +940,8 @@ class TestW4A8UnifiedGemmPath(TestCase): | |||
| 940 | x = torch.randn(m, k, dtype=torch.bfloat16, requires_grad=True) | 940 | x = torch.randn(m, k, dtype=torch.bfloat16, requires_grad=True) |
| 941 | group_list = torch.tensor([m // 2, m], dtype=torch.int64) | 941 | group_list = torch.tensor([m // 2, m], dtype=torch.int64) |
| 942 | 942 | ||
| 943 | - from torchao_npu.features.qat.w4a8.config import W4A8QATConfig | 943 | + from torchao_ascend.features.qat.w4a8.config import W4A8QATConfig |
| 944 | - import torchao_npu.features.training.mxfp8.mx_gmm as mx_gmm_mod | 944 | + import torchao_ascend.features.training.mxfp8.mx_gmm as mx_gmm_mod |
| 945 | 945 | ||
| 946 | out = mx_gmm_mod.mx_quant_group_gemm( | 946 | out = mx_gmm_mod.mx_quant_group_gemm( |
| 947 | x=x, weight=pq, group_list=group_list, config=W4A8QATConfig() | 947 | x=x, weight=pq, group_list=group_list, config=W4A8QATConfig() |
| @@ -951,7 +951,7 @@ class TestW4A8UnifiedGemmPath(TestCase): | |||
| 951 | 951 | ||
| 952 | def test_config_duck_types_gemm_config(self): | 952 | def test_config_duck_types_gemm_config(self): |
| 953 | """W4A8QATConfig 满足 mx_quant_group_gemm 的 GEMM config 契约。""" | 953 | """W4A8QATConfig 满足 mx_quant_group_gemm 的 GEMM config 契约。""" |
| 954 | - from torchao_npu.features.training.mxfp8.config import Format | 954 | + from torchao_ascend.features.training.mxfp8.config import Format |
| 955 | 955 | ||
| 956 | cfg = W4A8QATConfig() | 956 | cfg = W4A8QATConfig() |
| 957 | self.assertEqual(cfg.quant_format, "W4A8") | 957 | self.assertEqual(cfg.quant_format, "W4A8") |
| @@ -1,9 +1,9 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd |
| 2 | 2 | ||
| 3 | -"""W8A16 MXFP8 QAT NPU tests for torchao_npu. | 3 | +"""W8A16 MXFP8 QAT NPU tests for torchao_ascend. |
| 4 | 4 | ||
| 5 | Covers: | 5 | Covers: |
| 6 | - - Namespace mounting: torchao.mxfp8 / torchao_npu.mxfp8 importability | 6 | + - Namespace mounting: torchao.mxfp8 / torchao_ascend.mxfp8 importability |
| 7 | - Fake quant: shape, dtype, value range, idempotency, padding, zero-tensor, | 7 | - Fake quant: shape, dtype, value range, idempotency, padding, zero-tensor, |
| 8 | FP32 input, non-default qdim, block_size variants | 8 | FP32 input, non-default qdim, block_size variants |
| 9 | - Dual configs: valid/invalid block_size, exact-type dispatch, from_linear, | 9 | - Dual configs: valid/invalid block_size, exact-type dispatch, from_linear, |
| @@ -29,8 +29,8 @@ import torch_npu # noqa: F401 | |||
| 29 | from torch import nn | 29 | from torch import nn |
| 30 | from torchao.quantization import quantize_ | 30 | from torchao.quantization import quantize_ |
| 31 | 31 | ||
| 32 | -import torchao_npu # noqa: F401 (mounts torchao.mxfp8; entry-point autoload may not fire) | 32 | +import torchao_ascend # noqa: F401 (mounts torchao.mxfp8; entry-point autoload may not fire) |
| 33 | -from torchao_npu.features.qat.mxfp8 import ( | 33 | +from torchao_ascend.features.qat.mxfp8 import ( |
| 34 | MXFP8FakeQuantization, | 34 | MXFP8FakeQuantization, |
| 35 | MXFP8GMMQAT, | 35 | MXFP8GMMQAT, |
| 36 | MXFP8GMMQATConfig, | 36 | MXFP8GMMQATConfig, |
| @@ -59,10 +59,10 @@ class TestW8A16Namespace: | |||
| 59 | assert torchao.mxfp8 is not None | 59 | assert torchao.mxfp8 is not None |
| 60 | assert hasattr(torchao.mxfp8, "W8A16LinearConfig") | 60 | assert hasattr(torchao.mxfp8, "W8A16LinearConfig") |
| 61 | 61 | ||
| 62 | - def test_import_from_torchao_npu(self): | 62 | + def test_import_from_torchao_ascend(self): |
| 63 | - """`from torchao_npu import mxfp8` resolves to the same module object.""" | 63 | + """`from torchao_ascend import mxfp8` resolves to the same module object.""" |
| 64 | import torchao | 64 | import torchao |
| 65 | - assert torchao_npu.mxfp8 is torchao.mxfp8 | 65 | + assert torchao_ascend.mxfp8 is torchao.mxfp8 |
| 66 | 66 | ||
| 67 | def test_import_submodule_via_torchao(self): | 67 | def test_import_submodule_via_torchao(self): |
| 68 | """`import torchao.mxfp8.config` style works through sys.modules aliasing.""" | 68 | """`import torchao.mxfp8.config` style works through sys.modules aliasing.""" |
| @@ -713,7 +713,7 @@ class TestMoEExpertsNPU: | |||
| 713 | 713 | ||
| 714 | def test_gmm_block_size_reaches_forward(self, monkeypatch): | 714 | def test_gmm_block_size_reaches_forward(self, monkeypatch): |
| 715 | """from_float 的 block_size 必须真正到达 forward(回归测试)。""" | 715 | """from_float 的 block_size 必须真正到达 forward(回归测试)。""" |
| 716 | - import torchao_npu.features.qat.mxfp8.gmm as gmm_mod | 716 | + import torchao_ascend.features.qat.mxfp8.gmm as gmm_mod |
| 717 | 717 | ||
| 718 | seen = {} | 718 | seen = {} |
| 719 | real = gmm_mod.mxfp8_experts_forward | 719 | real = gmm_mod.mxfp8_experts_forward |
| @@ -32,8 +32,8 @@ except ImportError: | |||
| 32 | def run_tests(): | 32 | def run_tests(): |
| 33 | unittest.main(argv=sys.argv) | 33 | unittest.main(argv=sys.argv) |
| 34 | 34 | ||
| 35 | -import torchao_npu # noqa: F401 (mounts torchao.mxfp8; entry-point autoload may not fire) | 35 | +import torchao_ascend # noqa: F401 (mounts torchao.mxfp8; entry-point autoload may not fire) |
| 36 | -from torchao_npu.features.qat.mxfp8 import ( | 36 | +from torchao_ascend.features.qat.mxfp8 import ( |
| 37 | MXFP8GMMQATConfig, | 37 | MXFP8GMMQATConfig, |
| 38 | MXFP8GMMQAT, | 38 | MXFP8GMMQAT, |
| 39 | convert_w8a8_gmm_qat_, | 39 | convert_w8a8_gmm_qat_, |
| @@ -83,7 +83,7 @@ class TestW8A8ExpertsForward(TestCase): | |||
| 83 | counts = torch.tensor([2, 1, 2, 1], dtype=torch.int64, device=DEVICE) | 83 | counts = torch.tensor([2, 1, 2, 1], dtype=torch.int64, device=DEVICE) |
| 84 | x = torch.randn(tokens, hidden, dtype=torch.bfloat16, device=DEVICE) | 84 | x = torch.randn(tokens, hidden, dtype=torch.bfloat16, device=DEVICE) |
| 85 | out_w8a8 = w8a8_experts_forward(x, experts.gate_up_proj, experts.down_proj, counts) | 85 | out_w8a8 = w8a8_experts_forward(x, experts.gate_up_proj, experts.down_proj, counts) |
| 86 | - from torchao_npu.features.qat.mxfp8 import w8a16_experts_forward | 86 | + from torchao_ascend.features.qat.mxfp8 import w8a16_experts_forward |
| 87 | out_w8a16 = w8a16_experts_forward(x, experts.gate_up_proj, experts.down_proj, counts) | 87 | out_w8a16 = w8a16_experts_forward(x, experts.gate_up_proj, experts.down_proj, counts) |
| 88 | assert not torch.allclose(out_w8a8.float(), out_w8a16.float(), atol=1e-6) | 88 | assert not torch.allclose(out_w8a8.float(), out_w8a16.float(), atol=1e-6) |
| 89 | 89 | ||
| @@ -148,7 +148,7 @@ class TestW8A8GMMClassSwap(TestCase): | |||
| 148 | assert out.dtype == torch.bfloat16 | 148 | assert out.dtype == torch.bfloat16 |
| 149 | assert torch.isfinite(out).all() | 149 | assert torch.isfinite(out).all() |
| 150 | # W8A8 must differ from W8A16: activation FQ changes the output. | 150 | # W8A8 must differ from W8A16: activation FQ changes the output. |
| 151 | - from torchao_npu.features.qat.mxfp8 import w8a16_experts_forward | 151 | + from torchao_ascend.features.qat.mxfp8 import w8a16_experts_forward |
| 152 | experts_flat = idx.reshape(-1).to(torch.int64) | 152 | experts_flat = idx.reshape(-1).to(torch.int64) |
| 153 | sort_order = torch.argsort(experts_flat, stable=True) | 153 | sort_order = torch.argsort(experts_flat, stable=True) |
| 154 | token_of_entry = torch.arange(experts_flat.numel(), device=DEVICE) // top_k | 154 | token_of_entry = torch.arange(experts_flat.numel(), device=DEVICE) // top_k |
| @@ -230,7 +230,7 @@ class TestWeightOnlyDispatch(TestCase): | |||
| 230 | 230 | ||
| 231 | def test_config_type(self): | 231 | def test_config_type(self): |
| 232 | """MXFP8GMMQATConfig is the sole config type (no W8A16GMMConfig alias).""" | 232 | """MXFP8GMMQATConfig is the sole config type (no W8A16GMMConfig alias).""" |
| 233 | - import torchao_npu.features.qat.mxfp8 as mxfp8 | 233 | + import torchao_ascend.features.qat.mxfp8 as mxfp8 |
| 234 | assert not hasattr(mxfp8, "W8A16GMMConfig") | 234 | assert not hasattr(mxfp8, "W8A16GMMConfig") |
| 235 | 235 | ||
| 236 | def test_prepare_w8a16(self): | 236 | def test_prepare_w8a16(self): |
| @@ -253,7 +253,7 @@ class TestWeightOnlyDispatch(TestCase): | |||
| 253 | 253 | ||
| 254 | def test_from_linear_propagates_weight_only(self): | 254 | def test_from_linear_propagates_weight_only(self): |
| 255 | """MXFP8GMMQATConfig.from_linear propagates weight_only from the base config.""" | 255 | """MXFP8GMMQATConfig.from_linear propagates weight_only from the base config.""" |
| 256 | - from torchao_npu.features.qat.mxfp8 import W8A16LinearConfig | 256 | + from torchao_ascend.features.qat.mxfp8 import W8A16LinearConfig |
| 257 | base = W8A16LinearConfig(block_size=32) | 257 | base = W8A16LinearConfig(block_size=32) |
| 258 | gmm = MXFP8GMMQATConfig.from_linear(base) | 258 | gmm = MXFP8GMMQATConfig.from_linear(base) |
| 259 | assert gmm.weight_only is True # default | 259 | assert gmm.weight_only is True # default |
| @@ -99,7 +99,7 @@ class TestQATMXFP8NPU(TestCase): | |||
| 99 | return model | 99 | return model |
| 100 | 100 | ||
| 101 | def _assert_npu_mx_dispatch(self): | 101 | def _assert_npu_mx_dispatch(self): |
| 102 | - """防呆:torchao 的 qat.mx dispatch 必须被 torchao_npu 改成 NPU MX kernel, | 102 | + """防呆:torchao 的 qat.mx dispatch 必须被 torchao_ascend 改成 NPU MX kernel, |
| 103 | 否则前向会静默回退到 BF16/CPU 而测试仍可能数值接近。 | 103 | 否则前向会静默回退到 BF16/CPU 而测试仍可能数值接近。 |
| 104 | """ | 104 | """ |
| 105 | try: | 105 | try: |
| @@ -5,7 +5,7 @@ | |||
| 5 | Covers the CPU-runnable slice of the auto-activation design (trigger | 5 | Covers the CPU-runnable slice of the auto-activation design (trigger |
| 6 | path 3): package discovery before public imports, escape hatches, | 6 | path 3): package discovery before public imports, escape hatches, |
| 7 | non-NPU environments, defensive bootstrap, and the idempotent | 7 | non-NPU environments, defensive bootstrap, and the idempotent |
| 8 | -``torchao_npu.activate()`` core shared by all trigger paths. The full NPU | 8 | +``torchao_ascend.activate()`` core shared by all trigger paths. The full NPU |
| 9 | chain (hook -> torchao import -> activation) is covered by NPU CI smoke tests. | 9 | chain (hook -> torchao import -> activation) is covered by NPU CI smoke tests. |
| 10 | """ | 10 | """ |
| 11 | from __future__ import annotations | 11 | from __future__ import annotations |
| @@ -19,16 +19,16 @@ from pathlib import Path | |||
| 19 | 19 | ||
| 20 | import pytest | 20 | import pytest |
| 21 | 21 | ||
| 22 | -import _torchao_npu_autoload as autoload | 22 | +import _torchao_ascend_autoload as autoload |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | def _meta_path_snapshot() -> list: | 25 | def _meta_path_snapshot() -> list: |
| 26 | return list(sys.meta_path) | 26 | return list(sys.meta_path) |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | -# _torchao_npu_autoload.py sits at the repository root: test/unit/ -> test/ -> root. | 29 | +# _torchao_ascend_autoload.py sits at the repository root: test/unit/ -> test/ -> root. |
| 30 | _REPO_ROOT = Path(__file__).resolve().parents[2] | 30 | _REPO_ROOT = Path(__file__).resolve().parents[2] |
| 31 | -_AUTOLOAD_FILE = _REPO_ROOT / "_torchao_npu_autoload.py" | 31 | +_AUTOLOAD_FILE = _REPO_ROOT / "_torchao_ascend_autoload.py" |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | @pytest.mark.parametrize("probe_count", [0, 1, 3]) | 34 | @pytest.mark.parametrize("probe_count", [0, 1, 3]) |
| @@ -37,8 +37,8 @@ def test_public_import_activates_after_package_discovery(tmp_path, probe_count): | |||
| 37 | packages = { | 37 | packages = { |
| 38 | "torch_npu/__init__.py": "", | 38 | "torch_npu/__init__.py": "", |
| 39 | "torchao/__init__.py": "initialized = True\nactivation_count = 0\n", | 39 | "torchao/__init__.py": "initialized = True\nactivation_count = 0\n", |
| 40 | - "torchao_npu/hifloat8/__init__.py": "class HiFloat8Config:\n pass\n", | 40 | + "torchao_ascend/hifloat8/__init__.py": "class HiFloat8Config:\n pass\n", |
| 41 | - "torchao_npu/__init__.py": """ | 41 | + "torchao_ascend/__init__.py": """ |
| 42 | import sys | 42 | import sys |
| 43 | import torchao | 43 | import torchao |
| 44 | from . import hifloat8 | 44 | from . import hifloat8 |
| @@ -66,7 +66,7 @@ def test_public_import_activates_after_package_discovery(tmp_path, probe_count): | |||
| 66 | import importlib.util | 66 | import importlib.util |
| 67 | import sys | 67 | import sys |
| 68 | from pathlib import Path | 68 | from pathlib import Path |
| 69 | - import _torchao_npu_autoload as autoload | 69 | + import _torchao_ascend_autoload as autoload |
| 70 | 70 | ||
| 71 | # The subprocess must load this checkout's autoload, never an installed copy. | 71 | # The subprocess must load this checkout's autoload, never an installed copy. |
| 72 | assert Path(autoload.__file__).resolve() == Path({str(_AUTOLOAD_FILE)!r}) | 72 | assert Path(autoload.__file__).resolve() == Path({str(_AUTOLOAD_FILE)!r}) |
| @@ -74,7 +74,7 @@ def test_public_import_activates_after_package_discovery(tmp_path, probe_count): | |||
| 74 | for _ in range({probe_count}): | 74 | for _ in range({probe_count}): |
| 75 | assert importlib.util.find_spec("torchao") is not None | 75 | assert importlib.util.find_spec("torchao") is not None |
| 76 | assert "torchao" not in sys.modules | 76 | assert "torchao" not in sys.modules |
| 77 | - assert "torchao_npu" not in sys.modules | 77 | + assert "torchao_ascend" not in sys.modules |
| 78 | 78 | ||
| 79 | from torchao.hifloat8 import HiFloat8Config | 79 | from torchao.hifloat8 import HiFloat8Config |
| 80 | import torchao | 80 | import torchao |
| @@ -85,7 +85,7 @@ def test_public_import_activates_after_package_discovery(tmp_path, probe_count): | |||
| 85 | assert repeated_import is HiFloat8Config | 85 | assert repeated_import is HiFloat8Config |
| 86 | assert torchao.activation_count == 1 | 86 | assert torchao.activation_count == 1 |
| 87 | """) | 87 | """) |
| 88 | - env = dict(os.environ, TORCHAO_NPU_AUTO_ACTIVATE="1") | 88 | + env = dict(os.environ, TORCHAO_ASCEND_AUTO_ACTIVATE="1") |
| 89 | env["PYTHONPATH"] = os.pathsep.join((str(tmp_path), str(_REPO_ROOT))) | 89 | env["PYTHONPATH"] = os.pathsep.join((str(tmp_path), str(_REPO_ROOT))) |
| 90 | result = subprocess.run( | 90 | result = subprocess.run( |
| 91 | [sys.executable, "-c", script], cwd=tmp_path, env=env, | 91 | [sys.executable, "-c", script], cwd=tmp_path, env=env, |
| @@ -95,8 +95,8 @@ def test_public_import_activates_after_package_discovery(tmp_path, probe_count): | |||
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | def test_bootstrap_escape_hatch_disables_hook(monkeypatch): | 97 | def test_bootstrap_escape_hatch_disables_hook(monkeypatch): |
| 98 | - """TORCHAO_NPU_AUTO_ACTIVATE=0 must leave sys.meta_path untouched.""" | 98 | + """TORCHAO_ASCEND_AUTO_ACTIVATE=0 must leave sys.meta_path untouched.""" |
| 99 | - monkeypatch.setenv("TORCHAO_NPU_AUTO_ACTIVATE", "0") | 99 | + monkeypatch.setenv("TORCHAO_ASCEND_AUTO_ACTIVATE", "0") |
| 100 | before = _meta_path_snapshot() | 100 | before = _meta_path_snapshot() |
| 101 | autoload.bootstrap() | 101 | autoload.bootstrap() |
| 102 | assert sys.meta_path == before | 102 | assert sys.meta_path == before |
| @@ -104,7 +104,7 @@ def test_bootstrap_escape_hatch_disables_hook(monkeypatch): | |||
| 104 | 104 | ||
| 105 | def test_bootstrap_skips_without_torch_npu(monkeypatch): | 105 | def test_bootstrap_skips_without_torch_npu(monkeypatch): |
| 106 | """Non-NPU environments (no torch_npu installed) must not install the hook.""" | 106 | """Non-NPU environments (no torch_npu installed) must not install the hook.""" |
| 107 | - monkeypatch.setenv("TORCHAO_NPU_AUTO_ACTIVATE", "1") | 107 | + monkeypatch.setenv("TORCHAO_ASCEND_AUTO_ACTIVATE", "1") |
| 108 | if importlib.util.find_spec("torch_npu") is not None: | 108 | if importlib.util.find_spec("torch_npu") is not None: |
| 109 | pytest.skip("torch_npu installed; NPU chain is covered by NPU CI") | 109 | pytest.skip("torch_npu installed; NPU chain is covered by NPU CI") |
| 110 | before = _meta_path_snapshot() | 110 | before = _meta_path_snapshot() |
| @@ -113,13 +113,13 @@ def test_bootstrap_skips_without_torch_npu(monkeypatch): | |||
| 113 | 113 | ||
| 114 | 114 | ||
| 115 | def test_bootstrap_circular_guard_skips_hook(monkeypatch): | 115 | def test_bootstrap_circular_guard_skips_hook(monkeypatch): |
| 116 | - """A partially/fully initialized torchao_npu must suppress the hook. | 116 | + """A partially/fully initialized torchao_ascend must suppress the hook. |
| 117 | 117 | ||
| 118 | - sys.modules["torchao_npu"] = None makes ``import torchao_npu`` raise | 118 | + sys.modules["torchao_ascend"] = None makes ``import torchao_ascend`` raise |
| 119 | ImportError while still marking the name as present. | 119 | ImportError while still marking the name as present. |
| 120 | """ | 120 | """ |
| 121 | - monkeypatch.setenv("TORCHAO_NPU_AUTO_ACTIVATE", "1") | 121 | + monkeypatch.setenv("TORCHAO_ASCEND_AUTO_ACTIVATE", "1") |
| 122 | - monkeypatch.setitem(sys.modules, "torchao_npu", None) | 122 | + monkeypatch.setitem(sys.modules, "torchao_ascend", None) |
| 123 | before = _meta_path_snapshot() | 123 | before = _meta_path_snapshot() |
| 124 | autoload.bootstrap() | 124 | autoload.bootstrap() |
| 125 | assert sys.meta_path == before | 125 | assert sys.meta_path == before |
| @@ -131,13 +131,13 @@ def test_bootstrap_never_raises(monkeypatch): | |||
| 131 | torch raises RuntimeError for entry-point failures; an unguarded | 131 | torch raises RuntimeError for entry-point failures; an unguarded |
| 132 | exception here would break every ``import torch`` in the environment. | 132 | exception here would break every ``import torch`` in the environment. |
| 133 | """ | 133 | """ |
| 134 | - monkeypatch.setenv("TORCHAO_NPU_AUTO_ACTIVATE", "1") | 134 | + monkeypatch.setenv("TORCHAO_ASCEND_AUTO_ACTIVATE", "1") |
| 135 | 135 | ||
| 136 | def _boom(): | 136 | def _boom(): |
| 137 | raise RuntimeError("boom") | 137 | raise RuntimeError("boom") |
| 138 | 138 | ||
| 139 | monkeypatch.setattr(autoload, "_bootstrap", _boom) | 139 | monkeypatch.setattr(autoload, "_bootstrap", _boom) |
| 140 | - with pytest.warns(RuntimeWarning, match="torchao_npu autoload skipped"): | 140 | + with pytest.warns(RuntimeWarning, match="torchao_ascend autoload skipped"): |
| 141 | autoload.bootstrap() | 141 | autoload.bootstrap() |
| 142 | 142 | ||
| 143 | 143 | ||
| @@ -148,11 +148,11 @@ def test_bootstrap_warns_when_torchao_imported_first(monkeypatch): | |||
| 148 | running), so the one-shot hook would silently never fire. Bootstrap | 148 | running), so the one-shot hook would silently never fire. Bootstrap |
| 149 | must warn with guidance instead of losing activation silently. | 149 | must warn with guidance instead of losing activation silently. |
| 150 | """ | 150 | """ |
| 151 | - monkeypatch.setenv("TORCHAO_NPU_AUTO_ACTIVATE", "1") | 151 | + monkeypatch.setenv("TORCHAO_ASCEND_AUTO_ACTIVATE", "1") |
| 152 | if importlib.util.find_spec("torch_npu") is None: | 152 | if importlib.util.find_spec("torch_npu") is None: |
| 153 | pytest.skip("torch_npu not installed; warning only fires on NPU envs") | 153 | pytest.skip("torch_npu not installed; warning only fires on NPU envs") |
| 154 | - # A pre-imported torchao_npu would trip the circular guard; clear it. | 154 | + # A pre-imported torchao_ascend would trip the circular guard; clear it. |
| 155 | - monkeypatch.delitem(sys.modules, "torchao_npu", raising=False) | 155 | + monkeypatch.delitem(sys.modules, "torchao_ascend", raising=False) |
| 156 | monkeypatch.setitem(sys.modules, "torchao", None) | 156 | monkeypatch.setitem(sys.modules, "torchao", None) |
| 157 | before = _meta_path_snapshot() | 157 | before = _meta_path_snapshot() |
| 158 | with pytest.warns(RuntimeWarning, match="auto-activation skipped"): | 158 | with pytest.warns(RuntimeWarning, match="auto-activation skipped"): |
| @@ -162,7 +162,7 @@ def test_bootstrap_warns_when_torchao_imported_first(monkeypatch): | |||
| 162 | 162 | ||
| 163 | def test_try_activate_warns_on_failure(monkeypatch): | 163 | def test_try_activate_warns_on_failure(monkeypatch): |
| 164 | """Activation failures must degrade to a warning, never an exception.""" | 164 | """Activation failures must degrade to a warning, never an exception.""" |
| 165 | - monkeypatch.setitem(sys.modules, "torchao_npu", None) | 165 | + monkeypatch.setitem(sys.modules, "torchao_ascend", None) |
| 166 | with pytest.warns(RuntimeWarning, match="auto-activation failed"): | 166 | with pytest.warns(RuntimeWarning, match="auto-activation failed"): |
| 167 | autoload._try_activate() | 167 | autoload._try_activate() |
| 168 | 168 | ||
| @@ -188,11 +188,11 @@ def test_hook_one_shot_when_torchao_already_imported(): | |||
| 188 | def test_activate_is_idempotent(): | 188 | def test_activate_is_idempotent(): |
| 189 | """All trigger paths converge on one idempotent activate().""" | 189 | """All trigger paths converge on one idempotent activate().""" |
| 190 | pytest.importorskip("torchao") | 190 | pytest.importorskip("torchao") |
| 191 | - import torchao_npu | 191 | + import torchao_ascend |
| 192 | 192 | ||
| 193 | - assert torchao_npu._APPLIED is True # import already ran trigger path 1 | 193 | + assert torchao_ascend._APPLIED is True # import already ran trigger path 1 |
| 194 | - torchao_npu.activate() # trigger path 2 (and 3 re-imports): no-op | 194 | + torchao_ascend.activate() # trigger path 2 (and 3 re-imports): no-op |
| 195 | - assert torchao_npu._APPLIED is True | 195 | + assert torchao_ascend._APPLIED is True |
| 196 | # NPU-native feature modules registered by _initialize() | 196 | # NPU-native feature modules registered by _initialize() |
| 197 | - assert hasattr(torchao_npu, "hifloat8") | 197 | + assert hasattr(torchao_ascend, "hifloat8") |
| 198 | - assert hasattr(torchao_npu, "w4a8") | 198 | + assert hasattr(torchao_ascend, "w4a8") |
| @@ -1,7 +1,7 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd |
| 2 | 2 | ||
| 3 | """Unit tests for the HiFloat8 filter factories. The predicates are | 3 | """Unit tests for the HiFloat8 filter factories. The predicates are |
| 4 | -device-free, but they import the torchao_npu package: torch_npu must be | 4 | +device-free, but they import the torchao_ascend package: torch_npu must be |
| 5 | installed, no NPU device needed. | 5 | installed, no NPU device needed. |
| 6 | """ | 6 | """ |
| 7 | import logging | 7 | import logging |
| @@ -12,11 +12,11 @@ torch_npu = pytest.importorskip("torch_npu") | |||
| 12 | 12 | ||
| 13 | import torch # noqa: E402 | 13 | import torch # noqa: E402 |
| 14 | 14 | ||
| 15 | -from torchao_npu.features.training.hifloat8 import ( # noqa: E402 | 15 | +from torchao_ascend.features.training.hifloat8 import ( # noqa: E402 |
| 16 | HiFloat8GMM, | 16 | HiFloat8GMM, |
| 17 | HiFloat8Linear, | 17 | HiFloat8Linear, |
| 18 | ) | 18 | ) |
| 19 | -from torchao_npu.features.training.hifloat8.filters import ( # noqa: E402 | 19 | +from torchao_ascend.features.training.hifloat8.filters import ( # noqa: E402 |
| 20 | grouped_filter_fn, | 20 | grouped_filter_fn, |
| 21 | linear_filter_fn, | 21 | linear_filter_fn, |
| 22 | mixed_filter_fn, | 22 | mixed_filter_fn, |
| @@ -90,7 +90,7 @@ def test_filters_drive_cpu_conversion(): | |||
| 90 | """Filters compose with quantize_: selected modules convert without kernels.""" | 90 | """Filters compose with quantize_: selected modules convert without kernels.""" |
| 91 | from torchao.quantization import quantize_ | 91 | from torchao.quantization import quantize_ |
| 92 | 92 | ||
| 93 | - from torchao_npu.features.training.hifloat8 import HiFloat8Config | 93 | + from torchao_ascend.features.training.hifloat8 import HiFloat8Config |
| 94 | 94 | ||
| 95 | class MixedModel(torch.nn.Module): | 95 | class MixedModel(torch.nn.Module): |
| 96 | def __init__(self): | 96 | def __init__(self): |
| @@ -3,7 +3,7 @@ | |||
| 3 | """Device-free unit tests for the grouped-GEMM conversion mechanics: the | 3 | """Device-free unit tests for the grouped-GEMM conversion mechanics: the |
| 4 | class swap survives a pickle roundtrip and the converted forward reads the | 4 | class swap survives a pickle roundtrip and the converted forward reads the |
| 5 | live config slot. The import chain reaches the torch_npu package, so these | 5 | live config slot. The import chain reaches the torch_npu package, so these |
| 6 | -run wherever torchao_npu installs — no NPU device needed, but torch_npu must | 6 | +run wherever torchao_ascend installs — no NPU device needed, but torch_npu must |
| 7 | be importable. | 7 | be importable. |
| 8 | """ | 8 | """ |
| 9 | import importlib | 9 | import importlib |
| @@ -17,12 +17,12 @@ import torch # noqa: E402 | |||
| 17 | 17 | ||
| 18 | from torchao.quantization import quantize_ # noqa: E402 | 18 | from torchao.quantization import quantize_ # noqa: E402 |
| 19 | 19 | ||
| 20 | -from torchao_npu.features.training.hifloat8 import ( # noqa: E402 | 20 | +from torchao_ascend.features.training.hifloat8 import ( # noqa: E402 |
| 21 | HiFloat8GMM, | 21 | HiFloat8GMM, |
| 22 | HiFloat8GMMConfig, | 22 | HiFloat8GMMConfig, |
| 23 | grouped_filter_fn, | 23 | grouped_filter_fn, |
| 24 | ) | 24 | ) |
| 25 | -from torchao_npu.features.training.hifloat8.hifloat8_gmm import ( # noqa: E402 | 25 | +from torchao_ascend.features.training.hifloat8.hifloat8_gmm import ( # noqa: E402 |
| 26 | hifloat8_gmm, | 26 | hifloat8_gmm, |
| 27 | ) | 27 | ) |
| 28 | 28 | ||
| @@ -72,7 +72,7 @@ def test_converted_forward_reads_live_config_slot(monkeypatch): | |||
| 72 | experts = model[0] | 72 | experts = model[0] |
| 73 | 73 | ||
| 74 | grouped_kernels = importlib.import_module( | 74 | grouped_kernels = importlib.import_module( |
| 75 | - "torchao_npu.features.training.hifloat8.hifloat8_gmm") | 75 | + "torchao_ascend.features.training.hifloat8.hifloat8_gmm") |
| 76 | 76 | ||
| 77 | recorded = [] | 77 | recorded = [] |
| 78 | 78 | ||
| @@ -98,7 +98,7 @@ def test_from_float_rejects_modules_outside_the_contract(): | |||
| 98 | misread: state-holding modules, foreign forward conventions and | 98 | misread: state-holding modules, foreign forward conventions and |
| 99 | converted subclasses. Rejection is non-mutating. | 99 | converted subclasses. Rejection is non-mutating. |
| 100 | """ | 100 | """ |
| 101 | - from torchao_npu.features.training.hifloat8.hifloat8_gmm import _is_grouped_gemm_leaf | 101 | + from torchao_ascend.features.training.hifloat8.hifloat8_gmm import _is_grouped_gemm_leaf |
| 102 | 102 | ||
| 103 | class _StatelessUnary(torch.nn.Module): | 103 | class _StatelessUnary(torch.nn.Module): |
| 104 | def forward(self, x): | 104 | def forward(self, x): |
| @@ -177,7 +177,7 @@ def test_pickle_roundtrip_preserves_registered_expert_weights(monkeypatch): | |||
| 177 | assert torch.equal(value, values_before[key]) | 177 | assert torch.equal(value, values_before[key]) |
| 178 | 178 | ||
| 179 | grouped_kernels = importlib.import_module( | 179 | grouped_kernels = importlib.import_module( |
| 180 | - "torchao_npu.features.training.hifloat8.hifloat8_gmm") | 180 | + "torchao_ascend.features.training.hifloat8.hifloat8_gmm") |
| 181 | 181 | ||
| 182 | recorded = [] | 182 | recorded = [] |
| 183 | 183 | ||
| @@ -205,7 +205,7 @@ def test_grouped_input_validation_rejects_malformed_calls(): | |||
| 205 | kernel work: these branches sit ahead of the NPU device check, so CPU | 205 | kernel work: these branches sit ahead of the NPU device check, so CPU |
| 206 | tensors exercise them. | 206 | tensors exercise them. |
| 207 | """ | 207 | """ |
| 208 | - from torchao_npu.features.training.hifloat8.hifloat8_gmm import _validate_grouped_inputs | 208 | + from torchao_ascend.features.training.hifloat8.hifloat8_gmm import _validate_grouped_inputs |
| 209 | 209 | ||
| 210 | x = torch.zeros(2, 4, dtype=torch.bfloat16) | 210 | x = torch.zeros(2, 4, dtype=torch.bfloat16) |
| 211 | weight = torch.zeros(1, 6, 4, dtype=torch.bfloat16) | 211 | weight = torch.zeros(1, 6, 4, dtype=torch.bfloat16) |
| @@ -219,7 +219,7 @@ def test_grouped_input_validation_rejects_malformed_calls(): | |||
| 219 | 219 | ||
| 220 | 220 | ||
| 221 | def test_function_entries_reject_non_config_objects(): | 221 | def test_function_entries_reject_non_config_objects(): |
| 222 | - from torchao_npu.features.training.hifloat8 import hifloat8_linear | 222 | + from torchao_ascend.features.training.hifloat8 import hifloat8_linear |
| 223 | 223 | ||
| 224 | with pytest.raises(TypeError, match="config must be a HiFloat8BaseConfig"): | 224 | with pytest.raises(TypeError, match="config must be a HiFloat8BaseConfig"): |
| 225 | hifloat8_linear(torch.zeros(2, 4, dtype=torch.bfloat16), | 225 | hifloat8_linear(torch.zeros(2, 4, dtype=torch.bfloat16), |
| @@ -232,10 +232,10 @@ def test_quantize_grouped_static_scale_keeps_layout_discipline(monkeypatch): | |||
| 232 | contiguous layout, ship the transpose view) and passes the caller's | 232 | contiguous layout, ship the transpose view) and passes the caller's |
| 233 | scale through untouched. | 233 | scale through untouched. |
| 234 | """ | 234 | """ |
| 235 | - from torchao_npu.features.training.hifloat8.hifloat8_gmm import _quantize_grouped | 235 | + from torchao_ascend.features.training.hifloat8.hifloat8_gmm import _quantize_grouped |
| 236 | 236 | ||
| 237 | grouped_kernels = importlib.import_module( | 237 | grouped_kernels = importlib.import_module( |
| 238 | - "torchao_npu.features.training.hifloat8.hifloat8_gmm") | 238 | + "torchao_ascend.features.training.hifloat8.hifloat8_gmm") |
| 239 | 239 | ||
| 240 | calls = [] | 240 | calls = [] |
| 241 | 241 | ||
| @@ -17,7 +17,7 @@ import torch_npu | |||
| 17 | from torch import nn | 17 | from torch import nn |
| 18 | from torchao.quantization import quantize_ | 18 | from torchao.quantization import quantize_ |
| 19 | 19 | ||
| 20 | -from torchao_npu.features.inference.lightning_indexer import ( | 20 | +from torchao_ascend.features.inference.lightning_indexer import ( |
| 21 | LightningIndexerMXFP4Config, | 21 | LightningIndexerMXFP4Config, |
| 22 | LightningIndexerMXFP4ReplaceConfig, | 22 | LightningIndexerMXFP4ReplaceConfig, |
| 23 | UnsupportedLightningIndexerConfig, | 23 | UnsupportedLightningIndexerConfig, |
| @@ -25,10 +25,10 @@ from torchao_npu.features.inference.lightning_indexer import ( | |||
| 25 | mxfp4_indexer, | 25 | mxfp4_indexer, |
| 26 | mxfp4_transform, | 26 | mxfp4_transform, |
| 27 | ) | 27 | ) |
| 28 | -from torchao_npu.features.inference.lightning_indexer.mxfp4_transform import ( | 28 | +from torchao_ascend.features.inference.lightning_indexer.mxfp4_transform import ( |
| 29 | mxfp4_lightning_indexer_forward, | 29 | mxfp4_lightning_indexer_forward, |
| 30 | ) | 30 | ) |
| 31 | -from torchao_npu.features.qat.lightning_indexer import ( | 31 | +from torchao_ascend.features.qat.lightning_indexer import ( |
| 32 | LightningIndexerQATConfig, | 32 | LightningIndexerQATConfig, |
| 33 | indexer_teacher_loss, | 33 | indexer_teacher_loss, |
| 34 | is_lightning_indexer_qat_active, | 34 | is_lightning_indexer_qat_active, |
| @@ -12,12 +12,12 @@ import torch | |||
| 12 | import torch_npu | 12 | import torch_npu |
| 13 | from torchao.quantization import quantize_ | 13 | from torchao.quantization import quantize_ |
| 14 | 14 | ||
| 15 | -from torchao_npu.features.inference.lightning_indexer import ( | 15 | +from torchao_ascend.features.inference.lightning_indexer import ( |
| 16 | LightningIndexerMXFP4Config, | 16 | LightningIndexerMXFP4Config, |
| 17 | mxfp4_indexer, | 17 | mxfp4_indexer, |
| 18 | ) | 18 | ) |
| 19 | -from torchao_npu.features.qat.lightning_indexer import LightningIndexerQATConfig, mxfp4_indexer_qat | 19 | +from torchao_ascend.features.qat.lightning_indexer import LightningIndexerQATConfig, mxfp4_indexer_qat |
| 20 | -from torchao_npu.features.qat.w4a8 import W4A8QATConfig, is_w4a8_qat_active, w4a8_moe_filter | 20 | +from torchao_ascend.features.qat.w4a8 import W4A8QATConfig, is_w4a8_qat_active, w4a8_moe_filter |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | @pytest.fixture | 23 | @pytest.fixture |
| @@ -15,8 +15,8 @@ import torchao.prototype.mx_formats.mx_tensor as mx_tensor_mod | |||
| 15 | from torchao.prototype.mx_formats.mx_tensor import MXTensor | 15 | from torchao.prototype.mx_formats.mx_tensor import MXTensor |
| 16 | from torchao.quantization.quantize_.common import KernelPreference | 16 | from torchao.quantization.quantize_.common import KernelPreference |
| 17 | 17 | ||
| 18 | -import torchao_npu # noqa: F401 # import 即完成 patch,与生产路径一致 | 18 | +import torchao_ascend # noqa: F401 # import 即完成 patch,与生产路径一致 |
| 19 | -from torchao_npu.ops.registry import _OPERATOR_REGISTRY # noqa: SLF001 | 19 | +from torchao_ascend.ops.registry import _OPERATOR_REGISTRY # noqa: SLF001 |
| 20 | 20 | ||
| 21 | _DISPATCH = mx_tensor_mod._addmm_mx_dispatch | 21 | _DISPATCH = mx_tensor_mod._addmm_mx_dispatch |
| 22 | 22 | ||
| @@ -16,10 +16,10 @@ Covers three areas: | |||
| 16 | import pytest | 16 | import pytest |
| 17 | import torch | 17 | import torch |
| 18 | 18 | ||
| 19 | -from torchao_npu.features.distributed import PreQuantWeight | 19 | +from torchao_ascend.features.distributed import PreQuantWeight |
| 20 | -from torchao_npu.features.training.mxfp8 import MXFP8LinearConfig | 20 | +from torchao_ascend.features.training.mxfp8 import MXFP8LinearConfig |
| 21 | -from torchao_npu.features.training.mxfp8 import _mx_linear_transform | 21 | +from torchao_ascend.features.training.mxfp8 import _mx_linear_transform |
| 22 | -from torchao_npu.features.training.mxfp8 import ( | 22 | +from torchao_ascend.features.training.mxfp8 import ( |
| 23 | MXFP8GMM, | 23 | MXFP8GMM, |
| 24 | weight_quant_gmm, | 24 | weight_quant_gmm, |
| 25 | ) | 25 | ) |
| @@ -16,8 +16,8 @@ from unittest.mock import Mock, patch | |||
| 16 | import pytest | 16 | import pytest |
| 17 | import torch | 17 | import torch |
| 18 | 18 | ||
| 19 | -from torchao_npu.features.distributed import PostQuantWeight | 19 | +from torchao_ascend.features.distributed import PostQuantWeight |
| 20 | -from torchao_npu.features.training.mxfp8 import ( | 20 | +from torchao_ascend.features.training.mxfp8 import ( |
| 21 | MXFP8GMM, | 21 | MXFP8GMM, |
| 22 | mx_quant_group_gemm, | 22 | mx_quant_group_gemm, |
| 23 | weight_quant_gmm, | 23 | weight_quant_gmm, |
| @@ -67,7 +67,7 @@ def test_weight_quant_gmm_2d_quantizes_in_op_layout_no_transpose(): | |||
| 67 | captured = {} | 67 | captured = {} |
| 68 | 68 | ||
| 69 | with patch( | 69 | with patch( |
| 70 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", | 70 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", |
| 71 | side_effect=_quantizer_mock(captured), | 71 | side_effect=_quantizer_mock(captured), |
| 72 | ): | 72 | ): |
| 73 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") | 73 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") |
| @@ -85,7 +85,7 @@ def test_weight_quant_gmm_3d_transposes_to_op_layout(): | |||
| 85 | captured = {} | 85 | captured = {} |
| 86 | 86 | ||
| 87 | with patch( | 87 | with patch( |
| 88 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", | 88 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", |
| 89 | side_effect=_quantizer_mock(captured), | 89 | side_effect=_quantizer_mock(captured), |
| 90 | ): | 90 | ): |
| 91 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") | 91 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") |
| @@ -105,7 +105,7 @@ def test_storage_layout_round_trip_preserves_quantized_op_layout(): | |||
| 105 | captured = {} | 105 | captured = {} |
| 106 | weight = torch.randn(*stored_shape) | 106 | weight = torch.randn(*stored_shape) |
| 107 | with patch( | 107 | with patch( |
| 108 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", | 108 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", |
| 109 | side_effect=_quantizer_mock(captured), | 109 | side_effect=_quantizer_mock(captured), |
| 110 | ): | 110 | ): |
| 111 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") | 111 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") |
| @@ -121,7 +121,7 @@ def test_weight_quant_gmm_3d_op_layout_quantizes_without_transpose(): | |||
| 121 | captured = {} | 121 | captured = {} |
| 122 | 122 | ||
| 123 | with patch( | 123 | with patch( |
| 124 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", | 124 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", |
| 125 | side_effect=_quantizer_mock(captured), | 125 | side_effect=_quantizer_mock(captured), |
| 126 | ): | 126 | ): |
| 127 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") | 127 | weight_fwd, _, weight_bwd, _ = weight_quant_gmm(weight, torch.bfloat16, (-1, k, n), quant_format="E4M3") |
| @@ -154,11 +154,11 @@ def test_post_quant_path_views_fwd_pair_in_gmm_layout(): | |||
| 154 | 154 | ||
| 155 | with ( | 155 | with ( |
| 156 | patch( | 156 | patch( |
| 157 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant", | 157 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant", |
| 158 | return_value=(x, torch.ones(8, 1)), | 158 | return_value=(x, torch.ones(8, 1)), |
| 159 | ), | 159 | ), |
| 160 | patch( | 160 | patch( |
| 161 | - "torchao_npu.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", | 161 | + "torchao_ascend.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", |
| 162 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), | 162 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), |
| 163 | ) as grouped_matmul, | 163 | ) as grouped_matmul, |
| 164 | ): | 164 | ): |
| @@ -182,11 +182,11 @@ def test_post_quant_path_keeps_3d_op_layout_storage(): | |||
| 182 | 182 | ||
| 183 | with ( | 183 | with ( |
| 184 | patch( | 184 | patch( |
| 185 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant", | 185 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant", |
| 186 | return_value=(x, torch.ones(8, 1)), | 186 | return_value=(x, torch.ones(8, 1)), |
| 187 | ), | 187 | ), |
| 188 | patch( | 188 | patch( |
| 189 | - "torchao_npu.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", | 189 | + "torchao_ascend.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", |
| 190 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), | 190 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), |
| 191 | ) as grouped_matmul, | 191 | ) as grouped_matmul, |
| 192 | ): | 192 | ): |
| @@ -209,15 +209,15 @@ def test_plain_weight_3d_op_layout_quantizes_without_transpose(): | |||
| 209 | 209 | ||
| 210 | with ( | 210 | with ( |
| 211 | patch( | 211 | patch( |
| 212 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant", | 212 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant", |
| 213 | return_value=(x, torch.ones(8, 1)), | 213 | return_value=(x, torch.ones(8, 1)), |
| 214 | ), | 214 | ), |
| 215 | patch( | 215 | patch( |
| 216 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", | 216 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", |
| 217 | side_effect=_quantizer_mock(captured), | 217 | side_effect=_quantizer_mock(captured), |
| 218 | ), | 218 | ), |
| 219 | patch( | 219 | patch( |
| 220 | - "torchao_npu.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", | 220 | + "torchao_ascend.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", |
| 221 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), | 221 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), |
| 222 | ) as grouped_matmul, | 222 | ) as grouped_matmul, |
| 223 | ): | 223 | ): |
| @@ -245,15 +245,15 @@ def test_plain_weight_grad_enabled_quantizes_bwd_pair_transposed(): | |||
| 245 | 245 | ||
| 246 | with ( | 246 | with ( |
| 247 | patch( | 247 | patch( |
| 248 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant", | 248 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant", |
| 249 | return_value=(x, torch.ones(8, 1)), | 249 | return_value=(x, torch.ones(8, 1)), |
| 250 | ), | 250 | ), |
| 251 | patch( | 251 | patch( |
| 252 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", | 252 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", |
| 253 | side_effect=_quantizer_mock(captured), | 253 | side_effect=_quantizer_mock(captured), |
| 254 | ), | 254 | ), |
| 255 | patch( | 255 | patch( |
| 256 | - "torchao_npu.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", | 256 | + "torchao_ascend.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", |
| 257 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), | 257 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), |
| 258 | ) as grouped_matmul, | 258 | ) as grouped_matmul, |
| 259 | ): | 259 | ): |
| @@ -283,11 +283,11 @@ def test_plain_weight_inference_skips_backward_pair(): | |||
| 283 | 283 | ||
| 284 | with ( | 284 | with ( |
| 285 | patch( | 285 | patch( |
| 286 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant", | 286 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant", |
| 287 | side_effect=fake_quant, | 287 | side_effect=fake_quant, |
| 288 | ), | 288 | ), |
| 289 | patch( | 289 | patch( |
| 290 | - "torchao_npu.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", | 290 | + "torchao_ascend.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", |
| 291 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), | 291 | return_value=torch.zeros(8, n, dtype=torch.bfloat16), |
| 292 | ) as grouped_matmul, | 292 | ) as grouped_matmul, |
| 293 | ): | 293 | ): |
| @@ -334,35 +334,35 @@ def test_mxfp8_gmm_propagates_owner_and_attr(entry): | |||
| 334 | with ExitStack() as stack: | 334 | with ExitStack() as stack: |
| 335 | if x.device.type == "cpu": | 335 | if x.device.type == "cpu": |
| 336 | stack.enter_context(patch( | 336 | stack.enter_context(patch( |
| 337 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant", | 337 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant", |
| 338 | side_effect=lambda x, **kw: (x.clone(), torch.ones_like(x)), | 338 | side_effect=lambda x, **kw: (x.clone(), torch.ones_like(x)), |
| 339 | )) | 339 | )) |
| 340 | stack.enter_context(patch( | 340 | stack.enter_context(patch( |
| 341 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", | 341 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant_with_dual_axis", |
| 342 | side_effect=_quantizer_mock({}), | 342 | side_effect=_quantizer_mock({}), |
| 343 | )) | 343 | )) |
| 344 | stack.enter_context( | 344 | stack.enter_context( |
| 345 | patch( | 345 | patch( |
| 346 | - "torchao_npu.features.training.mxfp8.mx_gmm.swiglu", | 346 | + "torchao_ascend.features.training.mxfp8.mx_gmm.swiglu", |
| 347 | return_value=fc2_input, | 347 | return_value=fc2_input, |
| 348 | ) | 348 | ) |
| 349 | ) | 349 | ) |
| 350 | grouped_matmul = stack.enter_context( | 350 | grouped_matmul = stack.enter_context( |
| 351 | patch( | 351 | patch( |
| 352 | - "torchao_npu.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", | 352 | + "torchao_ascend.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", |
| 353 | return_value=torch.zeros(4, 64, device=_device(), dtype=torch.bfloat16), | 353 | return_value=torch.zeros(4, 64, device=_device(), dtype=torch.bfloat16), |
| 354 | ) | 354 | ) |
| 355 | ) | 355 | ) |
| 356 | if entry == "forward": | 356 | if entry == "forward": |
| 357 | stack.enter_context( | 357 | stack.enter_context( |
| 358 | patch( | 358 | patch( |
| 359 | - "torchao_npu.features.training.mxfp8.mx_gmm.permute", | 359 | + "torchao_ascend.features.training.mxfp8.mx_gmm.permute", |
| 360 | return_value=(permuted, torch.arange(4)), | 360 | return_value=(permuted, torch.arange(4)), |
| 361 | ) | 361 | ) |
| 362 | ) | 362 | ) |
| 363 | stack.enter_context( | 363 | stack.enter_context( |
| 364 | patch( | 364 | patch( |
| 365 | - "torchao_npu.features.training.mxfp8.mx_gmm.unpermute", | 365 | + "torchao_ascend.features.training.mxfp8.mx_gmm.unpermute", |
| 366 | return_value=torch.zeros(4, hidden, device=_device(), dtype=torch.bfloat16), | 366 | return_value=torch.zeros(4, hidden, device=_device(), dtype=torch.bfloat16), |
| 367 | ) | 367 | ) |
| 368 | ) | 368 | ) |
| @@ -414,7 +414,7 @@ def test_mxfp8_gmm_propagates_owner_and_attr(entry): | |||
| 414 | # ep_forward_fused / ep_forward_eager tests | 414 | # ep_forward_fused / ep_forward_eager tests |
| 415 | # ============================================================================ | 415 | # ============================================================================ |
| 416 | 416 | ||
| 417 | -_MX_GMM = 'torchao_npu.features.training.mxfp8.mx_gmm' | 417 | +_MX_GMM = 'torchao_ascend.features.training.mxfp8.mx_gmm' |
| 418 | 418 | ||
| 419 | # Shape constants shared by all EP tests. | 419 | # Shape constants shared by all EP tests. |
| 420 | _EP_EXPERTS = 2 | 420 | _EP_EXPERTS = 2 |
| @@ -772,7 +772,7 @@ def test_ep_forward_reads_callbacks_from_quant_config_not_self_config(): | |||
| 772 | ``config`` attribute on ``self.config``; _ep_forward must read EP dispatch | 772 | ``config`` attribute on ``self.config``; _ep_forward must read EP dispatch |
| 773 | callbacks from ``_quant_config`` (the MXFP8GMMConfig), not ``self.config``. | 773 | callbacks from ``_quant_config`` (the MXFP8GMMConfig), not ``self.config``. |
| 774 | """ | 774 | """ |
| 775 | - from torchao_npu.features.training.mxfp8 import MXFP8GMMConfig | 775 | + from torchao_ascend.features.training.mxfp8 import MXFP8GMMConfig |
| 776 | 776 | ||
| 777 | e, k, n = 2, 8, 16 | 777 | e, k, n = 2, 8, 16 |
| 778 | mod = _FakeGMMModule( | 778 | mod = _FakeGMMModule( |
| @@ -8,7 +8,7 @@ dtypes are translated to the torch_npu codes. | |||
| 8 | """ | 8 | """ |
| 9 | import torch | 9 | import torch |
| 10 | 10 | ||
| 11 | -from torchao_npu.ops.npu import mx_ops | 11 | +from torchao_ascend.ops.npu import mx_ops |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | class _Recorder: | 14 | class _Recorder: |
| @@ -11,11 +11,11 @@ real NPU kernels are covered by | |||
| 11 | 11 | ||
| 12 | Verifies that the patched autograd chain composes and backpropagates: | 12 | Verifies that the patched autograd chain composes and backpropagates: |
| 13 | 13 | ||
| 14 | - a2a_dispatch_mxfp8_fwd_hp_bwd (torchao_npu patch, this PR) | 14 | + a2a_dispatch_mxfp8_fwd_hp_bwd (torchao_ascend patch, this PR) |
| 15 | - -> permute_mxfp8_fwd_hp_bwd (torchao_npu PR #68 patch) | 15 | + -> permute_mxfp8_fwd_hp_bwd (torchao_ascend PR #68 patch) |
| 16 | - -> _to_mxfp8_then_scaled_grouped_mm (torchao_npu patch, EMULATED) | 16 | + -> _to_mxfp8_then_scaled_grouped_mm (torchao_ascend patch, EMULATED) |
| 17 | - -> unpermute_hp_fwd_mxfp8_bwd (torchao_npu PR #68 patch) | 17 | + -> unpermute_hp_fwd_mxfp8_bwd (torchao_ascend PR #68 patch) |
| 18 | - a2a_combine_hp_fwd_mxfp8_bwd (torchao_npu patch, this PR) | 18 | + a2a_combine_hp_fwd_mxfp8_bwd (torchao_ascend patch, this PR) |
| 19 | 19 | ||
| 20 | Seams (all late-bound in the patched bodies, mocked here; real kernels are | 20 | Seams (all late-bound in the patched bodies, mocked here; real kernels are |
| 21 | covered by the NPU tests): | 21 | covered by the NPU tests): |
| @@ -45,7 +45,7 @@ import torch | |||
| 45 | 45 | ||
| 46 | # CPU-only dev boxes have neither torch_npu nor triton; the upstream ep | 46 | # CPU-only dev boxes have neither torch_npu nor triton; the upstream ep |
| 47 | # module tree imports triton at top level, so gate on both before importing | 47 | # module tree imports triton at top level, so gate on both before importing |
| 48 | -# torchao_npu (real backends on NPU hosts make these a no-op). | 48 | +# torchao_ascend (real backends on NPU hosts make these a no-op). |
| 49 | pytest.importorskip("torch_npu", reason="requires torch_npu (NPU host)") | 49 | pytest.importorskip("torch_npu", reason="requires torch_npu (NPU host)") |
| 50 | pytest.importorskip("triton", reason="requires triton (triton-ascend on NPU hosts)") | 50 | pytest.importorskip("triton", reason="requires triton (triton-ascend on NPU hosts)") |
| 51 | 51 | ||
| @@ -67,8 +67,8 @@ from torchao.prototype.moe_training.ep.kernels import fill_indices_cpu # noqa: | |||
| 67 | from torchao.prototype.moe_training import _to_mxfp8_then_scaled_grouped_mm # noqa: E402 | 67 | from torchao.prototype.moe_training import _to_mxfp8_then_scaled_grouped_mm # noqa: E402 |
| 68 | from torchao.quantization.quantize_.common import KernelPreference # noqa: E402 | 68 | from torchao.quantization.quantize_.common import KernelPreference # noqa: E402 |
| 69 | 69 | ||
| 70 | -import torchao_npu # noqa: F401,E402 # patch activation | 70 | +import torchao_ascend # noqa: F401,E402 # patch activation |
| 71 | -from torchao_npu.patches.torchao.prototype.moe_training.ep import ( # noqa: E402 | 71 | +from torchao_ascend.patches.torchao.prototype.moe_training.ep import ( # noqa: E402 |
| 72 | permute as npu_permute_mod, | 72 | permute as npu_permute_mod, |
| 73 | ) | 73 | ) |
| 74 | 74 | ||
| @@ -17,14 +17,14 @@ import torchao.prototype.moe_training.mxfp8_linear as mxfp8_linear_mod | |||
| 17 | from torchao.prototype.mx_formats.config import ScaleCalculationMode | 17 | from torchao.prototype.mx_formats.config import ScaleCalculationMode |
| 18 | from torchao.quantization.quantize_.common import KernelPreference | 18 | from torchao.quantization.quantize_.common import KernelPreference |
| 19 | 19 | ||
| 20 | -from torchao_npu.features.distributed import ( | 20 | +from torchao_ascend.features.distributed import ( |
| 21 | MXFP8WeightPhase, | 21 | MXFP8WeightPhase, |
| 22 | PostQuantWeight, | 22 | PostQuantWeight, |
| 23 | PreQuantWeight, | 23 | PreQuantWeight, |
| 24 | resolve_live_post_quant_weight, | 24 | resolve_live_post_quant_weight, |
| 25 | ) | 25 | ) |
| 26 | -from torchao_npu.features.training.mxfp8 import mx_quant_group_gemm | 26 | +from torchao_ascend.features.training.mxfp8 import mx_quant_group_gemm |
| 27 | -from torchao_npu.features.training.mxfp8 import ( | 27 | +from torchao_ascend.features.training.mxfp8 import ( |
| 28 | MXFP8LinearConfig, | 28 | MXFP8LinearConfig, |
| 29 | ) | 29 | ) |
| 30 | 30 | ||
| @@ -60,7 +60,7 @@ def test_live_weight_is_resolved_after_recompute_before_backward(): | |||
| 60 | 60 | ||
| 61 | with pytest.raises(RuntimeError, match="backward weight is not resident"): | 61 | with pytest.raises(RuntimeError, match="backward weight is not resident"): |
| 62 | forward_weight.get_backward_pair() | 62 | forward_weight.get_backward_pair() |
| 63 | - with patch("torchao_npu.features.distributed.recompute_phase.ensure_mxfp8_backward_phase") as ensure_phase: | 63 | + with patch("torchao_ascend.features.distributed.recompute_phase.ensure_mxfp8_backward_phase") as ensure_phase: |
| 64 | resolved = resolve_live_post_quant_weight(forward_weight, weakref.ref(owner), "weight") | 64 | resolved = resolve_live_post_quant_weight(forward_weight, weakref.ref(owner), "weight") |
| 65 | 65 | ||
| 66 | ensure_phase.assert_called_once_with(owner) | 66 | ensure_phase.assert_called_once_with(owner) |
| @@ -82,7 +82,7 @@ def test_live_owner_shape_mismatch_fails_closed(): | |||
| 82 | ) | 82 | ) |
| 83 | 83 | ||
| 84 | with ( | 84 | with ( |
| 85 | - patch("torchao_npu.features.distributed.recompute_phase.ensure_mxfp8_backward_phase"), | 85 | + patch("torchao_ascend.features.distributed.recompute_phase.ensure_mxfp8_backward_phase"), |
| 86 | pytest.raises(RuntimeError, match="shape changed across recompute"), | 86 | pytest.raises(RuntimeError, match="shape changed across recompute"), |
| 87 | ): | 87 | ): |
| 88 | resolve_live_post_quant_weight(saved_weight, weakref.ref(owner), "weight") | 88 | resolve_live_post_quant_weight(saved_weight, weakref.ref(owner), "weight") |
| @@ -117,14 +117,14 @@ def test_linear_autograd_backward_uses_live_owner_weight(): | |||
| 117 | 117 | ||
| 118 | with ( | 118 | with ( |
| 119 | patch( | 119 | patch( |
| 120 | - "torchao_npu.ops.npu.mx_ops.dynamic_mx_quant_with_dual_axis", | 120 | + "torchao_ascend.ops.npu.mx_ops.dynamic_mx_quant_with_dual_axis", |
| 121 | side_effect=_fake_dual_axis_quant, | 121 | side_effect=_fake_dual_axis_quant, |
| 122 | ), | 122 | ), |
| 123 | patch( | 123 | patch( |
| 124 | - "torchao_npu.ops.npu.mx_ops.mx_quant_matmul", | 124 | + "torchao_ascend.ops.npu.mx_ops.mx_quant_matmul", |
| 125 | side_effect=lambda lhs, rhs, *_args, **_kwargs: lhs @ rhs, | 125 | side_effect=lambda lhs, rhs, *_args, **_kwargs: lhs @ rhs, |
| 126 | ), | 126 | ), |
| 127 | - patch("torchao_npu.features.distributed.recompute_phase.ensure_mxfp8_backward_phase"), | 127 | + patch("torchao_ascend.features.distributed.recompute_phase.ensure_mxfp8_backward_phase"), |
| 128 | ): | 128 | ): |
| 129 | output = mxfp8_linear_mod.mx_mm.apply(input_tensor, stale_weight, *_MX_MM_ARGS, owner) | 129 | output = mxfp8_linear_mod.mx_mm.apply(input_tensor, stale_weight, *_MX_MM_ARGS, owner) |
| 130 | owner.weight = live_weight | 130 | owner.weight = live_weight |
| @@ -146,11 +146,11 @@ def test_gmm_propagates_canonical_owner_attribute(weight_attr): | |||
| 146 | 146 | ||
| 147 | with ( | 147 | with ( |
| 148 | patch( | 148 | patch( |
| 149 | - "torchao_npu.features.training.mxfp8.mx_gmm.dynamic_mx_quant", | 149 | + "torchao_ascend.features.training.mxfp8.mx_gmm.dynamic_mx_quant", |
| 150 | return_value=(input_tensor, torch.ones(4, 2)), | 150 | return_value=(input_tensor, torch.ones(4, 2)), |
| 151 | ), | 151 | ), |
| 152 | patch( | 152 | patch( |
| 153 | - "torchao_npu.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", | 153 | + "torchao_ascend.features.training.mxfp8.mx_gmm.mx_quant_grouped_matmul", |
| 154 | return_value=expected, | 154 | return_value=expected, |
| 155 | ) as grouped_matmul, | 155 | ) as grouped_matmul, |
| 156 | ): | 156 | ): |
| @@ -195,7 +195,7 @@ def test_linear_autograd_backward_uses_plain_weight(): | |||
| 195 | 195 | ||
| 196 | with ( | 196 | with ( |
| 197 | patch( | 197 | patch( |
| 198 | - "torchao_npu.patches.torchao.prototype.mx_formats.utils.npu_dynamic_mx_quantize", | 198 | + "torchao_ascend.patches.torchao.prototype.mx_formats.utils.npu_dynamic_mx_quantize", |
| 199 | side_effect=_fake_npu_quantize, | 199 | side_effect=_fake_npu_quantize, |
| 200 | ), | 200 | ), |
| 201 | patch( | 201 | patch( |
| @@ -263,11 +263,11 @@ def test_pre_quant_all_gather_selects_pairs(mode, phase, expected, exp_fwd, exp_ | |||
| 263 | 263 | ||
| 264 | with ( | 264 | with ( |
| 265 | patch( | 265 | patch( |
| 266 | - "torchao_npu.features.distributed.pre_quant_weight.get_module_fsdp_state", | 266 | + "torchao_ascend.features.distributed.pre_quant_weight.get_module_fsdp_state", |
| 267 | return_value=_fsdp_state_mock(), | 267 | return_value=_fsdp_state_mock(), |
| 268 | ), | 268 | ), |
| 269 | patch( | 269 | patch( |
| 270 | - "torchao_npu.features.distributed.pre_quant_weight.select_recompute_aware_phase", | 270 | + "torchao_ascend.features.distributed.pre_quant_weight.select_recompute_aware_phase", |
| 271 | return_value=phase, | 271 | return_value=phase, |
| 272 | ), | 272 | ), |
| 273 | ): | 273 | ): |
| @@ -1,7 +1,7 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd |
| 2 | 2 | ||
| 3 | # -*- coding: utf-8 -*- | 3 | # -*- coding: utf-8 -*- |
| 4 | -"""L1 no-card unit tests for torchao_npu.ops registry (registry.py). | 4 | +"""L1 no-card unit tests for torchao_ascend.ops registry (registry.py). |
| 5 | 5 | ||
| 6 | Covers the (op_name, backend) registry ported from FSDPTurbo: register_op | 6 | Covers the (op_name, backend) registry ported from FSDPTurbo: register_op |
| 7 | lookup via get_op/dispatch_op, backend=None accelerator inference (CPU | 7 | lookup via get_op/dispatch_op, backend=None accelerator inference (CPU |
| @@ -14,10 +14,10 @@ from types import SimpleNamespace | |||
| 14 | import pytest | 14 | import pytest |
| 15 | import torch | 15 | import torch |
| 16 | 16 | ||
| 17 | -import torchao_npu # noqa: F401 # import 即完成 patch,与生产路径一致 | 17 | +import torchao_ascend # noqa: F401 # import 即完成 patch,与生产路径一致 |
| 18 | -from torchao_npu.ops import registry | 18 | +from torchao_ascend.ops import registry |
| 19 | -from torchao_npu.ops import dispatch_op, get_op, register_op | 19 | +from torchao_ascend.ops import dispatch_op, get_op, register_op |
| 20 | -from torchao_npu.utils import log_warning_once | 20 | +from torchao_ascend.utils import log_warning_once |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | @pytest.fixture(autouse=True) | 23 | @pytest.fixture(autouse=True) |
| @@ -136,7 +136,7 @@ def test_implicit_fallback_returns_cpu_impl_with_warning_once(npu_accelerator, c | |||
| 136 | def _cpu_impl(): | 136 | def _cpu_impl(): |
| 137 | return "cpu" | 137 | return "cpu" |
| 138 | 138 | ||
| 139 | - with caplog.at_level(logging.WARNING, logger="torchao_npu.utils"): | 139 | + with caplog.at_level(logging.WARNING, logger="torchao_ascend.utils"): |
| 140 | assert dispatch_op("probe_op_implicit_fallback") == "cpu" | 140 | assert dispatch_op("probe_op_implicit_fallback") == "cpu" |
| 141 | # 再次请求:仍是 CPU 兜底,但 warning 只打一次 | 141 | # 再次请求:仍是 CPU 兜底,但 warning 只打一次 |
| 142 | assert dispatch_op("probe_op_implicit_fallback") == "cpu" | 142 | assert dispatch_op("probe_op_implicit_fallback") == "cpu" |
| @@ -157,7 +157,7 @@ def test_explicit_cpu_backend_does_not_warn(caplog): | |||
| 157 | def _cpu_impl(): | 157 | def _cpu_impl(): |
| 158 | return "cpu" | 158 | return "cpu" |
| 159 | 159 | ||
| 160 | - with caplog.at_level(logging.WARNING, logger="torchao_npu.utils"): | 160 | + with caplog.at_level(logging.WARNING, logger="torchao_ascend.utils"): |
| 161 | assert dispatch_op("probe_op_explicit_cpu", backend="cpu") == "cpu" | 161 | assert dispatch_op("probe_op_explicit_cpu", backend="cpu") == "cpu" |
| 162 | 162 | ||
| 163 | assert not [ | 163 | assert not [ |
| @@ -166,8 +166,8 @@ def test_explicit_cpu_backend_does_not_warn(caplog): | |||
| 166 | 166 | ||
| 167 | 167 | ||
| 168 | def test_log_warning_once_dedups(caplog): | 168 | def test_log_warning_once_dedups(caplog): |
| 169 | - target = logging.getLogger("torchao_npu.test_log_warning_once") | 169 | + target = logging.getLogger("torchao_ascend.test_log_warning_once") |
| 170 | - with caplog.at_level(logging.WARNING, logger="torchao_npu.test_log_warning_once"): | 170 | + with caplog.at_level(logging.WARNING, logger="torchao_ascend.test_log_warning_once"): |
| 171 | log_warning_once(target, "unique-dedup-message") | 171 | log_warning_once(target, "unique-dedup-message") |
| 172 | log_warning_once(target, "unique-dedup-message") | 172 | log_warning_once(target, "unique-dedup-message") |
| 173 | 173 | ||
| @@ -3,7 +3,7 @@ | |||
| 3 | """CPU unit tests for the HF safetensors export (MXFP8 / FP8 scope). | 3 | """CPU unit tests for the HF safetensors export (MXFP8 / FP8 scope). |
| 4 | 4 | ||
| 5 | Tensors are built through their constructors directly (no quantization kernel | 5 | Tensors are built through their constructors directly (no quantization kernel |
| 6 | -calls), so the tests are device-agnostic and independent of the torchao_npu | 6 | +calls), so the tests are device-agnostic and independent of the torchao_ascend |
| 7 | autoload patches. | 7 | autoload patches. |
| 8 | """ | 8 | """ |
| 9 | 9 | ||
| @@ -18,8 +18,8 @@ from torchao.prototype.mx_formats.mx_tensor import MXTensor | |||
| 18 | from torchao.quantization.quantize_.common import KernelPreference | 18 | from torchao.quantization.quantize_.common import KernelPreference |
| 19 | from torchao.quantization.quantize_.workflows.float8.float8_tensor import Float8Tensor | 19 | from torchao.quantization.quantize_.workflows.float8.float8_tensor import Float8Tensor |
| 20 | 20 | ||
| 21 | -from torchao_npu.serialization import load_safetensors, save_safetensors | 21 | +from torchao_ascend.serialization import load_safetensors, save_safetensors |
| 22 | -from torchao_npu.serialization.safetensor import _to_bytes | 22 | +from torchao_ascend.serialization.safetensor import _to_bytes |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | def _make_mxfp8(): | 25 | def _make_mxfp8(): |
| @@ -29,12 +29,12 @@ import torch | |||
| 29 | 29 | ||
| 30 | from torchao.quantization import quantize_ | 30 | from torchao.quantization import quantize_ |
| 31 | 31 | ||
| 32 | -import torchao_npu.features.qat.w4a16.w4a16_gmm as w4a16_gmm_module | 32 | +import torchao_ascend.features.qat.w4a16.w4a16_gmm as w4a16_gmm_module |
| 33 | -import torchao_npu.features.qat.w4a16.w4a16_linear as w4a16_linear_module | 33 | +import torchao_ascend.features.qat.w4a16.w4a16_linear as w4a16_linear_module |
| 34 | -from torchao_npu.features.qat import w4a16 | 34 | +from torchao_ascend.features.qat import w4a16 |
| 35 | -from torchao_npu.features.qat.w4a16 import fakequant_rebuild as w4a16_fakequant_rebuild | 35 | +from torchao_ascend.features.qat.w4a16 import fakequant_rebuild as w4a16_fakequant_rebuild |
| 36 | -from torchao_npu.features.qat.w4a16.config import _w4a16_gmm_transform, _w4a16_linear_transform | 36 | +from torchao_ascend.features.qat.w4a16.config import _w4a16_gmm_transform, _w4a16_linear_transform |
| 37 | -from torchao_npu.ops.npu import get_float4_dtype | 37 | +from torchao_ascend.ops.npu import get_float4_dtype |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | class TestW4A16ConfigDtypeDispatch: | 40 | class TestW4A16ConfigDtypeDispatch: |
| @@ -31,8 +31,8 @@ import torchao # noqa: E402,F401 | |||
| 31 | from torchao.quantization import quantize_ # noqa: E402 | 31 | from torchao.quantization import quantize_ # noqa: E402 |
| 32 | from torchao.quantization.transform_module import _QUANTIZE_CONFIG_HANDLER # noqa: E402 | 32 | from torchao.quantization.transform_module import _QUANTIZE_CONFIG_HANDLER # noqa: E402 |
| 33 | 33 | ||
| 34 | -import torchao_npu # noqa: E402,F401 | 34 | +import torchao_ascend # noqa: E402,F401 |
| 35 | -from torchao_npu.features.qat.mxfp8 import ( # noqa: E402 | 35 | +from torchao_ascend.features.qat.mxfp8 import ( # noqa: E402 |
| 36 | MXFP8FakeQuantization, | 36 | MXFP8FakeQuantization, |
| 37 | MXFP8GMMQAT, | 37 | MXFP8GMMQAT, |
| 38 | MXFP8GMMQATConfig, | 38 | MXFP8GMMQATConfig, |
| @@ -100,7 +100,7 @@ class TestNamespace: | |||
| 100 | 100 | ||
| 101 | def test_import_surface(self): | 101 | def test_import_surface(self): |
| 102 | assert hasattr(torchao, "mxfp8") | 102 | assert hasattr(torchao, "mxfp8") |
| 103 | - assert torchao_npu.mxfp8 is torchao.mxfp8 | 103 | + assert torchao_ascend.mxfp8 is torchao.mxfp8 |
| 104 | import torchao.mxfp8.config as cfg_mod | 104 | import torchao.mxfp8.config as cfg_mod |
| 105 | 105 | ||
| 106 | assert cfg_mod.W8A16LinearConfig is W8A16LinearConfig | 106 | assert cfg_mod.W8A16LinearConfig is W8A16LinearConfig |
| @@ -793,7 +793,7 @@ class TestGmmLayoutGuard: | |||
| 793 | MXFP8GMMQAT.from_float(experts2, block_size=32) | 793 | MXFP8GMMQAT.from_float(experts2, block_size=32) |
| 794 | assert isinstance(experts2, HFStyleExperts) | 794 | assert isinstance(experts2, HFStyleExperts) |
| 795 | # forward-side guard still active | 795 | # forward-side guard still active |
| 796 | - from torchao_npu.features.qat.mxfp8.gmm import ( | 796 | + from torchao_ascend.features.qat.mxfp8.gmm import ( |
| 797 | _resolve_weight, _require_fused_layout, | 797 | _resolve_weight, _require_fused_layout, |
| 798 | ) | 798 | ) |
| 799 | m = nn.Module() | 799 | m = nn.Module() |
| @@ -830,7 +830,7 @@ class TestNpuRoutingBranch: | |||
| 830 | 830 | ||
| 831 | @staticmethod | 831 | @staticmethod |
| 832 | def _run_both(top_k_weights): | 832 | def _run_both(top_k_weights): |
| 833 | - import torchao_npu.features.qat.mxfp8.gmm as gmm_mod | 833 | + import torchao_ascend.features.qat.mxfp8.gmm as gmm_mod |
| 834 | 834 | ||
| 835 | torch.manual_seed(0) | 835 | torch.manual_seed(0) |
| 836 | experts = HFStyleExperts() | 836 | experts = HFStyleExperts() |
| @@ -1,6 +1,6 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd |
| 2 | 2 | ||
| 3 | -"""torchao_npu — run torchao FP8 on Ascend NPU by monkey-patching torchao operators.""" | 3 | +"""torchao_ascend — run torchao FP8 on Ascend NPU by monkey-patching torchao operators.""" |
| 4 | 4 | ||
| 5 | from __future__ import annotations | 5 | from __future__ import annotations |
| 6 | 6 | ||
| @@ -9,14 +9,14 @@ import importlib.util | |||
| 9 | import sys | 9 | import sys |
| 10 | from types import ModuleType | 10 | from types import ModuleType |
| 11 | 11 | ||
| 12 | -from torchao_npu import patches as _patches | 12 | +from torchao_ascend import patches as _patches |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | def _mount_into_torchao() -> None: | 15 | def _mount_into_torchao() -> None: |
| 16 | - """Alias the public feature packages into the torchao_npu and torchao namespaces.""" | 16 | + """Alias the public feature packages into the torchao_ascend and torchao namespaces.""" |
| 17 | import torchao | 17 | import torchao |
| 18 | 18 | ||
| 19 | - from torchao_npu import features, serialization | 19 | + from torchao_ascend import features, serialization |
| 20 | 20 | ||
| 21 | # (namespace name, module) pairs — features first, then serialization; | 21 | # (namespace name, module) pairs — features first, then serialization; |
| 22 | # every entry goes through the identical shadowing-guarded mount below. | 22 | # every entry goes through the identical shadowing-guarded mount below. |
| @@ -45,9 +45,9 @@ def _initialize() -> None: | |||
| 45 | """Apply every patch step and register the NPU-native quantize_ handlers.""" | 45 | """Apply every patch step and register the NPU-native quantize_ handlers.""" |
| 46 | _patches.enable() | 46 | _patches.enable() |
| 47 | 47 | ||
| 48 | - # Importing torchao_npu.features registers every feature declared in its | 48 | + # Importing torchao_ascend.features registers every feature declared in its |
| 49 | # __all__ (the single registration point — new features need no edits | 49 | # __all__ (the single registration point — new features need no edits |
| 50 | - # here); _mount_into_torchao() then mounts them under the torchao_npu | 50 | + # here); _mount_into_torchao() then mounts them under the torchao_ascend |
| 51 | # and torchao namespaces. | 51 | # and torchao namespaces. |
| 52 | _mount_into_torchao() | 52 | _mount_into_torchao() |
| 53 | 53 | ||
| @@ -59,12 +59,12 @@ def activate() -> None: | |||
| 59 | """Idempotent activation entry (trigger path 2). | 59 | """Idempotent activation entry (trigger path 2). |
| 60 | 60 | ||
| 61 | All trigger paths converge on this single core: | 61 | All trigger paths converge on this single core: |
| 62 | - 1. explicit ``import torchao_npu`` -- called automatically at the end | 62 | + 1. explicit ``import torchao_ascend`` -- called automatically at the end |
| 63 | of this ``__init__`` (existing behavior, zero change for callers); | 63 | of this ``__init__`` (existing behavior, zero change for callers); |
| 64 | 2. explicit ``activate()`` -- equivalent to 1, for callers that need | 64 | 2. explicit ``activate()`` -- equivalent to 1, for callers that need |
| 65 | a deterministic init point (test fixtures, training frameworks); | 65 | a deterministic init point (test fixtures, training frameworks); |
| 66 | 3. torch device-backend autoload -- on NPU machines the | 66 | 3. torch device-backend autoload -- on NPU machines the |
| 67 | - ``_torchao_npu_autoload`` hook imports torchao_npu, which is | 67 | + ``_torchao_ascend_autoload`` hook imports torchao_ascend, which is |
| 68 | path 1 again (framework calls activate() on the user's behalf). | 68 | path 1 again (framework calls activate() on the user's behalf). |
| 69 | 69 | ||
| 70 | ``_APPLIED`` guarantees idempotency: whichever path fires first, the | 70 | ``_APPLIED`` guarantees idempotency: whichever path fires first, the |
| @@ -1,5 +1,5 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd |
| 2 | -"""torchao_npu.features.distributed — low-precision all-gather (LP-AG) | 2 | +"""torchao_ascend.features.distributed — low-precision all-gather (LP-AG) |
| 3 | infrastructure for FSDP2 training with MXFP8 quantization on Ascend NPU. | 3 | infrastructure for FSDP2 training with MXFP8 quantization on Ascend NPU. |
| 4 | 4 | ||
| 5 | This package owns the tensor subclasses (``PreQuantWeight``, | 5 | This package owns the tensor subclasses (``PreQuantWeight``, |
| @@ -12,9 +12,9 @@ LP-AG into their FSDP2 orchestration. The weight quantization cache | |||
| 12 | (``cached_weight_quant``, ``clear_weight_cache``, ``hook_optimizer_step``) | 12 | (``cached_weight_quant``, ``clear_weight_cache``, ``hook_optimizer_step``) |
| 13 | is framework-owned and injected via ``MXFP8LinearConfig.weight_quant_fn``. | 13 | is framework-owned and injected via ``MXFP8LinearConfig.weight_quant_fn``. |
| 14 | """ | 14 | """ |
| 15 | -from torchao_npu.features.distributed.post_quant_weight import PostQuantWeight | 15 | +from torchao_ascend.features.distributed.post_quant_weight import PostQuantWeight |
| 16 | -from torchao_npu.features.distributed.pre_quant_weight import PreQuantWeight | 16 | +from torchao_ascend.features.distributed.pre_quant_weight import PreQuantWeight |
| 17 | -from torchao_npu.features.distributed.recompute_phase import ( | 17 | +from torchao_ascend.features.distributed.recompute_phase import ( |
| 18 | MXFP8WeightPhase, | 18 | MXFP8WeightPhase, |
| 19 | ensure_mxfp8_backward_phase, | 19 | ensure_mxfp8_backward_phase, |
| 20 | mark_module_for_recompute, | 20 | mark_module_for_recompute, |
| @@ -23,7 +23,7 @@ from torchao_npu.features.distributed.recompute_phase import ( | |||
| 23 | resolve_live_post_quant_weight, | 23 | resolve_live_post_quant_weight, |
| 24 | select_recompute_aware_phase, | 24 | select_recompute_aware_phase, |
| 25 | ) | 25 | ) |
| 26 | -from torchao_npu.features.distributed.fsdp_protocol import ( | 26 | +from torchao_ascend.features.distributed.fsdp_protocol import ( |
| 27 | FSDPStateProtocol, | 27 | FSDPStateProtocol, |
| 28 | FSDPParamGroupProtocol, | 28 | FSDPParamGroupProtocol, |
| 29 | ) | 29 | ) |
Rtorchao_npu/features/distributed/fsdp_protocol.py→torchao_ascend/features/distributed/fsdp_protocol.py+1-1
| @@ -1,6 +1,6 @@ | |||
| 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved. | 1 | # Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved. |
| 2 | """Structural protocols documenting the FSDP state interface consumed by | 2 | """Structural protocols documenting the FSDP state interface consumed by |
| 3 | -``torchao_npu.features.distributed.recompute_phase``. | 3 | +``torchao_ascend.features.distributed.recompute_phase``. |
| 4 | 4 | ||
| 5 | These are *documentation-only* typing.Protocol classes — FSDPTurbo's | 5 | These are *documentation-only* typing.Protocol classes — FSDPTurbo's |
| 6 | ``FSDPParamGroup`` (which extends PyTorch's ``FSDPParamGroup``) already | 6 | ``FSDPParamGroup`` (which extends PyTorch's ``FSDPParamGroup``) already |
Rtorchao_npu/features/distributed/post_quant_weight.py→torchao_ascend/features/distributed/post_quant_weight.py+0-0
文件重命名但无更改。
Rtorchao_npu/features/distributed/pre_quant_weight.py→torchao_ascend/features/distributed/pre_quant_weight.py+2-2
| @@ -8,8 +8,8 @@ import torch | |||
| 8 | import torch.utils._pytree as pytree | 8 | import torch.utils._pytree as pytree |
| 9 | from torch.distributed.tensor import DTensor | 9 | from torch.distributed.tensor import DTensor |
| 10 | 10 | ||
| 11 | -from torchao_npu.features.distributed.post_quant_weight import PostQuantWeight | 11 | +from torchao_ascend.features.distributed.post_quant_weight import PostQuantWeight |
| 12 | -from torchao_npu.features.distributed.recompute_phase import ( | 12 | +from torchao_ascend.features.distributed.recompute_phase import ( |
| 13 | MXFP8WeightPhase, | 13 | MXFP8WeightPhase, |
| 14 | get_module_fsdp_state, | 14 | get_module_fsdp_state, |
| 15 | select_recompute_aware_phase, | 15 | select_recompute_aware_phase, |
Rtorchao_npu/features/distributed/recompute_phase.py→torchao_ascend/features/distributed/recompute_phase.py+8-8
| @@ -6,13 +6,13 @@ from enum import Enum | |||
| 6 | from threading import Condition, Lock | 6 | from threading import Condition, Lock |
| 7 | from typing import Any | 7 | from typing import Any |
| 8 | 8 | ||
| 9 | -_RECOMPUTE_MODULE_MARKER = "_torchao_npu_activation_recompute" | 9 | +_RECOMPUTE_MODULE_MARKER = "_torchao_ascend_activation_recompute" |
| 10 | -_RECOMPUTE_AWARE_GROUP = "_torchao_npu_mxfp8_recompute_aware" | 10 | +_RECOMPUTE_AWARE_GROUP = "_torchao_ascend_mxfp8_recompute_aware" |
| 11 | -_RECOMPUTE_DEPTH = "_torchao_npu_mxfp8_recompute_depth" | 11 | +_RECOMPUTE_DEPTH = "_torchao_ascend_mxfp8_recompute_depth" |
| 12 | -_WEIGHT_PHASE = "_torchao_npu_mxfp8_weight_phase" | 12 | +_WEIGHT_PHASE = "_torchao_ascend_mxfp8_weight_phase" |
| 13 | -_WEIGHT_PHASE_ERROR = "_torchao_npu_mxfp8_weight_phase_error" | 13 | +_WEIGHT_PHASE_ERROR = "_torchao_ascend_mxfp8_weight_phase_error" |
| 14 | -_WEIGHT_PHASE_TRANSITION = "_torchao_npu_mxfp8_weight_phase_transition" | 14 | +_WEIGHT_PHASE_TRANSITION = "_torchao_ascend_mxfp8_weight_phase_transition" |
| 15 | -_WEIGHT_PHASE_CONDITION = "_torchao_npu_mxfp8_weight_phase_condition" | 15 | +_WEIGHT_PHASE_CONDITION = "_torchao_ascend_mxfp8_weight_phase_condition" |
| 16 | _CONDITION_CREATION_LOCK = Lock() | 16 | _CONDITION_CREATION_LOCK = Lock() |
| 17 | 17 | ||
| 18 | 18 | ||
| @@ -197,7 +197,7 @@ def resolve_live_post_quant_weight(saved_weight: Any, owner_ref: Any, weight_att | |||
| 197 | if hasattr(live_weight, "to_local"): | 197 | if hasattr(live_weight, "to_local"): |
| 198 | live_weight = live_weight.to_local() | 198 | live_weight = live_weight.to_local() |
| 199 | 199 | ||
| 200 | - from torchao_npu.features.distributed.post_quant_weight import PostQuantWeight | 200 | + from torchao_ascend.features.distributed.post_quant_weight import PostQuantWeight |
| 201 | 201 | ||
| 202 | if not isinstance(live_weight, PostQuantWeight): | 202 | if not isinstance(live_weight, PostQuantWeight): |
| 203 | raise TypeError( | 203 | raise TypeError( |
Rtorchao_npu/features/inference/lightning_indexer/__init__.py→torchao_ascend/features/inference/lightning_indexer/__init__.py+0-0
文件重命名但无更改。
Rtorchao_npu/features/inference/lightning_indexer/common.py→torchao_ascend/features/inference/lightning_indexer/common.py+0-0
文件重命名但无更改。
Rtorchao_npu/features/inference/lightning_indexer/config.py→torchao_ascend/features/inference/lightning_indexer/config.py+0-0
文件重命名但无更改。
Rtorchao_npu/features/inference/lightning_indexer/hadamard.py→torchao_ascend/features/inference/lightning_indexer/hadamard.py+0-0
文件重命名但无更改。
Rtorchao_npu/features/inference/lightning_indexer/mxfp4_indexer.py→torchao_ascend/features/inference/lightning_indexer/mxfp4_indexer.py+3-3
| @@ -18,13 +18,13 @@ import torch_npu | |||
| 18 | from torchao.prototype.mx_formats import mx_tensor | 18 | from torchao.prototype.mx_formats import mx_tensor |
| 19 | from torchao.prototype.mx_formats.config import ScaleCalculationMode | 19 | from torchao.prototype.mx_formats.config import ScaleCalculationMode |
| 20 | 20 | ||
| 21 | -from torchao_npu.features.inference.lightning_indexer.common import ( | 21 | +from torchao_ascend.features.inference.lightning_indexer.common import ( |
| 22 | _sequence_shape, | 22 | _sequence_shape, |
| 23 | _validate_tensor_rank, | 23 | _validate_tensor_rank, |
| 24 | v2_sequence_kwargs, | 24 | v2_sequence_kwargs, |
| 25 | ) | 25 | ) |
| 26 | -from torchao_npu.features.inference.lightning_indexer.hadamard import rotate_activation | 26 | +from torchao_ascend.features.inference.lightning_indexer.hadamard import rotate_activation |
| 27 | -from torchao_npu.features.inference.lightning_indexer.config import ( | 27 | +from torchao_ascend.features.inference.lightning_indexer.config import ( |
| 28 | LightningIndexerMXFP4Config, | 28 | LightningIndexerMXFP4Config, |
| 29 | UnsupportedLightningIndexerConfig, | 29 | UnsupportedLightningIndexerConfig, |
| 30 | ) | 30 | ) |
Rtorchao_npu/features/inference/lightning_indexer/mxfp4_transform.py→torchao_ascend/features/inference/lightning_indexer/mxfp4_transform.py+3-3
| @@ -20,11 +20,11 @@ import torch.nn as nn | |||
| 20 | from torchao.core.config import AOBaseConfig | 20 | from torchao.core.config import AOBaseConfig |
| 21 | from torchao.quantization.transform_module import register_quantize_module_handler | 21 | from torchao.quantization.transform_module import register_quantize_module_handler |
| 22 | 22 | ||
| 23 | -from torchao_npu.features.inference.lightning_indexer.config import ( | 23 | +from torchao_ascend.features.inference.lightning_indexer.config import ( |
| 24 | LightningIndexerMXFP4Config, | 24 | LightningIndexerMXFP4Config, |
| 25 | UnsupportedLightningIndexerConfig, | 25 | UnsupportedLightningIndexerConfig, |
| 26 | ) | 26 | ) |
| 27 | -from torchao_npu.features.inference.lightning_indexer.mxfp4_indexer import ( | 27 | +from torchao_ascend.features.inference.lightning_indexer.mxfp4_indexer import ( |
| 28 | mxfp4_lightning_indexer, | 28 | mxfp4_lightning_indexer, |
| 29 | ) | 29 | ) |
| 30 | 30 | ||
| @@ -150,7 +150,7 @@ def mxfp4_lightning_indexer_forward( | |||
| 150 | empty_scores if training or config.return_value else None | 150 | empty_scores if training or config.return_value else None |
| 151 | ) | 151 | ) |
| 152 | if training: | 152 | if training: |
| 153 | - from torchao_npu.features.qat.lightning_indexer.mxfp4_indexer_qat import ( | 153 | + from torchao_ascend.features.qat.lightning_indexer.mxfp4_indexer_qat import ( |
| 154 | mxfp4_lightning_indexer_qat, | 154 | mxfp4_lightning_indexer_qat, |
| 155 | ) | 155 | ) |
| 156 | 156 | ||
Rtorchao_npu/features/qat/lightning_indexer/__init__.py→torchao_ascend/features/qat/lightning_indexer/__init__.py+1-1
| @@ -5,7 +5,7 @@ | |||
| 5 | Expose model prepare/convert, MXFP4 autograd, and main-attention teacher helpers. | 5 | Expose model prepare/convert, MXFP4 autograd, and main-attention teacher helpers. |
| 6 | """ | 6 | """ |
| 7 | 7 | ||
| 8 | -from torchao_npu.features.inference.lightning_indexer.mxfp4_transform import ( | 8 | +from torchao_ascend.features.inference.lightning_indexer.mxfp4_transform import ( |
| 9 | is_lightning_indexer_qat_active, | 9 | is_lightning_indexer_qat_active, |
| 10 | lightning_indexer_filter, | 10 | lightning_indexer_filter, |
| 11 | ) | 11 | ) |
Rtorchao_npu/features/qat/lightning_indexer/config.py→torchao_ascend/features/qat/lightning_indexer/config.py+2-2
| @@ -17,11 +17,11 @@ from torchao.core.config import AOBaseConfig | |||
| 17 | from torchao.quantization.qat import QATStep | 17 | from torchao.quantization.qat import QATStep |
| 18 | from torchao.quantization.transform_module import register_quantize_module_handler | 18 | from torchao.quantization.transform_module import register_quantize_module_handler |
| 19 | 19 | ||
| 20 | -from torchao_npu.features.inference.lightning_indexer.config import ( | 20 | +from torchao_ascend.features.inference.lightning_indexer.config import ( |
| 21 | LightningIndexerMXFP4Config, | 21 | LightningIndexerMXFP4Config, |
| 22 | UnsupportedLightningIndexerConfig, | 22 | UnsupportedLightningIndexerConfig, |
| 23 | ) | 23 | ) |
| 24 | -from torchao_npu.features.inference.lightning_indexer.mxfp4_transform import ( | 24 | +from torchao_ascend.features.inference.lightning_indexer.mxfp4_transform import ( |
| 25 | _module_forward, | 25 | _module_forward, |
| 26 | _reject_default_linear_target, | 26 | _reject_default_linear_target, |
| 27 | is_lightning_indexer_module, | 27 | is_lightning_indexer_module, |
Rtorchao_npu/features/qat/lightning_indexer/indexer_loss.py→torchao_ascend/features/qat/lightning_indexer/indexer_loss.py+0-0
文件重命名但无更改。
Rtorchao_npu/features/qat/lightning_indexer/mxfp4_indexer_qat.py→torchao_ascend/features/qat/lightning_indexer/mxfp4_indexer_qat.py+3-3
| @@ -14,14 +14,14 @@ from typing import Any | |||
| 14 | 14 | ||
| 15 | import torch | 15 | import torch |
| 16 | 16 | ||
| 17 | -from torchao_npu.features.inference.lightning_indexer.common import ( | 17 | +from torchao_ascend.features.inference.lightning_indexer.common import ( |
| 18 | _sequence_shape, | 18 | _sequence_shape, |
| 19 | v2_sequence_kwargs, | 19 | v2_sequence_kwargs, |
| 20 | ) | 20 | ) |
| 21 | -from torchao_npu.features.inference.lightning_indexer.config import ( | 21 | +from torchao_ascend.features.inference.lightning_indexer.config import ( |
| 22 | LightningIndexerMXFP4Config, | 22 | LightningIndexerMXFP4Config, |
| 23 | ) | 23 | ) |
| 24 | -from torchao_npu.features.inference.lightning_indexer.mxfp4_indexer import ( | 24 | +from torchao_ascend.features.inference.lightning_indexer.mxfp4_indexer import ( |
| 25 | _require_cann_version, | 25 | _require_cann_version, |
| 26 | mxfp4_lightning_indexer, | 26 | mxfp4_lightning_indexer, |
| 27 | ) | 27 | ) |
Rtorchao_npu/features/qat/mxfp8/__init__.py→torchao_ascend/features/qat/mxfp8/__init__.py+1-1文件内容审核中,请稍后刷新重试
Rtorchao_npu/features/qat/mxfp8/mxfp8_fake_quantization.py→torchao_ascend/features/qat/mxfp8/mxfp8_fake_quantization.py+1-1
Rtorchao_npu/features/qat/mxfp8/w8a16_linear.py→torchao_ascend/features/qat/mxfp8/w8a16_linear.py+1-1文件内容审核中,请稍后刷新重试
Rtorchao_npu/features/qat/w4a16/fakequant_rebuild.py→torchao_ascend/features/qat/w4a16/fakequant_rebuild.py+1-1
Rtorchao_npu/features/qat/w4a16/filters.py→torchao_ascend/features/qat/w4a16/filters.py+1-1文件内容审核中,请稍后刷新重试
Rtorchao_npu/features/qat/w4a16/w4a16_linear.py→torchao_ascend/features/qat/w4a16/w4a16_linear.py+1-1
Rtorchao_npu/features/qat/w4a8/__init__.py→torchao_ascend/features/qat/w4a8/__init__.py+1-1文件内容审核中,请稍后刷新重试
Rtorchao_npu/features/qat/w4a8/utils.py→torchao_ascend/features/qat/w4a8/utils.py+2-2文件内容审核中,请稍后刷新重试
Rtorchao_npu/features/qat/w4a8/w4a8_grouped_mm.py→torchao_ascend/features/qat/w4a8/w4a8_grouped_mm.py+3-3
Rtorchao_npu/features/training/hifloat8/__init__.py→torchao_ascend/features/training/hifloat8/__init__.py+0-0
Rtorchao_npu/features/training/hifloat8/config.py→torchao_ascend/features/training/hifloat8/config.py+0-0
Rtorchao_npu/features/training/hifloat8/filters.py→torchao_ascend/features/training/hifloat8/filters.py+0-0
Rtorchao_npu/features/training/hifloat8/hifloat8_gmm.py→torchao_ascend/features/training/hifloat8/hifloat8_gmm.py+1-1
Rtorchao_npu/features/training/hifloat8/hifloat8_inference.py→torchao_ascend/features/training/hifloat8/hifloat8_inference.py+1-1
Rtorchao_npu/features/training/hifloat8/hifloat8_linear.py→torchao_ascend/features/training/hifloat8/hifloat8_linear.py+0-0
Rtorchao_npu/features/training/hifloat8/hifloat8_tensor.py→torchao_ascend/features/training/hifloat8/hifloat8_tensor.py+2-2
Rtorchao_npu/features/training/mxfp8/__init__.py→torchao_ascend/features/training/mxfp8/__init__.py+6-6
Rtorchao_npu/features/training/mxfp8/config.py→torchao_ascend/features/training/mxfp8/config.py+9-9文件内容审核中,请稍后刷新重试
Rtorchao_npu/features/training/mxfp8/filters.py→torchao_ascend/features/training/mxfp8/filters.py+1-1
Rtorchao_npu/features/training/mxfp8/grouped_matmul.py→torchao_ascend/features/training/mxfp8/grouped_matmul.py+5-5
Rtorchao_npu/patches/torchao/_base_patch.py→torchao_ascend/patches/torchao/_base_patch.py+3-3文件内容审核中,请稍后刷新重试
Rtorchao_npu/patches/torchao/float8/float8_scaling_utils.py→torchao_ascend/patches/torchao/float8/float8_scaling_utils.py+1-1
Rtorchao_npu/patches/torchao/kernel/blockwise_quantization.py→torchao_ascend/patches/torchao/kernel/blockwise_quantization.py+1-1
Rtorchao_npu/patches/torchao/prototype/blockwise_fp8_inference/blockwise_linear.py→torchao_ascend/patches/torchao/prototype/blockwise_fp8_inference/blockwise_linear.py+2-2
Rtorchao_npu/patches/torchao/prototype/blockwise_fp8_training/linear.py→torchao_ascend/patches/torchao/prototype/blockwise_fp8_training/linear.py+2-2
Rtorchao_npu/patches/torchao/prototype/moe_training/ep/a2a_combine.py→torchao_ascend/patches/torchao/prototype/moe_training/ep/a2a_combine.py+1-1
Rtorchao_npu/patches/torchao/prototype/moe_training/ep/a2a_dispatch.py→torchao_ascend/patches/torchao/prototype/moe_training/ep/a2a_dispatch.py+1-1
Rtorchao_npu/patches/torchao/prototype/moe_training/ep/common.py→torchao_ascend/patches/torchao/prototype/moe_training/ep/common.py+3-3
Rtorchao_npu/patches/torchao/prototype/moe_training/ep/permute.py→torchao_ascend/patches/torchao/prototype/moe_training/ep/permute.py+1-1
Rtorchao_npu/patches/torchao/prototype/moe_training/ep/unpermute.py→torchao_ascend/patches/torchao/prototype/moe_training/ep/unpermute.py+1-1文件内容审核中,请稍后刷新重试
Rtorchao_npu/patches/torchao/prototype/moe_training/fp8_grouped_mm.py→torchao_ascend/patches/torchao/prototype/moe_training/fp8_grouped_mm.py+1-1
Rtorchao_npu/patches/torchao/prototype/moe_training/mxfp8_grouped_mm.py→torchao_ascend/patches/torchao/prototype/moe_training/mxfp8_grouped_mm.py+5-5
Rtorchao_npu/patches/torchao/prototype/moe_training/utils.py→torchao_ascend/patches/torchao/prototype/moe_training/utils.py+1-1文件内容审核中,请稍后刷新重试
Rtorchao_npu/patches/torchao/prototype/mx_formats/config.py→torchao_ascend/patches/torchao/prototype/mx_formats/config.py+1-1
Rtorchao_npu/patches/torchao/prototype/mx_formats/mx_tensor.py→torchao_ascend/patches/torchao/prototype/mx_formats/mx_tensor.py+4-4
Rtorchao_npu/patches/torchao/prototype/mx_formats/mxfp8_linear.py→torchao_ascend/patches/torchao/prototype/mx_formats/mxfp8_linear.py+10-10文件内容审核中,请稍后刷新重试
Rtorchao_npu/patches/torchao/prototype/mx_formats/utils.py→torchao_ascend/patches/torchao/prototype/mx_formats/utils.py+3-3
Rtorchao_npu/patches/torchao/prototype/quantization/float8_static_quant/prototype_float8_tensor.py→torchao_ascend/patches/torchao/prototype/quantization/float8_static_quant/prototype_float8_tensor.py+4-4文件内容审核中,请稍后刷新重试
Rtorchao_npu/patches/torchao/quantization/quant_api.py→torchao_ascend/patches/torchao/quantization/quant_api.py+2-2
Rtorchao_npu/patches/torchao/quantization/quantize_/common/kernel_preference.py→torchao_ascend/patches/torchao/quantization/quantize_/common/kernel_preference.py+1-1
Rtorchao_npu/patches/torchao/quantization/quantize_/workflows/float8/float8_tensor.py→torchao_ascend/patches/torchao/quantization/quantize_/workflows/float8/float8_tensor.py+1-1