Testing Reference
The settings, files and CI facts of the test framework, for looking things up. Each section names its source of truth, the file or command that defines it: when this page and the source disagree, the source is right (and this page needs a fix). For how these pieces fit together, see Testing Architecture.
Test folders
Source: the folders of tests/. Each folder holds one test plan, with its known failures and
helper modules.
Folder |
What its tests check |
|---|---|
|
One op or a short op pattern, compiled, run and compared with a reference |
|
A full model, and its layers or blocks |
|
One compiler behavior, without running the model |
|
The execution paths: host, CSS, heterogeneous runs, the runtime API |
|
Any model file, layer by layer; for investigations, not in CI |
|
|
|
The |
|
Opt-in sweeps, not run by default |
tests/testdata/ holds the cases and models shared by the test plans, and extras/tests/ the
tests of internal models.
Test names
Source: pytest node IDs.
tests/ops/test_tosa_ops.py::test_mlir_files_torq[add-single-rescale.mlir-sim-sl2610-v1]
<test module> ::<test function> [<case>-<runtime>-<chip>]
Case: the name of a
Case, e.g. a file name or a Keras case name with its quantization (avgpool_k3x3_s3x3_valid_10x10x4_int8).Runtime:
sim,aws_fpgaorastra_machina.Chip: a chip name, e.g.
sl2610-v1.
The -xfails.txt files and the -k option use these names.
Markers
Source: pytest.ini (pytest --markers lists them).
Marker |
Meaning |
|---|---|
|
Run by the C model CI job |
|
Run by the AWS FPGA CI job |
|
Run by the Astra Machina SL board CI job |
|
Run by the C model CI job in the merge queue and on |
|
Not run by the FPGA CI job, even when its test function is |
|
Keras op cases of one quantization |
|
Keras op cases of one family module (the module name) |
|
Layer and full-model cases of the TFLite model tests |
|
Opt-in suites, deselected by default (see More testing) |
An explicit -m replaces the default selection of pytest.ini, which deselects the opt-in
suites.
Options
Source: pytest --help, section “Custom options”. The most used ones:
Option |
What for |
|---|---|
|
The chips to compile for: chip names, comma-separated, or |
|
The runtimes: |
|
Redo every step, ignoring the cache |
|
Print why each cached step is reused or redone |
|
Read cached results from stores (directories or |
|
Append to |
|
Run the known failures, and report those that pass ( |
|
Run only the tests of the known failures of an issue |
|
Fail when a line of an |
|
Write the outcome of each test, for |
|
Start the tests of |
|
Save the IR after each compiler pass |
|
Print the whole compiler and runtime output |
|
Add compiler options to every test |
|
Verify the IR after each compiler pass ( |
|
Time limits of one compilation and one run (default 300 s and 240 s) |
|
Save a runtime profile of each test |
|
Save the time of each compiler pass of each test |
|
Save where the time of each test goes, and print the slowest tests |
|
TFLite model tests: only the full models, not their layers |
Files
File |
Content |
|---|---|
|
The known failures of |
|
The same, for internal chips and models |
|
The slow tests, slowest first: |
|
Keras op case names that get the |
|
|
|
A chip description; |
|
Keras op cases, see Keras module |
|
PyTorch and ONNX op cases, see PyTorch and ONNX module |
|
MLIR op cases, see MLIR file |
|
Cases that may run on the host or the CSS |
|
Compile-only cases of |
|
The cache; can be deleted at any time |
Case settings
Keras module
Source: the docstring of tests/ops/keras_ops_models.py.
Name |
Content |
|---|---|
|
|
|
The quantizations of every case, default |
|
Settings of every case of the module |
|
|
PyTorch and ONNX module
Source: the docstring of tests/ops/torch_ops_models.py. The module is read without being
imported: these names must be plain literals.
Name |
Content |
|---|---|
|
|
|
|
|
PyTorch only: |
|
|
MLIR file
Sources: comparison_config_from_mlir in python/torq/testing/iree.py, the CONFIG
table of tests/ops/test_tosa_ops.py.
Tolerances: comments
// TORQ_<KEY>: <number>, with a comparison setting in upper case, e.g.// TORQ_FP_MAX_TOL: 0.05.Other settings of a tosa_ops file: the
CONFIGtable oftest_tosa_ops.py,{file stem or pattern: settings}. A pattern uses*and?("identity-*"). The keys aretorq_compiler_options(added),torq_compiler_timeoutandtweaked_input_data_range((low, high)of the random inputs). Settings under an"aws_fpga"key apply on the FPGA only. Every entry must match a file.linalg_ops sets its per-file settings in the
case_configoftest_linalg_ops.py.Compile-only cases (
linalg_compilation):// TORQ_COMPILE_OPTIONS: --flag1 --flag2.
Comparison settings
Source: DEFAULT_COMPARISON_CONFIG and compare_outputs in
python/torq/lab/verification/compare.py.
Integer outputs pass when every element differs from the reference by at most int_tol. For
float outputs, the relative difference of an element is
|observed - expected| / (|observed| + |expected| + epsilon); they pass when the fraction of
elements whose relative difference is over fp_max_tol is at most allowed_wrong.
Key |
Default |
Meaning |
|---|---|---|
|
1 |
Integers: largest allowed difference |
|
1 |
Integers: has no effect, since an element over |
|
0.01 |
Floats: an element over this relative difference is wrong |
|
0 |
Floats: largest allowed fraction of wrong elements |
|
false |
Floats: an element is wrong only if its absolute difference is also over |
|
0 |
See |
|
0.01 |
Floats: the relative difference over which an element is counted in the “number of differences” printed on failure; it doesn’t decide the result |
|
1e-6 |
Floats: added to the denominator of the relative difference |
|
false |
Accept an output that is all zeros when the reference is not |
|
false |
Floats: don’t check that NaNs are at the same places |
CI
Sources: .github/workflows/test.yml (pull requests and merge queue), release.yml
(pushes), test-build.yml and the job workflows it calls.
Jobs
Job (workflow) |
Selection |
Runtime, chips |
Workers |
|---|---|---|---|
C model ( |
|
|
18, |
AWS FPGA ( |
|
|
|
Astra Machina SL ( |
|
|
4 |
torq-lab ( |
|
none |
1 |
When: the C model and torq-lab jobs run on every pull request. The FPGA and board jobs run in the merge queue and on pushes, and on a pull request only with their label. They start after the C model jobs pass (or are skipped).
C model options:
--check-xfails,--durations=30,--torq-step-timings, and compile-time profiles. The step timings and profiles are in the artifactcmodel_compile_profiling_logs_<chip>.All jobs pass
--tflite-layer-test-generate-full-model-only. They check outextrasat the commit ofscripts/extras.gitlink(update it withscripts/pin_extras.sh), and upload their results to the test dashboard.
Time limits
Limit |
Value |
Set in |
|---|---|---|
pytest |
40 min ( |
|
C model, FPGA and board jobs |
50 min ( |
the job workflows |
CodeBuild runner |
60 min |
the runner |
torq-lab job |
20 min |
|
Labels
Label |
Effect on a pull request |
|---|---|
|
Run the FPGA jobs |
|
Run the Astra Machina board job |
|
Don’t run the C model jobs; the FPGA and board jobs still run if labeled |
|
Don’t run the torq-lab job |
|
Run the |
|
Run the known failures too ( |
|
Upload the results to the staging dashboard instead of production |
|
Verify the IR after each compiler pass ( |
Adding a label starts a new run; removing one doesn’t. Re-running a workflow run reuses the labels it had when it started.