Skip to content

Commit

Permalink
#163: Added strict ttrt runtime checking for ttnn binary and added de…
Browse files Browse the repository at this point in the history
…fault load system desc pass in ttir to ttnn pipeline (#302)
  • Loading branch information
tapspatel authored Aug 6, 2024
1 parent 5dc6d82 commit 7185429
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 10 deletions.
5 changes: 4 additions & 1 deletion docs/src/ttrt.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ttrt query --clean-artifacts

### perf
Note: It's required to be on a system with silicon and to have a runtime enabled
build `-DTTMLIR_ENABLE_RUNTIME=ON`. Also need perf enabled build `-DTT_RUNTIME_ENABLE_PERF_TRACE=ON`.
build `-DTTMLIR_ENABLE_RUNTIME=ON`. Also need perf enabled build `-DTT_RUNTIME_ENABLE_PERF_TRACE=ON` with `export ENABLE_TRACY=1`.

```bash
ttrt perf --help
Expand All @@ -89,3 +89,6 @@ import ttrt.binary
fbb = ttrt.binary.load_from_path("out.ttnn")
d = ttrt.binary.as_dict(fbb)
```

## bonus
artifacts are saved in ttrt-artifacts directory if the option `--save-artifacts` is provided
1 change: 1 addition & 0 deletions lib/Dialect/TTNN/Pipelines/TTNNPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace mlir::tt::ttnn {

void createTTIRToTTNNBackendPipeline(
OpPassManager &pm, const TTIRToTTNNBackendPipelineOptions &options) {
pm.addPass(mlir::tt::ttir::createTTIRLoadSystemDesc());
pm.addPass(mlir::tt::ttir::createTTIRImplicitDevice());
pm.addPass(mlir::tt::ttir::createTTIRLayout());

Expand Down
5 changes: 4 additions & 1 deletion runtime/tools/python/ttrt/common/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ def run(args):

# constraint checking
print("executing constraint for all provided flatbuffers")
system_desc, device_ids = ttrt.runtime.get_current_system_desc()
for binary in binaries:
check_file_exists(binary)
fbb = ttrt.binary.load_binary_from_path(binary)
check_version(fbb.version)
fbb_dict = ttrt.binary.as_dict(fbb)
assert (
fbb_dict["system_desc"] == system_desc_as_dict(system_desc)["system_desc"]
), f"system descriptor for binary and system mismatch!"
fbb_list.append((os.path.splitext(os.path.basename(binary))[0], fbb, fbb_dict))
program_index = arg_program_index
assert program_index <= len(
Expand All @@ -129,7 +133,6 @@ def run(args):

# execution
print("executing action for all provided flatbuffers")
system_desc, device_ids = ttrt.runtime.get_current_system_desc()
device = ttrt.runtime.open_device(device_ids)
atexit.register(lambda: ttrt.runtime.close_device(device))

Expand Down
2 changes: 1 addition & 1 deletion test/ttmlir/Dialect/TTNN/multiple_add_with_loc.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline %s | FileCheck %s
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline %s | FileCheck %s
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile>
#loc = loc("test_ops.py:17_0_0":0:0)
module @pybuda_graph attributes {} {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline="override-grid-sizes=add_1_0=4x4,add_2_0=4x4" %s | FileCheck %s
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="override-grid-sizes=add_1_0=4x4,add_2_0=4x4" %s | FileCheck %s
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile>
#loc = loc("test_ops.py:17_0_0":0:0)
module @pybuda_graph attributes {} {
Expand Down
2 changes: 1 addition & 1 deletion test/ttmlir/Dialect/TTNN/ttir_to_ttnn_pipeline.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline %s | FileCheck %s
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline %s | FileCheck %s
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile>
module attributes {} {
func.func @forward(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline="enable-grid-set=false" %s | FileCheck %s
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="enable-grid-set=false" %s | FileCheck %s
#any_device = #tt.operand_constraint<dram|l1|scalar|tile|any_device|any_device_tile>
module attributes {} {
func.func @forward(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> {
Expand Down
2 changes: 1 addition & 1 deletion test/ttmlir/Silicon/TTNN/multiple_add_with_loc.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline %s > %t.mlir
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline %s > %t.mlir
// RUN: FileCheck %s --input-file=%t.mlir
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline="override-grid-sizes=add_1_0=4x4,add_2_0=4x4" %s > %t.mlir
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="override-grid-sizes=add_1_0=4x4,add_2_0=4x4" %s > %t.mlir
// RUN: FileCheck %s --input-file=%t.mlir
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn

Expand Down
2 changes: 1 addition & 1 deletion test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline %s > %t.mlir
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline %s > %t.mlir
// RUN: FileCheck %s --input-file=%t.mlir
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: ttmlir-opt --ttir-load-system-desc --ttir-to-ttnn-backend-pipeline="enable-grid-set=false" %s > %t.mlir
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="enable-grid-set=false" %s > %t.mlir
// RUN: FileCheck %s --input-file=%t.mlir
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn

Expand Down

0 comments on commit 7185429

Please sign in to comment.