trntensor 0.25.1__tar.gz → 0.26.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trntensor-0.26.0/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
- trntensor-0.26.0/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/CHANGELOG.md +86 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/CONTRIBUTING.md +11 -0
- {trntensor-0.25.1/trntensor.egg-info → trntensor-0.26.0}/PKG-INFO +3 -1
- {trntensor-0.25.1 → trntensor-0.26.0}/README.md +2 -0
- trntensor-0.26.0/docs/api/equivariant.md +177 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/api/index.md +2 -1
- {trntensor-0.25.1 → trntensor-0.26.0}/mkdocs.yml +1 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/pyproject.toml +3 -2
- trntensor-0.26.0/scripts/conformance_expect.py +65 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/conftest.py +72 -0
- trntensor-0.26.0/tests/fixtures/mace_mp0b2_tiny.pt +0 -0
- trntensor-0.26.0/tests/mlip_reference.py +126 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_conformance.py +53 -0
- trntensor-0.26.0/tests/test_device_known.py +57 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_einsum.py +85 -0
- trntensor-0.26.0/tests/test_equivariant.py +632 -0
- trntensor-0.26.0/tests/test_equivariant_native.py +421 -0
- trntensor-0.26.0/tests/test_equivariant_neuron.py +436 -0
- trntensor-0.26.0/tests/test_equivariant_nki.py +221 -0
- trntensor-0.26.0/tests/test_neuron_int_exact.py +70 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/__init__.py +19 -1
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/einsum.py +62 -3
- trntensor-0.26.0/trntensor/equivariant.py +1153 -0
- trntensor-0.26.0/trntensor/nki/_equivariant.py +377 -0
- trntensor-0.26.0/trntensor/nki/_equivariant_kernels.py +558 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/nki/_kernels.py +2 -1
- trntensor-0.26.0/trntensor/nki/_native_equivariant.py +167 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/nki/dispatch.py +6 -3
- {trntensor-0.25.1 → trntensor-0.26.0/trntensor.egg-info}/PKG-INFO +3 -1
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor.egg-info/SOURCES.txt +16 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/.github/workflows/ci.yml +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/.github/workflows/notify-umbrella.yml +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/.github/workflows/publish.yml +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/.gitignore +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/.pre-commit-config.yaml +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/CLAUDE.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/CODE_OF_CONDUCT.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/LICENSE +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/benchmarks/__init__.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/benchmarks/bench_einsum.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/api/decompose.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/api/einsum.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/api/nki.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/api/plan.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/api/quantum.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/api/stream.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/architecture.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/aws_setup.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/benchmarks.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/contraction_patterns.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/design/matmul_dispatch_findings.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/design/matmul_kernel_profile.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/developing_kernels.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/index.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/installation.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/quickstart.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/docs/tutorial_df_mp2.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/examples/df_mp2_einsum.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/infra/terraform/README.md +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/infra/terraform/main.tf +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/autotune_dispatch.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/bench_ao2mo_nocc.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/bench_eager_handle.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/bench_native_einsum.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/bench_native_kernels.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/bench_to_md.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/run_benchmarks.sh +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/run_neuron_profile.sh +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/run_neuron_tests.sh +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/run_reduce_parallel_multirank.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/scripts/run_simulator_tests.sh +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/setup.cfg +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_decompose.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_host_output.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_kernel_dtype_guard.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_native_dispatch.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_neuron_span.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_neuron_span_device.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_nki.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_nki_compile.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_nki_kernels.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_nki_native.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_nki_sim.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_nki_tail_audit.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_parallel.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_plan.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_quantum.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_sr_runtime.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_stream.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/tests/test_trace_cache_safety.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/decompose.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/nki/__init__.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/nki/_native.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/nki/collectives.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/parallel.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/plan.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/py.typed +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/quantum.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor/stream.py +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor.egg-info/dependency_links.txt +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor.egg-info/requires.txt +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/trntensor.egg-info/top_level.txt +0 -0
- {trntensor-0.25.1 → trntensor-0.26.0}/uv.lock +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Report a bug in trnfft
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Environment
|
|
8
|
+
|
|
9
|
+
- trnfft version:
|
|
10
|
+
- Python version:
|
|
11
|
+
- PyTorch version:
|
|
12
|
+
- Hardware: CPU / trn1 / trn2 / inf2
|
|
13
|
+
- OS:
|
|
14
|
+
|
|
15
|
+
## Description
|
|
16
|
+
|
|
17
|
+
What happened?
|
|
18
|
+
|
|
19
|
+
## Steps to reproduce
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
# Minimal code to reproduce
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Expected behavior
|
|
26
|
+
|
|
27
|
+
What should have happened?
|
|
28
|
+
|
|
29
|
+
## Actual behavior
|
|
30
|
+
|
|
31
|
+
What happened instead? Include error messages/tracebacks if applicable.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest a new feature or enhancement
|
|
4
|
+
labels: enhancement
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Description
|
|
8
|
+
|
|
9
|
+
What feature would you like?
|
|
10
|
+
|
|
11
|
+
## Motivation
|
|
12
|
+
|
|
13
|
+
Why is this needed? What problem does it solve?
|
|
14
|
+
|
|
15
|
+
## Alternatives considered
|
|
16
|
+
|
|
17
|
+
Any other approaches you've thought about?
|
|
@@ -7,6 +7,92 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.26.0] — 2026-11-25
|
|
11
|
+
|
|
12
|
+
Validated on Trn2 (trn2.3xlarge, Neuron SDK 2.33.1, native TorchNeuron) — see trnsci/trnsci#35.
|
|
13
|
+
|
|
14
|
+
Headline: `trntensor.equivariant`, MACE-style equivariant contractions with registered backwards (#138, #139): `conv_tp` (the e3nn "uvu" tensor product, gradients for x, y and w) and `symmetric_contraction` (correlation ≤ 3, gradient for x). On Trn2 the NKI kernels match the fp64 host path to ≤ 2.2e-7 relative, forward, input gradients and double backward, so `"auto"` runs them for fp32 operands on the `neuron` device. The PyTorch-path `symmetric_contraction` backward is a few GEMMs instead of `index_add_` (#140).
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **`trntensor.equivariant`: MACE-style equivariant contractions with
|
|
19
|
+
forward and input gradients** (#138, MLIP exemplar trnsci/trnsci#170).
|
|
20
|
+
These are the first trntensor ops with a registered backward.
|
|
21
|
+
- `conv_tp(x, y, w, spec)`: the e3nn "uvu" tensor product with per-edge
|
|
22
|
+
weights, the MLIP interaction. Gradients ∂x, ∂y, ∂w.
|
|
23
|
+
- `symmetric_contraction(x, species, spec)`: MACE's product basis,
|
|
24
|
+
correlation ≤ 3. Gradient ∂x.
|
|
25
|
+
- `conv_tp_spec` / `symmetric_contraction_spec` build the static spec
|
|
26
|
+
either from an e3nn / MACE module or from explicit irreps (or coupling
|
|
27
|
+
tensors and weights). e3nn and mace-torch stay optional, test-only
|
|
28
|
+
dependencies. `wigner_3j` and `wigner_D` reproduce e3nn 0.4.4's basis
|
|
29
|
+
and sign convention for l ≤ 3.
|
|
30
|
+
- The fused PyTorch path is a fixed handful of aten launches per call: 8
|
|
31
|
+
at MACE-MP layer 1 forward, against 34 for e3nn. Against the MACE-MP-0b2
|
|
32
|
+
medium captures it matches MACE to ≤ 3.6e-7 relative for every output and
|
|
33
|
+
input gradient on all six exemplar captures (16 / 64 / 216 atoms, two
|
|
34
|
+
geometries each).
|
|
35
|
+
- The NKI kernels run one launch per direction per layer. conv_tp keeps
|
|
36
|
+
edges on partitions; its Clebsch-Gordan blocks stay in SBUF and come out
|
|
37
|
+
of one Tensor Engine matmul, and the work is split over the GpSimd,
|
|
38
|
+
Scalar and Vector engines. symmetric_contraction runs as Tensor Engine
|
|
39
|
+
matmuls over a pruned symmetric-monomial basis, accumulating in PSUM.
|
|
40
|
+
- On the native TorchNeuron path the ops are `nki_op` custom ops with
|
|
41
|
+
`register_autograd`. On the XLA path and the simulator they are wrapped
|
|
42
|
+
in `torch.autograd.Function`.
|
|
43
|
+
- The kernels pass MLIR verification for trn1 and trn2 (LNC 1 and 2), and
|
|
44
|
+
match MACE in `nki.simulate`. On Trn2 (SDK 2.33.1, neuronx-cc 2.28,
|
|
45
|
+
native TorchNeuron, LNC=2) they match the fp64 host path to ≤ 2.2e-7
|
|
46
|
+
relative at 216 and 1728 atoms and every MACE-MP-0b2 capture to ≤ 2.9e-7
|
|
47
|
+
(bar 2e-5), forward, input gradients and double backward; reruns are
|
|
48
|
+
bitwise identical. `"auto"` therefore runs them for fp32 operands on the
|
|
49
|
+
`neuron` device (`TRNTENSOR_EQUIVARIANT_NKI=0` opts out); elsewhere it
|
|
50
|
+
runs the PyTorch path. Timings are in trntensor#139.
|
|
51
|
+
- The symmetric-contraction factor products run on the Vector Engine:
|
|
52
|
+
neuronx-cc 2.28 elides a PSUM → SBUF `tensor_copy` into a GpSimd
|
|
53
|
+
consumer and then fails with NCC_IBFD004.
|
|
54
|
+
- With `create_graph=True` (training on forces) the backward is built from
|
|
55
|
+
differentiable aten ops on the kernel operands, so double backward works
|
|
56
|
+
with the kernels on; first-order backward (forces) stays on the kernels.
|
|
57
|
+
- The PyTorch-path `symmetric_contraction` backward scatters the factors
|
|
58
|
+
as three GEMMs against a 0/1 factor-selection matrix, not `index_add_`
|
|
59
|
+
(#140). On Trn2 at 216 atoms the backward drops from 4485 to 5.1 ms
|
|
60
|
+
(layer 0) and from 1030 to 2.6 ms (layer 1).
|
|
61
|
+
- Device tests and a timing harness are in
|
|
62
|
+
`tests/test_equivariant_neuron.py`.
|
|
63
|
+
|
|
64
|
+
## [0.25.2] — 2026-11-10
|
|
65
|
+
|
|
66
|
+
Validated on Trn2 (trn2.3xlarge, Neuron SDK 2.33.0, native TorchNeuron) — see trnsci/trnsci#35.
|
|
67
|
+
|
|
68
|
+
Headline: integer einsum on the neuron device is exact above 2^24, and int32/int64 out= copies are exact (silent, #132)
|
|
69
|
+
|
|
70
|
+
### Fixed
|
|
71
|
+
|
|
72
|
+
- **Integer einsum on the neuron device: `precision="fast"` rounded int32
|
|
73
|
+
above 2^24, and `out=` rounded transposed int32 / int64 results** (silent,
|
|
74
|
+
#132, trnsci/trnsci#135, aws-neuron/aws-neuron-sdk#1466). Integer and bool
|
|
75
|
+
contractions with an operand on a device without exact integer arithmetic
|
|
76
|
+
now contract on the host in every precision mode (the #90 route, which
|
|
77
|
+
covered `"kahan"` only), and the result is made contiguous before it is
|
|
78
|
+
uploaded (an upload of a transposed int32 host view is rounded too).
|
|
79
|
+
`out=` copies int32 through `uint32` views and int64 through `float64`
|
|
80
|
+
views, which the device moves bit-exactly. On Trn2, `einsum("ij->ji", x,
|
|
81
|
+
out=buf)` on an int32 (64, 96) tensor had 5928 of 6144 entries wrong, and
|
|
82
|
+
`einsum("ij,jk->ik")` of `[[2^24 + 1, 2], [3, 4]]` with I gave 16777216.
|
|
83
|
+
### Changed
|
|
84
|
+
|
|
85
|
+
- **Device conformance runs are signal-only (trnsci/trnsci#35).** Under
|
|
86
|
+
`--backend nki --conformance-device neuron`, `tests/test_conformance.py`
|
|
87
|
+
marks the known platform failures `xfail(strict=False)` by category at run
|
|
88
|
+
time (`DEVICE_KNOWN`, the trnsolver#146 pattern): complex SVD / solve on
|
|
89
|
+
device (#130, 9 cases) and device float64 at fp32 precision (#136, 1 case).
|
|
90
|
+
A case that starts passing shows as XPASS. CPU CI and `auto` / `pytorch`
|
|
91
|
+
runs are unchanged. A device run prints passed, xfailed and XPASS by
|
|
92
|
+
category and the NEW failures; `--conformance-json PATH` writes it as
|
|
93
|
+
JSON, and `scripts/conformance_expect.py` merges chunked runs (exit 1 on
|
|
94
|
+
NEW failures). Test: `tests/test_device_known.py`.
|
|
95
|
+
|
|
10
96
|
## [0.25.1] — 2026-11-07
|
|
11
97
|
|
|
12
98
|
Validated on Trn2 (trn2.3xlarge, Neuron SDK 2.33.0, native TorchNeuron) — see trnsci/trnsci#35.
|
|
@@ -57,6 +57,17 @@ Before opening a PR:
|
|
|
57
57
|
- [ ] If you added a public symbol, the project's `docs/api.md` lists it
|
|
58
58
|
- [ ] PR description says *what* changed and *why*, not just *what*
|
|
59
59
|
|
|
60
|
+
## Releasing
|
|
61
|
+
|
|
62
|
+
`.github/workflows/publish.yml` publishes to PyPI (trusted publishing) when a GitHub Release is published. A tag containing `-` (`vX.Y.Z-rc1`) goes to TestPyPI.
|
|
63
|
+
|
|
64
|
+
- [ ] Release PR (`release: vX.Y.Z`): bump `version` in `pyproject.toml` and `__version__` in `trntensor/__init__.py`, and move the `[Unreleased]` CHANGELOG entries under `## [X.Y.Z] - YYYY-MM-DD`.
|
|
65
|
+
- [ ] After the merge, run `gh release create vX.Y.Z --target <merge sha>`, then confirm the publish run and the new version on PyPI.
|
|
66
|
+
- [ ] **Update umbrella docs/extras** in one [trnsci/trnsci](https://github.com/trnsci/trnsci) PR:
|
|
67
|
+
- if users should require this release (always for a fix to silent wrong results), bump `trntensor` in the umbrella `pyproject.toml` `[tensor]` and `[all]` extras, and cut a `trnsci` meta-package release;
|
|
68
|
+
- update the `[[described:trntensor=X.Y.Z]]` rows in `docs/roadmap.md` and `docs/nki_validation_status.md`, with the [#35](https://github.com/trnsci/trnsci/issues/35) Trn2 validation link;
|
|
69
|
+
- check that `python scripts/check_docs_drift.py` exits 0. The weekly docs-drift workflow opens a `docs-stale` issue for anything missed.
|
|
70
|
+
|
|
60
71
|
## Issues
|
|
61
72
|
|
|
62
73
|
Label each issue one of: `bug`, `feature`, `question`, `docs`, `infra`. Bugs include repro steps and expected-vs-actual output. Features describe the use case.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trntensor
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.26.0
|
|
4
4
|
Summary: Tensor contractions for AWS Trainium via NKI
|
|
5
5
|
Author-email: Scott Friedman <scttfrdmn@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -144,6 +144,8 @@ core, factors = trntensor.tucker_decompose(tensor, ranks=(5, 5, 5))
|
|
|
144
144
|
| Chemistry | `df_exchange` / `df_coulomb` | Fused DF exchange (K) / Coulomb (J) from packed integrals |
|
|
145
145
|
| Chemistry | `pack_tril` / `unpack_tril` | Packed (μ≥ν) three-centre integral layout |
|
|
146
146
|
| Sharding | `ShardedTensor`, `scatter`, `gather` | Output- and reduce-parallel sharded contractions |
|
|
147
|
+
| Equivariant | `conv_tp` | e3nn "uvu" tensor product (MACE interaction), forward + ∂x/∂y/∂w |
|
|
148
|
+
| Equivariant | `symmetric_contraction` | MACE product basis (correlation ≤ 3), forward + ∂x |
|
|
147
149
|
|
|
148
150
|
## Status
|
|
149
151
|
|
|
@@ -106,6 +106,8 @@ core, factors = trntensor.tucker_decompose(tensor, ranks=(5, 5, 5))
|
|
|
106
106
|
| Chemistry | `df_exchange` / `df_coulomb` | Fused DF exchange (K) / Coulomb (J) from packed integrals |
|
|
107
107
|
| Chemistry | `pack_tril` / `unpack_tril` | Packed (μ≥ν) three-centre integral layout |
|
|
108
108
|
| Sharding | `ShardedTensor`, `scatter`, `gather` | Output- and reduce-parallel sharded contractions |
|
|
109
|
+
| Equivariant | `conv_tp` | e3nn "uvu" tensor product (MACE interaction), forward + ∂x/∂y/∂w |
|
|
110
|
+
| Equivariant | `symmetric_contraction` | MACE product basis (correlation ≤ 3), forward + ∂x |
|
|
109
111
|
|
|
110
112
|
## Status
|
|
111
113
|
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Equivariant contractions
|
|
2
|
+
|
|
3
|
+
Fixed-shape kernels for the two contractions that dominate a MACE-style
|
|
4
|
+
machine-learned interatomic potential (MLIP exemplar,
|
|
5
|
+
[trnsci/trnsci#170](https://github.com/trnsci/trnsci/issues/170); contract
|
|
6
|
+
[#138](https://github.com/trnsci/trntensor/issues/138)). Conservative MLIPs
|
|
7
|
+
compute forces as F = −∂E/∂positions, so each op has a forward and a
|
|
8
|
+
registered input gradient.
|
|
9
|
+
|
|
10
|
+
| op | shares of a CPU energy + forces step (MACE-MP-0b2 medium, 216 atoms) |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `conv_tp` (interaction tensor product) | 56% |
|
|
13
|
+
| `symmetric_contraction` (product basis) | 29% |
|
|
14
|
+
|
|
15
|
+
## `conv_tp(x, y, w, spec) -> Tensor`
|
|
16
|
+
|
|
17
|
+
The e3nn `TensorProduct` with "uvu" instructions and per-edge weights. For
|
|
18
|
+
edge `e`, channel `u` and path `p = (l1 ⊗ l2 → l3, α_p)`:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
out_p[e, u, k] = α_p · w[e, p, u] · Σ_ij C^{l1 l2 l3}_ijk · x_{l1}[e, u, i] · y_{l2}[e, j]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`C` are the real Wigner-3j symbols (e3nn basis and sign convention). Layouts
|
|
25
|
+
are e3nn's mul-major: an irreps block `mul × l` is `[mul, 2l+1]` row-major.
|
|
26
|
+
Gradients: `∂x`, `∂y`, `∂w`.
|
|
27
|
+
|
|
28
|
+
| | MACE-MP layer 0 | layer 1 |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| `x` | `[E, 128]` (128x0e) | `[E, 512]` (128x0e + 128x1o) |
|
|
31
|
+
| `y` | `[E, 16]` (0e + 1o + 2e + 3o) | `[E, 16]` |
|
|
32
|
+
| `w` | `[E, 512]`, 4 paths | `[E, 1280]`, 10 paths |
|
|
33
|
+
| out | `[E, 2048]` | `[E, 5120]` |
|
|
34
|
+
|
|
35
|
+
### `conv_tp_spec(irreps_in1=None, irreps_in2=None, irreps_out=None, instructions=None, *, module=None, w3j=None, irrep_normalization="component", path_normalization="element") -> ConvTPSpec`
|
|
36
|
+
|
|
37
|
+
Built once per layer.
|
|
38
|
+
|
|
39
|
+
- `module=`: an e3nn `TensorProduct`, or a MACE interaction block (its
|
|
40
|
+
`conv_tp` is read). The irreps, instruction order (which is also the
|
|
41
|
+
weight order) and e3nn's normalisation (`path_weight`) are read from it.
|
|
42
|
+
- Explicit irreps: e3nn strings (`"128x0e+128x1o"`) or `[(mul, l), ...]`, and
|
|
43
|
+
instructions `(i1, i2, io)` (α from e3nn's "uvu" normalisation),
|
|
44
|
+
`(i1, i2, io, α)`, or e3nn's `(i1, i2, io, "uvu", True)`.
|
|
45
|
+
- The exemplar's capture dict is accepted wherever a spec is
|
|
46
|
+
(`ConvTPSpec.from_dict`, `spec.as_dict()`).
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
ins = [(0, 0, 0), (1, 1, 1), (0, 1, 2), (1, 0, 3), (1, 2, 4)]
|
|
50
|
+
ins += [(0, 2, 5), (1, 1, 6), (1, 3, 7), (0, 3, 8), (1, 2, 9)]
|
|
51
|
+
irreps_out = "128x0e+128x0e+128x1o+128x1o+128x1o+128x2e+128x2e+128x2e+128x3o+128x3o"
|
|
52
|
+
spec = trntensor.conv_tp_spec("128x0e+128x1o", "1x0e+1x1o+1x2e+1x3o", irreps_out, ins)
|
|
53
|
+
out = trntensor.conv_tp(x, y, w, spec) # [E, 5120]
|
|
54
|
+
# or from the model: trntensor.conv_tp_spec(module=model.interactions[1].conv_tp)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## `symmetric_contraction(x, species, spec) -> Tensor`
|
|
58
|
+
|
|
59
|
+
MACE's `SymmetricContraction`, correlation ν ≤ 3:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
out[n, c, m] = Σ_ν Σ_k W_ν[z_n, k, c] · Σ_{a_1..a_ν} U_ν[m, a_1..a_ν, k] · Π_j x[n, c, a_j]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`x [N, C, 16]`, `species [N]` (int64 indices into the weight tables).
|
|
66
|
+
Returns `[N, Σ C·d_out]` in MACE's layout (output irreps in order, each
|
|
67
|
+
`[C, d_out]` row-major). Gradient: `∂x`.
|
|
68
|
+
|
|
69
|
+
### `symmetric_contraction_spec(*, module=None, contractions=None) -> SymmetricContractionSpec`
|
|
70
|
+
|
|
71
|
+
- `module=`: a MACE `SymmetricContraction` or product block. Each
|
|
72
|
+
`Contraction`'s `U_matrix_ν` buffers and weights are read (`weights_max` is
|
|
73
|
+
ν = correlation, `weights[j]` is ν = correlation − 1 − j).
|
|
74
|
+
- `contractions=`: one mapping per output irrep with `d_out`, `correlation`,
|
|
75
|
+
`U` (`{ν: [d_out, 16, …, 16, K_ν]}`, dense or COO) and `W` (`{ν: [Z, K_ν, C]}`).
|
|
76
|
+
|
|
77
|
+
## `wigner_3j(l1, l2, l3)`, `wigner_D(l, alpha, beta, gamma)`
|
|
78
|
+
|
|
79
|
+
e3nn-compatible real Wigner-3j symbols (`l ≤ 3`, checked against e3nn 0.4.4 to
|
|
80
|
+
1e-15) and Wigner D matrices (Euler `Y(α) X(β) Y(γ)`). `C` is invariant under
|
|
81
|
+
`D` on all three indices; the tests use this for the equivariance checks.
|
|
82
|
+
|
|
83
|
+
## Backends
|
|
84
|
+
|
|
85
|
+
| `set_backend` | what runs |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `"pytorch"` | the fused PyTorch formulation on the operands' device |
|
|
88
|
+
| `"nki"` | the NKI kernels, one launch per direction per layer; float64 is computed in fp32 with a one-time warning |
|
|
89
|
+
| `"auto"` | the NKI kernels for fp32 operands on the `neuron` device (native TorchNeuron path); the fused PyTorch path everywhere else. `TRNTENSOR_EQUIVARIANT_NKI=0` keeps `"auto"` on the PyTorch path. float64 on the `neuron` device is computed on the host. |
|
|
90
|
+
|
|
91
|
+
`"auto"` uses the kernels on the device since their Trn2 validation
|
|
92
|
+
(trntensor#139). `TRNTENSOR_REQUIRE_NKI=1` raises instead of falling back.
|
|
93
|
+
|
|
94
|
+
## Design
|
|
95
|
+
|
|
96
|
+
### The fused PyTorch path
|
|
97
|
+
|
|
98
|
+
- **conv_tp.** One matmul `y @ cg` builds every per-edge coupling block
|
|
99
|
+
`G[e] ∈ R^{D1×K}` from a dense block-CG matrix (`[16, 4·40]` at layer 1,
|
|
100
|
+
α folded in). Here `D1 = Σ (2 l1 + 1)` (4 at layer 1) and `K = Σ_p (2 l3 + 1)` (40).
|
|
101
|
+
One batched product `x_cat @ G` follows, then one broadcast multiply by
|
|
102
|
+
`w` per *run* of paths. A run is a group of consecutive paths with the same
|
|
103
|
+
`2 l3 + 1` and consecutive output blocks; MACE-MP has 4 runs per layer. The
|
|
104
|
+
multiply writes straight into strided views of the output in e3nn's layout.
|
|
105
|
+
The forward is 7 aten launches at layer 0 and 8 at layer 1, the backward
|
|
106
|
+
about 29. e3nn's codegen is 34 forward and 144 forward + backward at layer 1.
|
|
107
|
+
The backward recomputes the intermediates rather than saving them, and it is
|
|
108
|
+
built from differentiable ops, so double backward (training on forces) works.
|
|
109
|
+
- **symmetric_contraction.** The coupling tensors are folded onto the
|
|
110
|
+
*symmetric monomial basis*: products `x_{a1} … x_{aν}` with `a1 ≤ … ≤ aν`
|
|
111
|
+
and a non-zero coupling, 410 of the 968 at layer 0 and 94 at layer 1. Per
|
|
112
|
+
row `(node, channel)`, `out = ((mono @ usym) ⊙ W[z_n, c]) @ S`. That is one
|
|
113
|
+
`[rows, 410] × [410, 202]` matmul at layer 0, where MACE runs
|
|
114
|
+
`[rows, 768] × [768, 816]` plus `bmm`.
|
|
115
|
+
|
|
116
|
+
### The NKI kernels
|
|
117
|
+
|
|
118
|
+
**conv_tp**:
|
|
119
|
+
|
|
120
|
+
- Edges sit on the 128 partitions and channels on the free axis. Each operand
|
|
121
|
+
row is one contiguous DMA per tile of 128 edges.
|
|
122
|
+
- `G = y_tile @ cg` is one Tensor Engine matmul. The compact `cg`
|
|
123
|
+
(`[16, Q]`, `Q = Σ_p d1·d3` = 88 at layer 1) stays in SBUF for the whole kernel.
|
|
124
|
+
- Each column of `G` is a per-partition scalar. So every term of
|
|
125
|
+
`out_p[:, u, k] = Σ_i (x_i ⊙ w_p) · G[:, (p, i, k)]` is one `[128, U]`
|
|
126
|
+
instruction:
|
|
127
|
+
- the `x_i ⊙ w_p` products run on GpSimd;
|
|
128
|
+
- the first term of each `k` runs on the Scalar Engine;
|
|
129
|
+
- the accumulating terms run on the Vector Engine.
|
|
130
|
+
- e3nn's layouts are read and written through strided SBUF views.
|
|
131
|
+
- Per 128-edge tile that is 110 instructions forward at layer 1, and about
|
|
132
|
+
30 KiB (forward) or 40 KiB (backward) of the 192 KiB per partition.
|
|
133
|
+
- The backward reduces the 128 channels for `∂G` with the Vector Engine's
|
|
134
|
+
fused free-axis reduction. `∂y = ∂G @ cgᵀ` is then a Tensor Engine
|
|
135
|
+
transpose and one matmul.
|
|
136
|
+
|
|
137
|
+
**symmetric_contraction**:
|
|
138
|
+
|
|
139
|
+
- Rows `(node, channel)` are on the free axis, 512 per block. The small axes
|
|
140
|
+
are on partitions: features, monomials, coupling columns `(irrep, m, ν, k)`
|
|
141
|
+
and outputs.
|
|
142
|
+
- Every contraction is a Tensor Engine matmul accumulating in PSUM:
|
|
143
|
+
- 0/1 selections that form the monomial factors;
|
|
144
|
+
- the folded couplings;
|
|
145
|
+
- the reduction over `(ν, k)`.
|
|
146
|
+
- All constants stay in SBUF. PSUM use is 7 of 8 banks.
|
|
147
|
+
- Species enter only as a host-side row gather of the folded weight table.
|
|
148
|
+
|
|
149
|
+
**Launches.** One kernel per direction per layer. Edge counts are padded to
|
|
150
|
+
coarse buckets (a multiple of 256; 10,392 and 10,378 edges both run at 11,264),
|
|
151
|
+
so the small changes in E between MD steps reuse one compiled kernel. No index
|
|
152
|
+
is compiled in.
|
|
153
|
+
|
|
154
|
+
**Autograd.** On the native TorchNeuron path, `trntensor::conv_tp` and
|
|
155
|
+
`trntensor::symcon` are `nki_op` custom ops with `register_autograd`. Their
|
|
156
|
+
backward ops are `trntensor::conv_tp_bwd` and `trntensor::symcon_bwd`. On the
|
|
157
|
+
XLA path and the CPU simulator, `torch.autograd.Function` wrappers run the
|
|
158
|
+
same kernels. The backward kernels are first order. When autograd records
|
|
159
|
+
the backward (`create_graph=True`, training on forces), the backward is
|
|
160
|
+
built from differentiable aten ops on the same padded operands instead, so
|
|
161
|
+
double backward works on every path; forces (first order) stay on the
|
|
162
|
+
kernels.
|
|
163
|
+
|
|
164
|
+
## Tests
|
|
165
|
+
|
|
166
|
+
- `tests/test_equivariant.py` runs on CPU:
|
|
167
|
+
- against MACE's captured outputs and gradients (the exemplar's fixture);
|
|
168
|
+
- against the per-path reference;
|
|
169
|
+
- fp64 `gradcheck` and `gradgradcheck`;
|
|
170
|
+
- equivariance under random rotations;
|
|
171
|
+
- spec builders from explicit irreps, e3nn and MACE modules.
|
|
172
|
+
- `tests/test_equivariant_native.py` runs on CPU. It covers autograd and op
|
|
173
|
+
registration with emulated kernels.
|
|
174
|
+
- `tests/test_equivariant_nki.py` needs `nki`. It runs MLIR `verify()` for
|
|
175
|
+
trn1/trn2 at LNC 1 and 2, and `nki.simulate` against MACE.
|
|
176
|
+
- `tests/test_equivariant_neuron.py` runs on device. It checks correctness at
|
|
177
|
+
the 216- and 1728-atom shapes, checks captures, and has the timing harness.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# API Reference
|
|
2
2
|
|
|
3
|
-
trntensor's public API is organized into
|
|
3
|
+
trntensor's public API is organized into these modules:
|
|
4
4
|
|
|
5
5
|
- **[einsum](einsum.md)** — `einsum`, `multi_einsum`
|
|
6
6
|
- **[plan](plan.md)** — `plan_contraction`, `ContractionPlan`, `estimate_flops`
|
|
7
7
|
- **[decompose](decompose.md)** — `cp_decompose`, `tucker_decompose`, and reconstructors
|
|
8
8
|
- **[quantum](quantum.md)** — fused chemistry primitives (`mp2_energy`, `ao_to_mo_transform`, `df_exchange`, `df_coulomb`)
|
|
9
|
+
- **[equivariant](equivariant.md)** — MACE-style equivariant contractions (`conv_tp`, `symmetric_contraction`) with forward and input gradients
|
|
9
10
|
- **[nki](nki.md)** — backend dispatch (`set_backend`, `get_backend`, `HAS_NKI`)
|
|
@@ -27,6 +27,7 @@ nav:
|
|
|
27
27
|
- Decompositions: api/decompose.md
|
|
28
28
|
- Quantum primitives: api/quantum.md
|
|
29
29
|
- Streaming DF integrals: api/stream.md
|
|
30
|
+
- Equivariant contractions: api/equivariant.md
|
|
30
31
|
- NKI dispatch: api/nki.md
|
|
31
32
|
- Architecture: architecture.md
|
|
32
33
|
- Benchmarks: benchmarks.md
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=77.0", "setuptools-scm>=8.0"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "trntensor"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.26.0"
|
|
8
8
|
description = "Tensor contractions for AWS Trainium via NKI"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -93,6 +93,7 @@ ignore = [
|
|
|
93
93
|
# look unused to the linter, etc). Don't fight the kernel authoring loop.
|
|
94
94
|
"trntensor/nki/_kernels.py" = ["F841", "B007"]
|
|
95
95
|
"trntensor/nki/dispatch.py" = ["F841", "B007"]
|
|
96
|
+
"trntensor/nki/_equivariant_kernels.py" = ["F841", "B007"]
|
|
96
97
|
"scripts/*" = ["F401"]
|
|
97
98
|
"tests/*" = ["F401", "F811"]
|
|
98
99
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Merge device conformance summaries and list the NEW failures.
|
|
3
|
+
|
|
4
|
+
A device conformance run (``pytest tests/test_conformance.py --backend nki
|
|
5
|
+
--conformance-device neuron``) marks known platform limits as
|
|
6
|
+
``xfail(strict=False)`` with a ``[device-known:<category>]`` reason, and prints
|
|
7
|
+
a summary at the end. Runs on a Trainium box are split into chunks, so pass
|
|
8
|
+
``--conformance-json PATH`` to each chunk and merge them here::
|
|
9
|
+
|
|
10
|
+
pytest tests/test_conformance.py --backend nki --conformance-device neuron \\
|
|
11
|
+
-k "<chunk>" --conformance-json chunk1.json
|
|
12
|
+
python scripts/conformance_expect.py chunk*.json
|
|
13
|
+
|
|
14
|
+
Prints passed, xfailed by category, XPASS by category (a known category that
|
|
15
|
+
now passes: a signal, not a failure) and the NEW failures. Exits 1 if there
|
|
16
|
+
are NEW failures, else 0.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import argparse
|
|
22
|
+
import json
|
|
23
|
+
import sys
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def merge(paths):
|
|
27
|
+
out = {"passed": 0, "skipped": 0, "xfailed": {}, "xpassed": {}, "new_failures": []}
|
|
28
|
+
for p in paths:
|
|
29
|
+
with open(p) as fh:
|
|
30
|
+
s = json.load(fh)
|
|
31
|
+
out["passed"] += s["passed"]
|
|
32
|
+
out["skipped"] += s["skipped"]
|
|
33
|
+
for key in ("xfailed", "xpassed"):
|
|
34
|
+
for cat, ids in s[key].items():
|
|
35
|
+
out[key].setdefault(cat, []).extend(ids)
|
|
36
|
+
out["new_failures"].extend(s["new_failures"])
|
|
37
|
+
return out
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def report(s, verbose=False):
|
|
41
|
+
lines = ["conformance expectations (device run)"]
|
|
42
|
+
lines.append(f" passed: {s['passed']} skipped: {s['skipped']}")
|
|
43
|
+
for key, label in (("xfailed", "xfailed"), ("xpassed", "XPASS (known category now passes)")):
|
|
44
|
+
lines.append(f" {label}: {sum(len(v) for v in s[key].values())}")
|
|
45
|
+
for cat, ids in sorted(s[key].items()):
|
|
46
|
+
lines.append(f" {cat}: {len(ids)}")
|
|
47
|
+
if verbose or key == "xpassed":
|
|
48
|
+
lines.extend(f" {i}" for i in ids)
|
|
49
|
+
lines.append(f" NEW failures: {len(s['new_failures'])}")
|
|
50
|
+
lines.extend(f" {i}" for i in s["new_failures"])
|
|
51
|
+
return "\n".join(lines)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def main(argv=None):
|
|
55
|
+
ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
|
56
|
+
ap.add_argument("json", nargs="+", help="--conformance-json files from device runs")
|
|
57
|
+
ap.add_argument("-v", "--verbose", action="store_true", help="list xfailed IDs too")
|
|
58
|
+
args = ap.parse_args(argv)
|
|
59
|
+
s = merge(args.json)
|
|
60
|
+
print(report(s, args.verbose))
|
|
61
|
+
return 1 if s["new_failures"] else 0
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
sys.exit(main())
|
|
@@ -47,6 +47,13 @@ def pytest_addoption(parser):
|
|
|
47
47
|
default="cpu",
|
|
48
48
|
help="device for conformance-test inputs, e.g. neuron (default: cpu)",
|
|
49
49
|
)
|
|
50
|
+
group.addoption(
|
|
51
|
+
"--conformance-json",
|
|
52
|
+
metavar="PATH",
|
|
53
|
+
default=None,
|
|
54
|
+
help="write the device conformance summary (passed, xfailed/XPASS by category, "
|
|
55
|
+
"NEW failures) as JSON",
|
|
56
|
+
)
|
|
50
57
|
|
|
51
58
|
|
|
52
59
|
def pytest_configure(config):
|
|
@@ -79,3 +86,68 @@ def sr_runtime(monkeypatch):
|
|
|
79
86
|
)
|
|
80
87
|
monkeypatch.setenv(SR_ENV_VAR, "1")
|
|
81
88
|
yield
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# ---------------------------------------------------------------- device conformance summary
|
|
92
|
+
# Device conformance runs (``--backend nki --conformance-device neuron``) mark
|
|
93
|
+
# known platform limits ``xfail(strict=False)`` at run time, with a reason that
|
|
94
|
+
# starts ``[device-known:<category>]`` (see DEVICE_KNOWN in
|
|
95
|
+
# tests/test_conformance.py). On a non-CPU device run this prints passed,
|
|
96
|
+
# xfailed and XPASS by category, and the NEW failures (anything not expected).
|
|
97
|
+
# ``--conformance-json PATH`` also writes it as JSON; merge the JSON from
|
|
98
|
+
# chunked runs with ``python scripts/conformance_expect.py run1.json ...``.
|
|
99
|
+
|
|
100
|
+
_KNOWN_PREFIX = "[device-known:"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _expect_category(reason):
|
|
104
|
+
reason = reason or ""
|
|
105
|
+
if reason.startswith(_KNOWN_PREFIX):
|
|
106
|
+
return reason[len(_KNOWN_PREFIX) :].split("]", 1)[0]
|
|
107
|
+
return "other xfail"
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _expect_summary(stats):
|
|
111
|
+
def ids(key):
|
|
112
|
+
return [
|
|
113
|
+
r.nodeid for r in stats.get(key, []) if getattr(r, "when", "call") in ("call", "setup")
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
by_cat = {}
|
|
117
|
+
for key in ("xfailed", "xpassed"):
|
|
118
|
+
for r in stats.get(key, []):
|
|
119
|
+
cat = _expect_category(getattr(r, "wasxfail", ""))
|
|
120
|
+
by_cat.setdefault(key, {}).setdefault(cat, []).append(r.nodeid)
|
|
121
|
+
return {
|
|
122
|
+
"passed": len(ids("passed")),
|
|
123
|
+
"skipped": len(stats.get("skipped", [])),
|
|
124
|
+
"xfailed": by_cat.get("xfailed", {}),
|
|
125
|
+
"xpassed": by_cat.get("xpassed", {}),
|
|
126
|
+
"new_failures": ids("failed") + [r.nodeid for r in stats.get("error", [])],
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _print_expect_summary(write, s):
|
|
131
|
+
write("conformance expectations (device run)")
|
|
132
|
+
write(f" passed: {s['passed']} skipped: {s['skipped']}")
|
|
133
|
+
for key, label in (("xfailed", "xfailed"), ("xpassed", "XPASS (known category now passes)")):
|
|
134
|
+
total = sum(len(v) for v in s[key].values())
|
|
135
|
+
write(f" {label}: {total}")
|
|
136
|
+
for cat, nodeids in sorted(s[key].items()):
|
|
137
|
+
write(f" {cat}: {len(nodeids)}")
|
|
138
|
+
write(f" NEW failures: {len(s['new_failures'])}")
|
|
139
|
+
for nodeid in s["new_failures"]:
|
|
140
|
+
write(f" {nodeid}")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def pytest_terminal_summary(terminalreporter, exitstatus, config):
|
|
144
|
+
path = config.getoption("--conformance-json", None)
|
|
145
|
+
if config.getoption("--conformance-device", "cpu") == "cpu" and not path:
|
|
146
|
+
return
|
|
147
|
+
s = _expect_summary(terminalreporter.stats)
|
|
148
|
+
_print_expect_summary(lambda line: terminalreporter.write_line(line), s)
|
|
149
|
+
if path:
|
|
150
|
+
import json
|
|
151
|
+
|
|
152
|
+
with open(path, "w") as fh:
|
|
153
|
+
json.dump(s, fh, indent=1)
|
|
Binary file
|