-
Notifications
You must be signed in to change notification settings - Fork 1
[test] Add me2e pytest framework for middle end #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
brnorris03
wants to merge
45
commits into
main
Choose a base branch
from
bnorris/me2e-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input) Introduces declarative test infrastructure for TTL-dialect MLIR: - op_specs.py: ComputeOpSpec/FusedOpSpec for single and fused kernels - config_specs.py: TestConfig for tile sizes, dtypes, buffer factors - ttl_builder.py: Programmatic TTL MLIR generation (reader/compute/writer) - compile_utils.py: Pass pipeline and C++ translation - runner.py: ttnn.generic_op execution and validation against PyTorch golden Supports 12 single ops, 8 fused op chains, 5 configurations (120 tests). Generated C++ sources written to build/test/middle_end/<op>/<config>/.
…structure: 1. Marks class for skip/xfail annotations on ops 2. Platform-aware skip markers (skip_config, only_config) 3. Automatic test metadata extraction for XML reporting 4. Structured grid/shape configuration sets (SMALL_GRIDS, etc.) 5. Input range constraints for domain-sensitive ops (sqrt, rsqrt) 6. Device caching across test session 7. Failure stage classification (compile/runtime/golden exceptions) 8. ID generation helpers (shape_str, torch_dtype_to_abbrev) 9. MLIR dump option (--dump-mlir) for debugging 10. PCC-based golden comparison (--check-pcc, compare_tensors) New files: - test_utils.py: Shared utilities, exceptions, PCC computation Updated files: - conftest.py: Platform detection, metadata hooks, CLI options - config_specs.py: Categorized grid shapes, make_config helper - op_specs.py: input_range field for ops with domain constraints - runner.py: Uses compare_tensors, custom exceptions, MLIR dump
…ize and minimize redundancies
62f1a40 to
0418d1d
Compare
- Rename test/e2e/builder/executor.py to ttnn_runner.py - Rename execute_* functions to run_* for consistency - Fix compute kernel compile-time args (CB indices were missing) - Fix runtime_args format (4D -> 3D list structure) - Skip execution stages blocked by TensorAccessorArgs codegen issue - Skip fused op translation (compute-only, no reader/writer threads) - Update README with blocking issue documentation
3 tasks
cd /home/bnorris/tt/tt-lang && source build/env/activate && TTLANG_DEBUG_KERNELS=1 timeout 90 pytest "test/me2e/test_compute_ops.py::test_compute[TestConfig(tile_h=32, tile_w=32, block_h=1, block_w=1, dtype=torch.bfloat16, num_tiles=1, buffer_factor=1, memory_layout=<MemoryLayout.INTERLEAVED: 'interleaved'>)-add]" -vsx
Make layout attribute generation configurable via E2EConfig.buffer_type (DRAM/L1) and E2EConfig.memory_layout (interleaved/sharded variants). Defaults preserved (DRAM + interleaved). Enables future tests with different memory configurations without modifying builder code.
3 tasks
brnorris03
added a commit
that referenced
this pull request
Jan 20, 2026
… utilities (#249) ### What? Extract shared kernel execution logic into `python/ttl/kernel_runner.py` and move test utilities from `test/python/test_helpers.py` to `test/ttlang_test_utils.py` at the test root. ### Why? Kernel execution logic was duplicated between `CompiledTTNNKernel.__call__` and test code (and would be further replicated in the compiler me2e tests), making it difficult to maintain a single source of truth for building kernel descriptors and CB descriptors. Test utilities were also scattered in `test/python/test_helpers.py`, making them less accessible to lit tests and other test infrastructure. ### How? - Created `python/ttl/kernel_runner.py` with reusable functions (`build_kernel_descriptors`, `build_cb_descriptors`, `run_kernel_on_device`) for building kernel descriptors, CB descriptors, and executing kernels via `ttnn.generic_op`. - Moved `test/python/test_helpers.py` to `test/ttlang_test_utils.py` at the test root, making utilities accessible to both pytest and lit tests. - Refactored `CompiledTTNNKernel.__call__` to delegate to `run_kernel_on_device()` from `kernel_runner.py`, reducing code duplication. - Updated all test imports to use the new `ttlang_test_utils` location. ### How to Test? Run existing tests to verify no regressions (check-ttlang-all passes) Also tested in the me2e PR that depends on this one: #167 ### Checklist: * [x] Self-reviewed (style, logic) * [x] Added tests (or justified none needed) * [x] PR is small and focused (one task)
8e02134 to
10e6f9c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
New pytest-based ME2E (middle-end to end-to-end) test framework in
test/me2e/for testing TTL MLIR generation, compilation, and hardware execution.
Why?
execution
single test function
TTLElementwiseOps.defkeeping tests in syncwith dialect
How?
Two test approaches (both auto-generated from
TTLElementwiseOps.def):Declarative parametrized tests (primary): Single
test_compute_ops.pyfunction parametrized over all operations and configurations.
COMPUTE_OPSin
op_specs.pyis auto-generated from the.deffile. All pipeline stagesexecuted in one function via
runner.py. Fast, clean, no artifacts.Class-based tests: Test classes auto-generated from
.deffile. Classesdeclare what to test (op name, arity, input range, tolerance) via class
attributes; base classes handle how (MLIR generation, compilation,
execution, validation). Saves intermediate (MLIR, CPP, results) artifacts
for debugging, supports custom (fused) ops via MLIR templates.
Architecture:
E2ETestBase: Ordered 5-stage pipeline (build → compile → translate → execute→ validate)
OpTestBase: AddsOP_STR,ARITY,INPUT_RANGE; auto-generates from.deffileFusedOpTestBase: Custom MLIR viaget_mlir_template()override(examples in
test/me2e/ops/test_fused.py)kernel_runnermodule (
python/ttl/kernel_runner.py)build/test/me2e/<TestName>/for debugging (class-basedtests) or temporary directories (declarative tests).
flowchart TD subgraph Inputs DEF[.def file] MLIR[Custom MLIR] end DEF --> GEN[Generate: TestAdd, TestExp...] DEF --> DECL[Declarative: test_compute_ops] MLIR --> FUSED[FusedOpTestBase] GEN --> P1 FUSED --> P1 DECL --> P2 subgraph P1[Class-based Pipeline] S1[build] --> S2[compile] S2 --> S3[translate] S3 --> S4[execute] S4 --> S5[validate] end subgraph P2[Declarative Pipeline] D1[build] --> D2[compile] D2 --> D3[translate] D3 --> D4[execute + validate] end S1 --> O1[module.mlir] S2 --> O2[compiled.mlir] S3 --> O3[*.cpp] S4 --> O4[result.pt] D4 --> O5[in-memory validation]Current status:
for all ops
tanh, abs, neg, relu, sigmoid)
See
https://github.com/tenstorrent/tt-lang/blob/bnorris/me2e-tests/test/me2e/README.md
for more details.
How to Test?
Part of the
check-ttlang-alltarget. Also separately testable with:CI:
https://github.com/tenstorrent/tt-lang/actions/runs/21126783459/job/60749650887
Checklist: