cortexnet 3.2.1__tar.gz → 3.2.3__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.
- {cortexnet-3.2.1 → cortexnet-3.2.3}/PKG-INFO +34 -1
- {cortexnet-3.2.1 → cortexnet-3.2.3}/README.md +26 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/__init__.py +1 -1
- cortexnet-3.2.3/cortexnet/__main__.py +45 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/compat.py +8 -5
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/multi_agent.py +3 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet.egg-info/PKG-INFO +34 -1
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet.egg-info/SOURCES.txt +4 -1
- cortexnet-3.2.3/cortexnet.egg-info/entry_points.txt +2 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet.egg-info/requires.txt +3 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/pyproject.toml +9 -2
- cortexnet-3.2.3/tests/test_public_api.py +49 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/LICENSE +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/adapter/__init__.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/adapter/arch_adapter.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/adapter/calibrator.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/adapter/inference_adapter.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/adapter/model_registry.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/adapter/weight_adapter.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/adversarial.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/attention.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/blocks.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/cache.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/causal_reasoning.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/config.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/continual_learning.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/cortex_block_lite.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/distributed.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/graph_reasoning.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/hierarchical_memory.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/interpretability.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/memory.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/meta_learning.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/model.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/multimodal.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/ops/__init__.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/ops/device_manager.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/ops/npu_ops.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/quantization.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/routing.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/self_evolution.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/ssm.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/training_utils.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet/transformer_baseline.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet.egg-info/dependency_links.txt +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/cortexnet.egg-info/top_level.txt +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/setup.cfg +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/tests/test_all.py +0 -0
- {cortexnet-3.2.1 → cortexnet-3.2.3}/tests/test_core_modules.py +0 -0
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cortexnet
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.3
|
|
4
4
|
Summary: CortexNet: unified neural network architecture beyond Transformers
|
|
5
5
|
Author: CortexNet Team
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/chaojixiaokeai/CortexNet
|
|
8
|
+
Project-URL: Repository, https://github.com/chaojixiaokeai/CortexNet
|
|
9
|
+
Project-URL: Issues, https://github.com/chaojixiaokeai/CortexNet/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/chaojixiaokeai/CortexNet/blob/main/CHANGELOG.md
|
|
7
11
|
Keywords: deep-learning,llm,state-space-model,sparse-attention,pytorch
|
|
8
12
|
Classifier: Development Status :: 4 - Beta
|
|
9
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -28,12 +32,19 @@ Provides-Extra: dev
|
|
|
28
32
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
33
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
30
34
|
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pyflakes>=3.2.0; extra == "dev"
|
|
36
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
31
38
|
Provides-Extra: distributed
|
|
32
39
|
Requires-Dist: deepspeed>=0.10.0; extra == "distributed"
|
|
33
40
|
Dynamic: license-file
|
|
34
41
|
|
|
35
42
|
# CortexNet
|
|
36
43
|
|
|
44
|
+
[](https://github.com/chaojixiaokeai/CortexNet/actions/workflows/ci.yml)
|
|
45
|
+
[](https://pypi.org/project/cortexnet/)
|
|
46
|
+
[](./LICENSE)
|
|
47
|
+
|
|
37
48
|
`CortexNet` 是一个面向语言建模与推理场景的神经网络架构实现,核心思路是将多尺度状态空间建模、选择性稀疏注意力、记忆系统、条件路由与可选高级推理模块组合到同一框架中。
|
|
38
49
|
|
|
39
50
|
本仓库已经完成以下整理:
|
|
@@ -58,6 +69,13 @@ python -m build
|
|
|
58
69
|
pip install dist/*.whl
|
|
59
70
|
```
|
|
60
71
|
|
|
72
|
+
## CLI
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
python -m cortexnet --version
|
|
76
|
+
python -m cortexnet --smoke-test
|
|
77
|
+
```
|
|
78
|
+
|
|
61
79
|
## Quick Start
|
|
62
80
|
|
|
63
81
|
```python
|
|
@@ -105,10 +123,25 @@ python -m pytest -q
|
|
|
105
123
|
|
|
106
124
|
## Docs
|
|
107
125
|
|
|
126
|
+
- 文档中心(中英文完整文档):`docs/README.md`
|
|
108
127
|
- 架构说明:`ARCHITECTURE.md`
|
|
109
128
|
- 模块职责图:`MODULE_MAP.md`
|
|
129
|
+
- 变更记录:`CHANGELOG.md`
|
|
130
|
+
- 贡献指南:`CONTRIBUTING.md`
|
|
131
|
+
- 支持与问题分流:`SUPPORT.md`
|
|
132
|
+
- 安全策略:`SECURITY.md`
|
|
133
|
+
- 示例代码:`examples/README.md`
|
|
110
134
|
|
|
111
135
|
## Compatibility Notes
|
|
112
136
|
|
|
113
137
|
- 对外推荐只使用 `CortexNet`。
|
|
114
138
|
- 历史命名(如 `CortexNetV2` / `CortexNetV3`)仍保留为兼容别名,避免旧代码立即失效。
|
|
139
|
+
|
|
140
|
+
## Development Commands
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
make install-dev
|
|
144
|
+
make lint
|
|
145
|
+
make test-all
|
|
146
|
+
make check
|
|
147
|
+
```
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# CortexNet
|
|
2
2
|
|
|
3
|
+
[](https://github.com/chaojixiaokeai/CortexNet/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/cortexnet/)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
3
7
|
`CortexNet` 是一个面向语言建模与推理场景的神经网络架构实现,核心思路是将多尺度状态空间建模、选择性稀疏注意力、记忆系统、条件路由与可选高级推理模块组合到同一框架中。
|
|
4
8
|
|
|
5
9
|
本仓库已经完成以下整理:
|
|
@@ -24,6 +28,13 @@ python -m build
|
|
|
24
28
|
pip install dist/*.whl
|
|
25
29
|
```
|
|
26
30
|
|
|
31
|
+
## CLI
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
python -m cortexnet --version
|
|
35
|
+
python -m cortexnet --smoke-test
|
|
36
|
+
```
|
|
37
|
+
|
|
27
38
|
## Quick Start
|
|
28
39
|
|
|
29
40
|
```python
|
|
@@ -71,10 +82,25 @@ python -m pytest -q
|
|
|
71
82
|
|
|
72
83
|
## Docs
|
|
73
84
|
|
|
85
|
+
- 文档中心(中英文完整文档):`docs/README.md`
|
|
74
86
|
- 架构说明:`ARCHITECTURE.md`
|
|
75
87
|
- 模块职责图:`MODULE_MAP.md`
|
|
88
|
+
- 变更记录:`CHANGELOG.md`
|
|
89
|
+
- 贡献指南:`CONTRIBUTING.md`
|
|
90
|
+
- 支持与问题分流:`SUPPORT.md`
|
|
91
|
+
- 安全策略:`SECURITY.md`
|
|
92
|
+
- 示例代码:`examples/README.md`
|
|
76
93
|
|
|
77
94
|
## Compatibility Notes
|
|
78
95
|
|
|
79
96
|
- 对外推荐只使用 `CortexNet`。
|
|
80
97
|
- 历史命名(如 `CortexNetV2` / `CortexNetV3`)仍保留为兼容别名,避免旧代码立即失效。
|
|
98
|
+
|
|
99
|
+
## Development Commands
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
make install-dev
|
|
103
|
+
make lint
|
|
104
|
+
make test-all
|
|
105
|
+
make check
|
|
106
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""CortexNet CLI entrypoint."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
|
|
7
|
+
import torch
|
|
8
|
+
|
|
9
|
+
from . import __version__, CortexNet, CortexNetConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _run_smoke_test() -> None:
|
|
13
|
+
cfg = CortexNetConfig(vocab_size=128, hidden_size=64, num_layers=1, num_heads=2, lite=False)
|
|
14
|
+
model = CortexNet(cfg).eval()
|
|
15
|
+
input_ids = torch.randint(0, cfg.vocab_size, (1, 8))
|
|
16
|
+
with torch.no_grad():
|
|
17
|
+
out = model(input_ids)
|
|
18
|
+
print(f"smoke_ok logits_shape={tuple(out['logits'].shape)}")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
22
|
+
parser = argparse.ArgumentParser(description="CortexNet CLI")
|
|
23
|
+
parser.add_argument("--version", action="store_true", help="Print installed CortexNet version")
|
|
24
|
+
parser.add_argument("--smoke-test", action="store_true", help="Run a minimal forward-pass smoke test")
|
|
25
|
+
return parser
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def main() -> int:
|
|
29
|
+
parser = build_parser()
|
|
30
|
+
args = parser.parse_args()
|
|
31
|
+
|
|
32
|
+
if args.version:
|
|
33
|
+
print(__version__)
|
|
34
|
+
return 0
|
|
35
|
+
|
|
36
|
+
if args.smoke_test:
|
|
37
|
+
_run_smoke_test()
|
|
38
|
+
return 0
|
|
39
|
+
|
|
40
|
+
parser.print_help()
|
|
41
|
+
return 0
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
45
|
+
raise SystemExit(main())
|
|
@@ -12,19 +12,22 @@ CortexNet 兼容模式组件 (Compatibility Mode Components)
|
|
|
12
12
|
这些组件在 compatibility_mode=True 时替代完整 V3 模块使用。
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import Optional, Tuple
|
|
18
|
+
|
|
15
19
|
import torch
|
|
16
20
|
import torch.nn as nn
|
|
17
21
|
import torch.nn.functional as F
|
|
18
|
-
from typing import Optional, Tuple
|
|
19
22
|
|
|
20
23
|
try:
|
|
21
|
-
from .config import CortexNetConfig
|
|
22
|
-
from .blocks import RMSNorm
|
|
23
24
|
from .attention import precompute_rope_freqs, apply_rope, apply_rope_with_positions
|
|
25
|
+
from .blocks import RMSNorm
|
|
26
|
+
from .config import CortexNetConfig
|
|
24
27
|
except ImportError:
|
|
25
|
-
from cortexnet.config import CortexNetConfig
|
|
26
|
-
from cortexnet.blocks import RMSNorm
|
|
27
28
|
from cortexnet.attention import precompute_rope_freqs, apply_rope, apply_rope_with_positions
|
|
29
|
+
from cortexnet.blocks import RMSNorm
|
|
30
|
+
from cortexnet.config import CortexNetConfig
|
|
28
31
|
|
|
29
32
|
|
|
30
33
|
class _NoOpEvolutionEngine(nn.Module):
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cortexnet
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.3
|
|
4
4
|
Summary: CortexNet: unified neural network architecture beyond Transformers
|
|
5
5
|
Author: CortexNet Team
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/chaojixiaokeai/CortexNet
|
|
8
|
+
Project-URL: Repository, https://github.com/chaojixiaokeai/CortexNet
|
|
9
|
+
Project-URL: Issues, https://github.com/chaojixiaokeai/CortexNet/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/chaojixiaokeai/CortexNet/blob/main/CHANGELOG.md
|
|
7
11
|
Keywords: deep-learning,llm,state-space-model,sparse-attention,pytorch
|
|
8
12
|
Classifier: Development Status :: 4 - Beta
|
|
9
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -28,12 +32,19 @@ Provides-Extra: dev
|
|
|
28
32
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
33
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
30
34
|
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pyflakes>=3.2.0; extra == "dev"
|
|
36
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
31
38
|
Provides-Extra: distributed
|
|
32
39
|
Requires-Dist: deepspeed>=0.10.0; extra == "distributed"
|
|
33
40
|
Dynamic: license-file
|
|
34
41
|
|
|
35
42
|
# CortexNet
|
|
36
43
|
|
|
44
|
+
[](https://github.com/chaojixiaokeai/CortexNet/actions/workflows/ci.yml)
|
|
45
|
+
[](https://pypi.org/project/cortexnet/)
|
|
46
|
+
[](./LICENSE)
|
|
47
|
+
|
|
37
48
|
`CortexNet` 是一个面向语言建模与推理场景的神经网络架构实现,核心思路是将多尺度状态空间建模、选择性稀疏注意力、记忆系统、条件路由与可选高级推理模块组合到同一框架中。
|
|
38
49
|
|
|
39
50
|
本仓库已经完成以下整理:
|
|
@@ -58,6 +69,13 @@ python -m build
|
|
|
58
69
|
pip install dist/*.whl
|
|
59
70
|
```
|
|
60
71
|
|
|
72
|
+
## CLI
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
python -m cortexnet --version
|
|
76
|
+
python -m cortexnet --smoke-test
|
|
77
|
+
```
|
|
78
|
+
|
|
61
79
|
## Quick Start
|
|
62
80
|
|
|
63
81
|
```python
|
|
@@ -105,10 +123,25 @@ python -m pytest -q
|
|
|
105
123
|
|
|
106
124
|
## Docs
|
|
107
125
|
|
|
126
|
+
- 文档中心(中英文完整文档):`docs/README.md`
|
|
108
127
|
- 架构说明:`ARCHITECTURE.md`
|
|
109
128
|
- 模块职责图:`MODULE_MAP.md`
|
|
129
|
+
- 变更记录:`CHANGELOG.md`
|
|
130
|
+
- 贡献指南:`CONTRIBUTING.md`
|
|
131
|
+
- 支持与问题分流:`SUPPORT.md`
|
|
132
|
+
- 安全策略:`SECURITY.md`
|
|
133
|
+
- 示例代码:`examples/README.md`
|
|
110
134
|
|
|
111
135
|
## Compatibility Notes
|
|
112
136
|
|
|
113
137
|
- 对外推荐只使用 `CortexNet`。
|
|
114
138
|
- 历史命名(如 `CortexNetV2` / `CortexNetV3`)仍保留为兼容别名,避免旧代码立即失效。
|
|
139
|
+
|
|
140
|
+
## Development Commands
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
make install-dev
|
|
144
|
+
make lint
|
|
145
|
+
make test-all
|
|
146
|
+
make check
|
|
147
|
+
```
|
|
@@ -2,6 +2,7 @@ LICENSE
|
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
4
|
cortexnet/__init__.py
|
|
5
|
+
cortexnet/__main__.py
|
|
5
6
|
cortexnet/adversarial.py
|
|
6
7
|
cortexnet/attention.py
|
|
7
8
|
cortexnet/blocks.py
|
|
@@ -29,6 +30,7 @@ cortexnet/transformer_baseline.py
|
|
|
29
30
|
cortexnet.egg-info/PKG-INFO
|
|
30
31
|
cortexnet.egg-info/SOURCES.txt
|
|
31
32
|
cortexnet.egg-info/dependency_links.txt
|
|
33
|
+
cortexnet.egg-info/entry_points.txt
|
|
32
34
|
cortexnet.egg-info/requires.txt
|
|
33
35
|
cortexnet.egg-info/top_level.txt
|
|
34
36
|
cortexnet/adapter/__init__.py
|
|
@@ -41,4 +43,5 @@ cortexnet/ops/__init__.py
|
|
|
41
43
|
cortexnet/ops/device_manager.py
|
|
42
44
|
cortexnet/ops/npu_ops.py
|
|
43
45
|
tests/test_all.py
|
|
44
|
-
tests/test_core_modules.py
|
|
46
|
+
tests/test_core_modules.py
|
|
47
|
+
tests/test_public_api.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cortexnet"
|
|
7
|
-
version = "3.2.
|
|
7
|
+
version = "3.2.3"
|
|
8
8
|
description = "CortexNet: unified neural network architecture beyond Transformers"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -13,6 +13,7 @@ authors = [
|
|
|
13
13
|
{name = "CortexNet Team"},
|
|
14
14
|
]
|
|
15
15
|
keywords = ["deep-learning", "llm", "state-space-model", "sparse-attention", "pytorch"]
|
|
16
|
+
urls = {Homepage = "https://github.com/chaojixiaokeai/CortexNet", Repository = "https://github.com/chaojixiaokeai/CortexNet", Issues = "https://github.com/chaojixiaokeai/CortexNet/issues", Changelog = "https://github.com/chaojixiaokeai/CortexNet/blob/main/CHANGELOG.md"}
|
|
16
17
|
classifiers = [
|
|
17
18
|
"Development Status :: 4 - Beta",
|
|
18
19
|
"Intended Audience :: Science/Research",
|
|
@@ -39,11 +40,17 @@ dev = [
|
|
|
39
40
|
"pytest>=7.0",
|
|
40
41
|
"pytest-cov>=4.0",
|
|
41
42
|
"ruff>=0.1.0",
|
|
43
|
+
"pyflakes>=3.2.0",
|
|
44
|
+
"build>=1.0.0",
|
|
45
|
+
"twine>=5.0.0",
|
|
42
46
|
]
|
|
43
47
|
distributed = [
|
|
44
48
|
"deepspeed>=0.10.0",
|
|
45
49
|
]
|
|
46
50
|
|
|
51
|
+
[project.scripts]
|
|
52
|
+
cortexnet = "cortexnet.__main__:main"
|
|
53
|
+
|
|
47
54
|
[tool.setuptools.packages.find]
|
|
48
55
|
include = ["cortexnet*"]
|
|
49
56
|
exclude = ["tests*", "scripts*"]
|
|
@@ -59,4 +66,4 @@ line-length = 120
|
|
|
59
66
|
|
|
60
67
|
[tool.ruff.lint]
|
|
61
68
|
select = ["E", "F", "W", "I"]
|
|
62
|
-
ignore = ["E501"]
|
|
69
|
+
ignore = ["E402", "E501", "I001", "W293"]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Public API contract tests for CortexNet."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
import torch
|
|
9
|
+
|
|
10
|
+
import cortexnet
|
|
11
|
+
from cortexnet import CortexNet, CortexNetConfig
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_public_api_version() -> None:
|
|
15
|
+
assert isinstance(cortexnet.__version__, str)
|
|
16
|
+
assert cortexnet.__version__
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_canonical_model_name_and_aliases() -> None:
|
|
20
|
+
cfg = CortexNetConfig(vocab_size=128, hidden_size=64, num_layers=1, num_heads=2, lite=False)
|
|
21
|
+
|
|
22
|
+
model = CortexNet(cfg)
|
|
23
|
+
model_v3 = cortexnet.CortexNetV3(cfg)
|
|
24
|
+
|
|
25
|
+
assert model.__class__.__name__ == "CortexNet"
|
|
26
|
+
assert isinstance(model, cortexnet.CortexNetV3)
|
|
27
|
+
assert isinstance(model_v3, cortexnet.CortexNetV3)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_forward_smoke_shape() -> None:
|
|
31
|
+
cfg = CortexNetConfig(vocab_size=128, hidden_size=64, num_layers=1, num_heads=2, lite=False)
|
|
32
|
+
model = CortexNet(cfg).eval()
|
|
33
|
+
|
|
34
|
+
input_ids = torch.randint(0, cfg.vocab_size, (2, 6))
|
|
35
|
+
with torch.no_grad():
|
|
36
|
+
out = model(input_ids)
|
|
37
|
+
|
|
38
|
+
assert "logits" in out
|
|
39
|
+
assert out["logits"].shape == (2, 6, cfg.vocab_size)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_module_cli_version() -> None:
|
|
43
|
+
result = subprocess.run(
|
|
44
|
+
[sys.executable, "-m", "cortexnet", "--version"],
|
|
45
|
+
capture_output=True,
|
|
46
|
+
text=True,
|
|
47
|
+
check=True,
|
|
48
|
+
)
|
|
49
|
+
assert cortexnet.__version__ in result.stdout.strip()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|