Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
60 changes: 26 additions & 34 deletions .github/workflows/ascend-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,37 +78,29 @@ jobs:
run: |
set -x
source /usr/local/Ascend/ascend-toolkit/set_env.sh
python3 third_party/tests/ascend/vector-add.py
python3 third_party/ascend/examples/tutorials/01-vector-add.py
python3 third_party/ascend/examples/tutorials/02-fused-softmax.py
python3 third_party/ascend/examples/tutorials/03-layer-norm.py
python3 third_party/ascend/examples/tutorials/04-fused-attention.py
python3 third_party/ascend/examples/tutorials/06-demo-autotune.py
python3 third_party/ascend/examples/tutorials/07-profiler.py
python3 third_party/ascend/examples/tutorials/09-gather.py
python3 third_party/ascend/examples/tutorials/10-gather_sorted.py
python3 third_party/ascend/examples/tutorials/11-rab_time.py
python3 third_party/ascend/examples/tutorials/13-matrix-multiplication-optimized.py
python3 third_party/ascend/examples/tutorials/13-matrix-multiplication-optimized-flagtree.py
python3 third_party/ascend/examples/tutorials/14-accuracy-comparison.py
python3 python/test/ops/01_vector_add/01_vector_add.py
python3 python/test/ops/abs/abs.py
python3 python/test/ops/addmm/addmm.py
python3 python/test/ops/addmm/addmm_ascend.py
python3 python/test/ops/amax/amax.py
python3 python/test/ops/amax/amax_ascend_perf.py
python3 python/test/ops/apply_rotary_pos_emb/apply_rotary_pos_emb.py
python3 python/test/ops/apply_rotary_pos_emb/apply_rotary_pos_emb_ascend.py
python3 python/test/ops/argmin/argmin.py
python3 python/test/ops/argmin/argmin_ascend_perf.py
python3 python/test/ops/bmm/bmm_ascend.py
python3 python/test/ops/cumsum/cumsum.py
python3 python/test/ops/min_dim/min_dim.py
python3 python/test/ops/min_dim/min_dim_ascend_perf.py
python3 python/test/ops/sum_dim/sum_dim.py
python3 python/test/ops/varmean/var_mean_ascend.py
python3 -m pytest third_party/ascend/examples/pytest_ut --ignore=third_party/ascend/examples/pytest_ut/test_index_select.py \
--ignore=third_party/ascend/examples/pytest_ut/test_linearize_permute.py \
--ignore=third_party/ascend/examples/pytest_ut/test_logical_and.py \
--ignore=third_party/ascend/examples/pytest_ut/test_logical_or.py \
--ignore=third_party/ascend/examples/pytest_ut/test_triton_unified_attention.py
# tutorials
pushd third_party/ascend/tutorials
python3 01-vector-add.py
python3 02-fused-softmax.py
python3 03-layer-norm.py
python3 04-fused-attention.py
python3 06-demo-autotune.py
python3 07-profiler.py
python3 08-demo-libentry.py
python3 09-gather.py
python3 10-gather_sorted.py
python3 11-rab_time.py
python3 12-hstu_attention.py
python3 13-matrix-multiplication-optimized.py
python3 14-accuracy-comparison.py
python3 15-embedding_gather_demo.py
popd
# pytest_ut
pushd third_party/ascend/unittest/pytest_ut
python3 -m pytest . \
--ignore=test_index_select.py \
--ignore=test_linearize_permute.py \
--ignore=test_logical_and.py \
--ignore=test_logical_or.py \
--ignore=test_triton_unified_attention.py
popd
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
hooks:
- id: ruff
files: '^python/.*'
args: ["--fix", "--line-length", "120"]
args: ["--fix", "--line-length", "120", "--per-file-ignores", "*/__init__.py:E402"]
stages: [pre-commit, pre-push, manual]
exclude: |
(?x)(
Expand Down
4 changes: 4 additions & 0 deletions python/triton/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# flagtree backend path specialization
from triton.runtime.driver import spec_path

spec_path(__path__)
"""isort:skip_file"""
__version__ = '3.2.0'

Expand Down
5 changes: 5 additions & 0 deletions python/triton/compiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# flagtree backend path specialization
from triton.runtime.driver import spec_path

spec_path(__path__)

from .compiler import CompiledKernel, ASTSource, compile, make_backend, LazyDict
from .errors import CompilationError

Expand Down
9 changes: 9 additions & 0 deletions python/triton/language/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# flagtree backend path specialization
from triton.runtime.driver import spec_path

spec_path(__path__)
"""isort:skip_file"""
# Import order is significant here.

Expand Down Expand Up @@ -255,6 +259,11 @@
"zeros_like",
]

# flagtree backend specialization
from triton.runtime.driver import spec

__all__ = spec("language_modify_all", __all__) or __all__


def str_to_ty(name):
if name[0] == "*":
Expand Down
5 changes: 5 additions & 0 deletions python/triton/runtime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# flagtree backend path specialization
from triton.runtime.driver import spec_path

spec_path(__path__)

from .autotuner import (Autotuner, Config, Heuristics, autotune, heuristics)
from .cache import RedisRemoteCacheBackend, RemoteCacheBackend
from .driver import driver
Expand Down
22 changes: 22 additions & 0 deletions python/triton/runtime/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,25 @@ def spec_func(function_name: str):
func = getattr(spec, function_name)
return func
return None


# flagtree backend path specialization
def spec_path(path_list: list):
"""
TODO: Read "ascend" from FLAGTREE_BACKEND file.
example: input __path__ = ["python/triton/compiler"]
backend_path = "third_party/ascend/backend/spec/python/triton/compiler"
__path__ = [backend_path, "python/triton/compiler"]
"""
import os
if not path_list:
return
current_path = path_list[0]
current_path = current_path.replace(os.sep, "/")
marker = "python/triton"
idx = current_path.find(marker)
if idx != -1:
rel_path = current_path[idx:]
backend_path = os.path.join("third_party/ascend/backend/spec", rel_path)
if os.path.isdir(backend_path):
path_list.insert(0, backend_path)
41 changes: 34 additions & 7 deletions third_party/ascend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
#add_subdirectory(triton-adapter triton-adapter)
#add_subdirectory(test)

add_subdirectory(backend/spec/lib)
add_subdirectory(${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/include)
add_subdirectory(${PROJECT_SOURCE_DIR}/lib
${PROJECT_BINARY_DIR}/lib)

add_triton_plugin(TritonAscend ${CMAKE_CURRENT_SOURCE_DIR}/triton_ascend.cpp)
add_triton_library(Registrar Registrar.cc)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Triton Ascend is dependent on AscendNPU IR
#set(ASCENDNPU_IR_SRC_DIR "${PROJECT_SOURCE_DIR}/third_party/ascendnpu-ir")
#set(ASCENDNPU_IR_BINARY_DIR "${PROJECT_BINARY_DIR}/third_party/ascendnpu-ir")

set(BISHENGIR_ENABLE_A5_UNPUBLISHED_FEATURES ON)
set(BISHENGIR_BUILD_STANDALONE_IR_ONLY ON)

#add_subdirectory(${ASCENDNPU_IR_SRC_DIR} ${ASCENDNPU_IR_BINARY_DIR})
#include_directories(${ASCENDNPU_IR_SRC_DIR}/bishengir/include)
#include_directories(${ASCENDNPU_IR_BINARY_DIR}/bishengir/include) # Tablegen'd files

#add_subdirectory(include)
#add_subdirectory(lib)

add_triton_plugin(TritonAscend
${CMAKE_CURRENT_SOURCE_DIR}/triton_ascend.cc
${CMAKE_CURRENT_SOURCE_DIR}/ascend_ir.cc

LINK_LIBS
TritonToLinalgIncubated
BiShengIRScopeDialect
BiShengIRHIVMDialect
)

# target_link_libraries(TritonAscend PRIVATE Python3::Module pybind11::headers)
target_include_directories(TritonAscend PRIVATE
${CMAKE_SOURCE_DIR}/third_party/flir/include
${CMAKE_BINARY_DIR}/third_party/flir/include)
${CMAKE_SOURCE_DIR}/third_party/flir/include
${CMAKE_BINARY_DIR}/third_party/flir/include)

add_triton_library(Registrar Registrar.cc)
if(TRITON_BUILD_UT)
add_subdirectory(unittest)
endif()
Empty file removed third_party/ascend/README.md
Empty file.
Loading