jax-pyrefly-stubs 1.4.0.dev3__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.5
2
+ Name: jax-pyrefly-stubs
3
+ Version: 1.4.0.dev3
4
+ Summary: JAX type stubs with array-shape tracking, maintained by Pyrefly
5
+ Project-URL: homepage, https://pyrefly.org
6
+ Project-URL: documentation, https://pyrefly.org/en/docs/
7
+ License: MIT License
8
+
9
+ Copyright (c) Meta Platforms, Inc. and affiliates.
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ License-File: LICENSE
29
+ Keywords: jax,stubs,typechecker,typechecking
30
+ Classifier: Development Status :: 4 - Beta
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Typing :: Stubs Only
35
+ Requires-Python: >=3.12
36
+ Requires-Dist: pyrefly-shape-extensions==1.4.0.dev3
37
+ Description-Content-Type: text/markdown
38
+
39
+ # Pyrefly JAX shape stubs
40
+
41
+ This package is a PEP 561 stub-only distribution. It installs the `jax-stubs`
42
+ stub package so Pyrefly can discover shape-aware stubs for the runtime `jax`
43
+ package without replacing or shadowing JAX itself. It is versioned in lockstep
44
+ with Pyrefly and depends on the matching `pyrefly-shape-extensions` package.
45
+
46
+ Shape-typed fixture stubs for a subset of JAX. This is a starting point for
47
+ working with the JAX core team rather than a complete model: it covers array
48
+ creation, broadcasting arithmetic, `matmul`, `reshape`, `transpose`, the
49
+ `axis`/`keepdims` reductions, and the elementwise activations in `jax.nn`.
50
+ Dimensions are modeled and dtypes are not, so adding dtypes later means modeling
51
+ JAX's own defaults (`float32` and `int32`) rather than copying the NumPy stubs.
52
+
53
+ Shape rules use the type-level DSL, `@type_shape_dsl_function`, exclusively. A
54
+ rule the DSL cannot express yet returns a gradual shape instead. Where a rule is
55
+ imprecise for that reason, the stub says so at the definition, along with
56
+ whether a fix is expected.
57
+
58
+ `TENSOR_SHAPES_CONTRIBUTING.md` at the repository root covers the workflow, and
59
+ `tensor-shapes/run_tests.py` runs the tests. Pyrefly checks the stubs themselves
60
+ and every `test/test_*.py`, and those same test files then run against real
61
+ JAX, so a stub that is self-consistent but wrong still fails.
62
+
63
+ Before submitting a change, format this package with Ruff from the repository
64
+ root:
65
+
66
+ ```bash
67
+ uv tool run --from ruff==0.16.5 ruff format tensor-shapes/jax-pyrefly-stubs
68
+ ```
69
+
70
+ Anything not listed above is simply absent rather than modeled loosely, so it is
71
+ reported as a missing attribute rather than inferred gradually.
@@ -0,0 +1,33 @@
1
+ # Pyrefly JAX shape stubs
2
+
3
+ This package is a PEP 561 stub-only distribution. It installs the `jax-stubs`
4
+ stub package so Pyrefly can discover shape-aware stubs for the runtime `jax`
5
+ package without replacing or shadowing JAX itself. It is versioned in lockstep
6
+ with Pyrefly and depends on the matching `pyrefly-shape-extensions` package.
7
+
8
+ Shape-typed fixture stubs for a subset of JAX. This is a starting point for
9
+ working with the JAX core team rather than a complete model: it covers array
10
+ creation, broadcasting arithmetic, `matmul`, `reshape`, `transpose`, the
11
+ `axis`/`keepdims` reductions, and the elementwise activations in `jax.nn`.
12
+ Dimensions are modeled and dtypes are not, so adding dtypes later means modeling
13
+ JAX's own defaults (`float32` and `int32`) rather than copying the NumPy stubs.
14
+
15
+ Shape rules use the type-level DSL, `@type_shape_dsl_function`, exclusively. A
16
+ rule the DSL cannot express yet returns a gradual shape instead. Where a rule is
17
+ imprecise for that reason, the stub says so at the definition, along with
18
+ whether a fix is expected.
19
+
20
+ `TENSOR_SHAPES_CONTRIBUTING.md` at the repository root covers the workflow, and
21
+ `tensor-shapes/run_tests.py` runs the tests. Pyrefly checks the stubs themselves
22
+ and every `test/test_*.py`, and those same test files then run against real
23
+ JAX, so a stub that is self-consistent but wrong still fails.
24
+
25
+ Before submitting a change, format this package with Ruff from the repository
26
+ root:
27
+
28
+ ```bash
29
+ uv tool run --from ruff==0.16.5 ruff format tensor-shapes/jax-pyrefly-stubs
30
+ ```
31
+
32
+ Anything not listed above is simply absent rather than modeled loosely, so it is
33
+ reported as a missing attribute rather than inferred gradually.
@@ -0,0 +1,186 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ from types import SimpleNamespace
7
+ from typing import Any, Callable
8
+
9
+ # Override jax.Array with shape-aware version.
10
+ from jax._array import Array as Array
11
+
12
+ # Override jit and vmap because jax annotations fail with shaped arrays.
13
+ def jit[F: Callable[..., Any]](fun: F, *args: Any, **kwargs: Any) -> F: ...
14
+ def vmap(fun: Callable[..., Any], *args: Any, **kwargs: Any) -> Callable[..., Any]: ...
15
+
16
+ # Remaining APIs mirror imports in jax/__init__.py,
17
+ # generated here based on jax v0.11.2
18
+ from jax import (
19
+ api_util as api_util,
20
+ custom_batching as custom_batching,
21
+ custom_derivatives as custom_derivatives,
22
+ debug as debug,
23
+ distributed as distributed,
24
+ dlpack as dlpack,
25
+ dtypes as dtypes,
26
+ errors as errors,
27
+ experimental as experimental,
28
+ export as export,
29
+ ffi as ffi,
30
+ image as image,
31
+ interpreters as interpreters,
32
+ lib as lib,
33
+ monitoring as monitoring,
34
+ ops as ops,
35
+ profiler as profiler,
36
+ random as random,
37
+ scipy as scipy,
38
+ sharding as sharding,
39
+ stages as stages,
40
+ tree as tree,
41
+ tree_util as tree_util,
42
+ typing as typing,
43
+ )
44
+ from jax._src.ad_checkpoint import (
45
+ checkpoint as checkpoint,
46
+ checkpoint_policies as checkpoint_policies,
47
+ custom_remat as custom_remat,
48
+ remat as remat,
49
+ )
50
+ from jax._src.api import (
51
+ block_until_ready as block_until_ready,
52
+ clear_caches as clear_caches,
53
+ copy_to_host_async as copy_to_host_async,
54
+ device_get as device_get,
55
+ device_put as device_put,
56
+ device_put_replicated as device_put_replicated,
57
+ device_put_sharded as device_put_sharded,
58
+ disable_jit as disable_jit,
59
+ effects_barrier as effects_barrier,
60
+ eval_shape as eval_shape,
61
+ fwd_and_bwd as fwd_and_bwd,
62
+ grad as grad,
63
+ hessian as hessian,
64
+ Inline as Inline,
65
+ jacfwd as jacfwd,
66
+ jacobian as jacobian,
67
+ jacrev as jacrev,
68
+ jvp as jvp,
69
+ linear_transpose as linear_transpose,
70
+ linearize as linearize,
71
+ live_arrays as live_arrays,
72
+ make_jaxpr as make_jaxpr,
73
+ named_call as named_call,
74
+ named_scope as named_scope,
75
+ value_and_grad as value_and_grad,
76
+ vjp as vjp,
77
+ )
78
+ from jax._src.array import (
79
+ make_array_from_callback as make_array_from_callback,
80
+ make_array_from_process_local_data as make_array_from_process_local_data,
81
+ make_array_from_single_device_arrays as make_array_from_single_device_arrays,
82
+ Shard as Shard,
83
+ )
84
+ from jax._src.callback import pure_callback as pure_callback
85
+ from jax._src.compiler import CompilerEffortLevel as CompilerEffortLevel
86
+ from jax._src.config import (
87
+ allow_f16_reductions as allow_f16_reductions,
88
+ array_garbage_collection_guard as array_garbage_collection_guard,
89
+ auto_pcast as auto_pcast,
90
+ check_tracer_leaks as check_tracer_leaks,
91
+ checking_leaks as checking_leaks,
92
+ config as config,
93
+ debug_infs as debug_infs,
94
+ debug_key_reuse as debug_key_reuse,
95
+ debug_nans as debug_nans,
96
+ default_device as default_device,
97
+ default_matmul_precision as default_matmul_precision,
98
+ default_prng_impl as default_prng_impl,
99
+ enable_checks as enable_checks,
100
+ enable_custom_prng as enable_custom_prng,
101
+ enable_x64 as enable_x64,
102
+ explain_cache_misses as explain_cache_misses,
103
+ jax2tf_associative_scan_reductions as jax2tf_associative_scan_reductions,
104
+ legacy_prng_key as legacy_prng_key,
105
+ log_compiles as log_compiles,
106
+ make_user_context as make_user_context,
107
+ no_execution as no_execution,
108
+ no_tracing as no_tracing,
109
+ numpy_dtype_promotion as numpy_dtype_promotion,
110
+ numpy_rank_promotion as numpy_rank_promotion,
111
+ remove_size_one_mesh_axis_from_type as remove_size_one_mesh_axis_from_type,
112
+ softmax_custom_jvp as softmax_custom_jvp,
113
+ thread_guard as thread_guard,
114
+ threefry_partitionable as threefry_partitionable,
115
+ transfer_guard as transfer_guard,
116
+ transfer_guard_device_to_device as transfer_guard_device_to_device,
117
+ transfer_guard_device_to_host as transfer_guard_device_to_host,
118
+ transfer_guard_host_to_device as transfer_guard_host_to_device,
119
+ )
120
+ from jax._src.core import (
121
+ ensure_compile_time_eval as ensure_compile_time_eval,
122
+ ShapeDtypeStruct as ShapeDtypeStruct,
123
+ typeof as typeof,
124
+ )
125
+ from jax._src.custom_derivatives import (
126
+ closure_convert as closure_convert,
127
+ custom_gradient as custom_gradient,
128
+ custom_jvp as custom_jvp,
129
+ custom_vjp as custom_vjp,
130
+ )
131
+ from jax._src.dtypes import float0 as float0
132
+ from jax._src.environment_info import print_environment_info as print_environment_info
133
+ from jax._src.indexing import ds as ds
134
+ from jax._src.mesh import (
135
+ get_abstract_mesh as get_abstract_mesh,
136
+ use_abstract_mesh as use_abstract_mesh,
137
+ )
138
+ from jax._src.partition_spec import P as P
139
+ from jax._src.pjit import reshard as reshard
140
+ from jax._src.pmap import pmap as pmap
141
+ from jax._src.shard_map import (
142
+ shard_map as shard_map,
143
+ smap as smap,
144
+ )
145
+ from jax._src.sharding_impls import (
146
+ get_mesh as get_mesh,
147
+ make_mesh as make_mesh,
148
+ NamedSharding as NamedSharding,
149
+ set_mesh as set_mesh,
150
+ )
151
+ from jax._src.xla_bridge import (
152
+ default_backend as default_backend,
153
+ device_count as device_count,
154
+ devices as devices,
155
+ host_count as host_count,
156
+ host_id as host_id,
157
+ host_ids as host_ids,
158
+ local_device_count as local_device_count,
159
+ local_devices as local_devices,
160
+ process_count as process_count,
161
+ process_index as process_index,
162
+ process_indices as process_indices,
163
+ )
164
+ from jax.ref import (
165
+ empty_ref as empty_ref,
166
+ free_ref as free_ref,
167
+ freeze as freeze,
168
+ new_ref as new_ref,
169
+ Ref as Ref,
170
+ )
171
+ from jax.version import (
172
+ __version__ as __version__,
173
+ __version_info__ as __version_info__,
174
+ )
175
+ from jaxlib._jax import Device as Device
176
+
177
+ # Import local typestubs for submodules defined in jax-pyrefly-stubs.
178
+ from . import (
179
+ lax as lax,
180
+ nn as nn,
181
+ numpy as numpy,
182
+ random as random,
183
+ )
184
+
185
+ ad: SimpleNamespace
186
+ memory: SimpleNamespace