spmd_types 0.2.4__tar.gz → 0.3.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.
Files changed (42) hide show
  1. {spmd_types-0.2.4/spmd_types.egg-info → spmd_types-0.3.0}/PKG-INFO +13 -1
  2. {spmd_types-0.2.4 → spmd_types-0.3.0}/README.md +7 -0
  3. spmd_types-0.3.0/pyproject.toml +69 -0
  4. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/__init__.py +2 -0
  5. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_backward_hooks.py +16 -4
  6. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_checker/__init__.py +407 -282
  7. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_collectives.py +10 -28
  8. spmd_types-0.3.0/spmd_types/_coverage.py +64 -0
  9. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_mesh.py +1 -0
  10. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_mesh_region.py +31 -5
  11. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_raw_dist.py +14 -2
  12. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_traceback.py +3 -1
  13. spmd_types-0.3.0/spmd_types/py.typed +0 -0
  14. spmd_types-0.3.0/spmd_types/rulecheck.py +946 -0
  15. spmd_types-0.3.0/spmd_types/rules.py +1073 -0
  16. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/runtime.py +83 -22
  17. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/types.py +3 -0
  18. {spmd_types-0.2.4 → spmd_types-0.3.0/spmd_types.egg-info}/PKG-INFO +13 -1
  19. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types.egg-info/SOURCES.txt +5 -0
  20. spmd_types-0.3.0/spmd_types.egg-info/requires.txt +5 -0
  21. spmd_types-0.2.4/pyproject.toml +0 -50
  22. {spmd_types-0.2.4 → spmd_types-0.3.0}/LICENSE +0 -0
  23. {spmd_types-0.2.4 → spmd_types-0.3.0}/setup.cfg +0 -0
  24. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_dist.py +0 -0
  25. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_dtensor.py +0 -0
  26. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_dtensor_checker.py +0 -0
  27. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_dtype_utils.py +0 -0
  28. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_frame.py +0 -0
  29. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_local.py +0 -0
  30. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_local_registration.py +0 -0
  31. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_mesh_axis.py +0 -0
  32. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_reinterpret_mesh.py +0 -0
  33. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_scalar.py +0 -0
  34. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_scalar_sentinel.py +0 -0
  35. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_state.py +0 -0
  36. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_test_utils.py +0 -0
  37. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_testing.py +0 -0
  38. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_type_attr.py +0 -0
  39. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/_vmap.py +0 -0
  40. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types/checker.py +0 -0
  41. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types.egg-info/dependency_links.txt +0 -0
  42. {spmd_types-0.2.4 → spmd_types-0.3.0}/spmd_types.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spmd_types
3
- Version: 0.2.4
3
+ Version: 0.3.0
4
4
  Summary: A type system for distributed (SPMD) tensor computations in PyTorch
5
5
  Author: Meta Platforms, Inc.
6
6
  License: BSD 3-Clause License
@@ -33,6 +33,7 @@ License: BSD 3-Clause License
33
33
  DAMAGE.
34
34
 
35
35
  Project-URL: Homepage, https://github.com/meta-pytorch/spmd_types
36
+ Project-URL: Documentation, https://meta-pytorch.org/spmd_types/
36
37
  Project-URL: Repository, https://github.com/meta-pytorch/spmd_types
37
38
  Project-URL: Issues, https://github.com/meta-pytorch/spmd_types/issues
38
39
  Classifier: Development Status :: 4 - Beta
@@ -47,6 +48,10 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
47
48
  Requires-Python: >=3.10
48
49
  Description-Content-Type: text/markdown
49
50
  License-File: LICENSE
51
+ Provides-Extra: docs
52
+ Requires-Dist: myst-parser==2.0.0; extra == "docs"
53
+ Requires-Dist: pytorch-sphinx-theme2==0.4.13; extra == "docs"
54
+ Requires-Dist: sphinx==7.2.6; extra == "docs"
50
55
  Dynamic: license-file
51
56
 
52
57
  # `spmd_types`
@@ -107,10 +112,17 @@ dist.destroy_process_group()
107
112
 
108
113
  ## Documentation
109
114
 
115
+ See the [SPMD Types documentation](https://meta-pytorch.org/spmd_types/) for
116
+ the complete user and API documentation.
117
+
110
118
  See [Local SPMD types](docs/local_spmd_types.md) for a hands-on guide on
111
119
  porting Megatron-derived training frameworks, including the Megatron-to-spmd_types
112
120
  function mapping table and advice on Invariant vs Replicate.
113
121
 
122
+ See [Rules](docs/rules.md) for how to write an `spmd_typecheck` typing rule
123
+ for your own custom autograd functions by composing `spmd_types.rules`, and
124
+ how to test it numerically with `rulecheck`.
125
+
114
126
  See [Design](docs/design.md) for the full type system specification, including
115
127
  local vs global SPMD modes, collective signatures with diagrams, forward-backward
116
128
  pairs, expert mode, cross-mesh compatibility, and partition spec redistribute.
@@ -56,10 +56,17 @@ dist.destroy_process_group()
56
56
 
57
57
  ## Documentation
58
58
 
59
+ See the [SPMD Types documentation](https://meta-pytorch.org/spmd_types/) for
60
+ the complete user and API documentation.
61
+
59
62
  See [Local SPMD types](docs/local_spmd_types.md) for a hands-on guide on
60
63
  porting Megatron-derived training frameworks, including the Megatron-to-spmd_types
61
64
  function mapping table and advice on Invariant vs Replicate.
62
65
 
66
+ See [Rules](docs/rules.md) for how to write an `spmd_typecheck` typing rule
67
+ for your own custom autograd functions by composing `spmd_types.rules`, and
68
+ how to test it numerically with `rulecheck`.
69
+
63
70
  See [Design](docs/design.md) for the full type system specification, including
64
71
  local vs global SPMD modes, collective signatures with diagrams, forward-backward
65
72
  pairs, expert mode, cross-mesh compatibility, and partition spec redistribute.
@@ -0,0 +1,69 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "spmd_types"
7
+ version = "0.3.0"
8
+ description = "A type system for distributed (SPMD) tensor computations in PyTorch"
9
+ readme = "README.md"
10
+ license = {file = "LICENSE"}
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ {name = "Meta Platforms, Inc."},
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Science/Research",
19
+ "License :: OSI Approved :: BSD License",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+ dependencies = [
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ docs = [
31
+ "myst-parser==2.0.0",
32
+ "pytorch-sphinx-theme2==0.4.13",
33
+ "sphinx==7.2.6",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/meta-pytorch/spmd_types"
38
+ Documentation = "https://meta-pytorch.org/spmd_types/"
39
+ Repository = "https://github.com/meta-pytorch/spmd_types"
40
+ Issues = "https://github.com/meta-pytorch/spmd_types/issues"
41
+
42
+ [tool.setuptools.packages.find]
43
+ include = ["spmd_types*"]
44
+
45
+ [tool.setuptools.package-data]
46
+ spmd_types = ["py.typed"]
47
+
48
+
49
+ [tool.ruff]
50
+ line-length = 88
51
+ target-version = "py310"
52
+
53
+ [tool.ruff.lint]
54
+ select = ["E4", "E7", "E9", "F"]
55
+
56
+ [tool.ruff.format]
57
+ exclude = ["*.md"]
58
+ quote-style = "double"
59
+
60
+ [tool.pytest.ini_options]
61
+ testpaths = ["tests"]
62
+ python_files = ["*_test.py"]
63
+
64
+ [tool.test-selector.extra-deps]
65
+
66
+ # BEGIN GENERATED buck-manual-deps -- do not edit by hand
67
+ # Regenerate: export_buck_manual_deps.py
68
+ "spmd_types/__init__.py" = ["../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_audio_artifacts.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_audio_artifacts_v22.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_audio_encoder_r6_i11_v22.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_conditioner_calibration_v21.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_ctts_pipeline_r6_i11_v22.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_landscape_recipe_r5_v21.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_landscape_sampling_r5.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_landscape_sampling_r6_i11_v22.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_landscape_sampling_r6_i11_v22_gb300.py", "../../llama4x/projects/experimental/rtai_avatar/pumpkin/sythetic_data/t2av/conversation_landscape_style_r5_v21.py", "../ops/interfaces/attn/triton_attention_fp32.py", "../ops/interfaces/gemm/gemm.py"]
69
+ # END GENERATED buck-manual-deps
@@ -7,6 +7,7 @@
7
7
  # spmd_types package
8
8
  from __future__ import annotations
9
9
 
10
+ from spmd_types import rules # noqa: F401
10
11
  from spmd_types._collectives import ( # noqa: F401
11
12
  all_gather,
12
13
  all_reduce,
@@ -65,6 +66,7 @@ from spmd_types.runtime import ( # noqa: F401
65
66
  no_typecheck,
66
67
  register_autograd_function,
67
68
  register_decomposition,
69
+ reinterpret_no_grad,
68
70
  trace,
69
71
  )
70
72
 
@@ -97,10 +97,22 @@ def install() -> None:
97
97
  if _orig_setup_input_hook is not None:
98
98
  return
99
99
 
100
- from spmd_types._checker import register_autograd_function
101
-
102
- BackwardHookFunction.typecheck_forward = staticmethod(BackwardHookFunction.apply)
103
- register_autograd_function(BackwardHookFunction)
100
+ def _spmd_typecheck(outputs, *, args):
101
+ # BackwardHookFunction is the identity on its tensor arguments: each
102
+ # output carries its input's type and sharding (rules imports runtime,
103
+ # so import lazily here).
104
+ from spmd_types import rules
105
+
106
+ if len(outputs) != len(args):
107
+ raise SpmdTypeError(
108
+ "BackwardHookFunction returned a different number of values than "
109
+ f"it received ({len(outputs)} vs. {len(args)})"
110
+ )
111
+ for out, arg in zip(outputs, args):
112
+ if isinstance(out, torch.Tensor) and isinstance(arg, torch.Tensor):
113
+ rules.einsum("...->...", arg, linear_in=(0,), out=out)
114
+
115
+ BackwardHookFunction.spmd_typecheck = staticmethod(_spmd_typecheck)
104
116
 
105
117
  _orig_setup_input_hook = _torch_hooks.BackwardHook.setup_input_hook
106
118
  _orig_setup_output_hook = _torch_hooks.BackwardHook.setup_output_hook