Skip to content

Commit 0d4355c

Browse files
Olivia-liufacebook-github-bot
authored andcommitted
API life cycle and deprecation policy in official documentation (#4529)
Summary: Pull Request resolved: #4529 This diff adds a new page to the ET public documentation site that establishes the API life cycle and deprecation policy. It's also been linked to from related docs. The doc has some TODO items we can either address in this diff or with follow-up diffs. ***For Meta reviewers: to comment easily, you can review in https://docs.google.com/document/d/1FJmsWoP544bF0Xe3SeREcLAbKPqgrxulScBdak0UoVs/edit?usp=sharing*** Differential Revision: D60692061
1 parent bf477e4 commit 0d4355c

File tree

6 files changed

+155
-0
lines changed

6 files changed

+155
-0
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ We actively welcome your pull requests (PRs).
2323
See the [testing section](#testing) for more information.
2424
1. If you've changed APIs or added a new tool or feature, [update the
2525
documentation](#updating-documentation).
26+
1. If you added an experimental API or deprecated an existing API, follow the
27+
[API Life Cycle and Deprecation Policy](/docs/source/api-life-cycle.md).
2628
1. Make sure your code follows the [style guides](#coding-style) and passes the
2729
[lint checks](#lintrunner).
2830
1. If you haven't already, complete the [Contributor License Agreement ("CLA")](#contributor-license-agreement-cla).
226 KB
Loading

docs/source/api-life-cycle.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# ExecuTorch API Life Cycle and Deprecation Policy
2+
3+
4+
## API Life Cycle
5+
![name](_static/img/api_life_cycle.png)
6+
7+
Each API of ExecuTorch falls into one of the following life cycle states:
8+
9+
10+
_Experimental_
11+
12+
* APIs in this stage are under active development and may change or be removed at any time. That said, the expectation is that we will eventually promote it to _Stable_, unless sufficient negative signals have been collected from the community or better alternatives have been found.
13+
* _Experimental_ APIs will be clearly marked (see the “How to Mark API State” section below).
14+
* _Experimental_ APIs may be changed or removed without notice, and developers should expect no stability guarantees.
15+
16+
_Stable_
17+
18+
* APIs are considered to be _Stable_ if they are not marked as _Experimental_ or _Deprecated._
19+
* APIs in this stage have been thoroughly tested and are considered ready for production use.
20+
* The recommended best practice is to not deprecate stable APIs. When writing an API, write it in such a way that it doesn’t need to be deprecated in the future.
21+
* _Stable_ APIs can be changed, but not in a breaking way. If breaking changes have to be made, _Stable_ APIs will always transition to _Deprecated_ before being broken/removed from the library.
22+
23+
_Deprecated_
24+
25+
* APIs in this stage are no longer recommended for use and will be removed in a future version of ExecuTorch.
26+
* _Deprecated_ APIs will be clearly marked (see the “How to Mark API State” section below).
27+
* _Deprecated_ APIs will remain functional for at least the _deprecation period_ (see the “Deprecation Period” section below) to allow developers time to migrate to alternative APIs.
28+
29+
_Deleted_
30+
31+
* APIs whose removal are made permanent. Cleaned up from both code and documentation.
32+
33+
34+
35+
## Deprecation Policy
36+
37+
Follow these steps to deprecate and remove an API:
38+
39+
1. Discuss the change and collect initial feedback.
40+
2. Clearly mark the API deprecated in code and documentation (See “How to Mark API State” below).
41+
3. Listen to user feedback after the first release that deprecates the API. Users who weren't involved in the original discussion may have good arguments for not deprecating or removing the API.
42+
4. Once the deprecation period has passed, the API may be removed (See “Deprecation Period” below). Be sure to also remove references from the documentation.
43+
44+
45+
We also use deprecation as a way to make breaking changes to an existing interface: for example, if adding a non-optional parameter to a method. To do this without breaking existing users:
46+
1. In a single commit:
47+
- Create a new API that meets the new requirements.
48+
- Deprecate the old API and recommend that users move to the new API.
49+
2. Migrate use cases from the old API to the new API.
50+
3. Delete the old API after the deprecation period.
51+
52+
53+
## How to Mark API State
54+
55+
When possible, the ExecuTorch code uses language-standard ways to annotate API lifecycle state in the code. This makes it easier for IDEs and other tools to communicate state to developers.
56+
57+
<table>
58+
<tr>
59+
<td><strong>API</strong>
60+
</td>
61+
<td><strong>Code</strong>
62+
</td>
63+
<td><strong>Documentation</strong>
64+
</td>
65+
</tr>
66+
<tr>
67+
<td>Python
68+
</td>
69+
<td>
70+
71+
<em>Deprecated</em>: use the <a href="https://typing-extensions.readthedocs.io/en/latest/#typing_extensions.deprecated">typing_extensions.deprecated</a> decorator
72+
73+
<em>Experimental</em>: use ExecuTorch's native experimental (TODO not yet implemented) decorator
74+
75+
</td>
76+
<td>
77+
78+
Use <code>.. warning::</code> in the docstrings of deprecated and experimental APIs. See <a href="https://github.com/pytorch/pytorch/blob/cd8bbdc71a0258292381a7d54c8b353988d02ff4/torch/nn/utils/stateless.py#L170">example usage</a>.
79+
</ul>
80+
</td>
81+
</tr>
82+
<tr>
83+
<td>C++
84+
</td>
85+
<td>
86+
87+
Use the <code>__ET_DEPRECATED</code> or (TODO not yet implemented) <code>__ET_EXPERIMENTAL</code> macros. See <a href="https://github.com/pytorch/executorch/blob/8e0f856ee269b319ac4195509cf31e3f548aa0e8/runtime/executor/program.h#L81">example usage</a>.
88+
</ul>
89+
</td>
90+
<td>
91+
92+
Start Doxygen comments with "DEPRECATED:" or "EXPERIMENTAL:". See <a href="https://github.com/pytorch/executorch/blob/9d859653ae916d0a72f6b2b5c5925bed38832140/runtime/executor/program.h#L139">example usage</a>.
93+
94+
</td>
95+
</tr>
96+
<tr>
97+
<td>Android
98+
</td>
99+
<td>Deprecated: use <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Deprecated.html">java.lang.Deprecated</a>
100+
<p>
101+
Experimental: use <a href="https://developer.android.com/reference/androidx/annotation/RequiresOptIn">androidx.annotation.RequiresOptIn</a>
102+
</td>
103+
<td>/**
104+
<p>
105+
@deprecated As of release x.x, replaced by {@link #newMethod()}
106+
<p>
107+
*/
108+
<p>
109+
/**
110+
<p>
111+
Warning: This API is experimental
112+
<p>
113+
*/
114+
</td>
115+
</tr>
116+
<tr>
117+
<td>Apple
118+
</td>
119+
<td>In Objective-C:
120+
<p>
121+
<code>__attribute__((deprecated("Use newMethod instead")));</code>
122+
<p>
123+
In Swift:
124+
<p>
125+
<code>@available(*, deprecated, message: "Use newMethod instead")</code>
126+
</td>
127+
<td>In Objective-C:
128+
<p>
129+
/**
130+
<p>
131+
* @deprecated Use `newMethod` instead.
132+
<p>
133+
*/
134+
<p>
135+
In Swift:
136+
<p>
137+
/// - Warning: Deprecated. Use `newMethod()` instead.
138+
</td>
139+
</tr>
140+
</table>
141+
142+
The annotations would trigger static and/or runtime warning that contains at least these information:
143+
1. Clearly point to the non-deprecated alternative to migrate to, or be clear if there is no alternative;
144+
2. Specify the earliest version in which the API may actually be removed (See “Deprecation Period” below).
145+
146+
## Deprecation Period
147+
148+
Here we recommend waiting for at least 2 minor releases before the removal. For example, if a function is marked as _deprecated_ in release 1.3.x, then it can be _deleted_ in 1.5.x or later.

docs/source/executorch-runtime-api-reference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The ExecuTorch C++ API provides an on-device execution framework for exported Py
66
For a tutorial style introduction to the runtime API, check out the
77
`runtime tutorial <running-a-model-cpp-tutorial.html>`__ and its `simplified <extension-module.html>`__ version.
88

9+
For detailed information on how APIs evolve and the deprecation process, please refer to the `ExecuTorch API Life Cycle and Deprecation Policy <api-life-cycle.html>`__.
10+
911
Model Loading and Execution
1012
---------------------------
1113

docs/source/export-to-executorch-api-reference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Export to ExecuTorch API Reference
22
----------------------------------
33

4+
For detailed information on how APIs evolve and the deprecation process, please refer to the `ExecuTorch API Life Cycle and Deprecation Policy <api-life-cycle.html>`__.
5+
46
.. automodule:: executorch.exir
57
.. autofunction:: to_edge
68

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Topics in this section will help you get started with ExecuTorch.
126126

127127
export-to-executorch-api-reference
128128
executorch-runtime-api-reference
129+
api-life-cycle
129130

130131
.. toctree::
131132
:glob:

0 commit comments

Comments
 (0)