isagellm-core 0.2.2.6__py2.py3-none-any.whl

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 (44) hide show
  1. isagellm_core-0.2.2.6.dist-info/METADATA +340 -0
  2. isagellm_core-0.2.2.6.dist-info/RECORD +44 -0
  3. isagellm_core-0.2.2.6.dist-info/WHEEL +6 -0
  4. isagellm_core-0.2.2.6.dist-info/entry_points.txt +3 -0
  5. isagellm_core-0.2.2.6.dist-info/top_level.txt +1 -0
  6. sagellm_core/__init__.py +114 -0
  7. sagellm_core/__init__.pyc +0 -0
  8. sagellm_core/__main__.pyc +0 -0
  9. sagellm_core/__pycache__/__init__.cpython-311.pyc +0 -0
  10. sagellm_core/__pycache__/base_engine.cpython-311.pyc +0 -0
  11. sagellm_core/__pycache__/config.cpython-311.pyc +0 -0
  12. sagellm_core/__pycache__/demo.cpython-311.pyc +0 -0
  13. sagellm_core/__pycache__/engine.cpython-311.pyc +0 -0
  14. sagellm_core/__pycache__/engine_factory.cpython-311.pyc +0 -0
  15. sagellm_core/__pycache__/factory.cpython-311.pyc +0 -0
  16. sagellm_core/__pycache__/health.cpython-311.pyc +0 -0
  17. sagellm_core/__pycache__/mock_engine.cpython-311.pyc +0 -0
  18. sagellm_core/__pycache__/plugins.cpython-311.pyc +0 -0
  19. sagellm_core/__pycache__/runner.cpython-311.pyc +0 -0
  20. sagellm_core/__pycache__/workload.cpython-311.pyc +0 -0
  21. sagellm_core/config.pyc +0 -0
  22. sagellm_core/demo.pyc +0 -0
  23. sagellm_core/engine.pyc +0 -0
  24. sagellm_core/engine_factory.pyc +0 -0
  25. sagellm_core/engines/__init__.py +33 -0
  26. sagellm_core/engines/__init__.pyc +0 -0
  27. sagellm_core/engines/__pycache__/__init__.cpython-311.pyc +0 -0
  28. sagellm_core/engines/__pycache__/cpu.cpython-311.pyc +0 -0
  29. sagellm_core/engines/__pycache__/embedding.cpython-311.pyc +0 -0
  30. sagellm_core/engines/__pycache__/hf_cuda.cpython-311.pyc +0 -0
  31. sagellm_core/engines/__pycache__/mock.cpython-311.pyc +0 -0
  32. sagellm_core/engines/__pycache__/pytorch.cpython-311.pyc +0 -0
  33. sagellm_core/engines/__pycache__/pytorch_engine.cpython-311.pyc +0 -0
  34. sagellm_core/engines/cpu.pyc +0 -0
  35. sagellm_core/engines/embedding.pyc +0 -0
  36. sagellm_core/engines/hf_cuda.pyc +0 -0
  37. sagellm_core/engines/pytorch.pyc +0 -0
  38. sagellm_core/engines/pytorch_engine.pyc +0 -0
  39. sagellm_core/factory.pyc +0 -0
  40. sagellm_core/health.pyc +0 -0
  41. sagellm_core/plugins.pyc +0 -0
  42. sagellm_core/py.typed +2 -0
  43. sagellm_core/runner.pyc +0 -0
  44. sagellm_core/workload.pyc +0 -0
@@ -0,0 +1,340 @@
1
+ Metadata-Version: 2.4
2
+ Name: isagellm-core
3
+ Version: 0.2.2.6
4
+ Summary: sageLLM core runtime (config/observability/registries), plugin-ready
5
+ Author: IntelliStream Team
6
+ License: Proprietary - IntelliStream
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Python: ==3.11.*
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: pydantic>=2.0.0
15
+ Requires-Dist: pyyaml>=6.0.0
16
+ Requires-Dist: isagellm-protocol<0.2.0,>=0.1.0
17
+ Requires-Dist: isagellm-backend<0.3.0,>=0.2.0.0
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
20
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
21
+ Requires-Dist: pytest-timeout>=2.0.0; extra == "dev"
22
+ Requires-Dist: ruff>=0.8.0; extra == "dev"
23
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
24
+ Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
25
+ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
26
+
27
+ # sagellm-core
28
+
29
+ ## Protocol Compliance (Mandatory)
30
+
31
+ - MUST follow Protocol v0.1: https://github.com/intellistream/sagellm-docs/blob/main/docs/specs/protocol_v0.1.md
32
+ - Any globally shared definitions (fields, error codes, metrics, IDs, schemas) MUST be added to Protocol first.
33
+
34
+ [![CI](https://github.com/intellistream/sagellm-core/actions/workflows/ci.yml/badge.svg)](https://github.com/intellistream/sagellm-core/actions/workflows/ci.yml)
35
+ [![PyPI](https://img.shields.io/pypi/v/isagellm-core.svg)](https://pypi.org/project/isagellm-core/)
36
+ [![Python](https://img.shields.io/pypi/pyversions/isagellm-core.svg)](https://pypi.org/project/isagellm-core/)
37
+ [![License](https://img.shields.io/github/license/intellistream/sagellm-core.svg)](https://github.com/intellistream/sagellm-core/blob/main/LICENSE)
38
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
39
+
40
+ sageLLM Core - 引擎协调层与运行时系统
41
+
42
+ ## 架构定位
43
+
44
+ ```
45
+ ┌─────────────────────────────────────────────────────────────┐
46
+ │ sagellm-core (引擎协调层) ← 本仓库 │
47
+ │ ┌─────────────────────────────────────────────────────┐ │
48
+ │ │ Engine Abstraction (BaseEngine, EngineFactory) │ │
49
+ │ │ • CPUEngine, HFCudaEngine │ │
50
+ │ │ • 自描述架构 (is_available, priority) │ │
51
+ │ │ • 引擎自动发现与注册 │ │
52
+ │ └─────────────────────────────────────────────────────┘ │
53
+ │ ┌─────────────────────────────────────────────────────┐ │
54
+ │ │ Configuration System (config.py) │ │
55
+ │ │ • YAML/JSON 配置解析 │ │
56
+ │ │ • Pydantic v2 类型验证 │ │
57
+ │ └─────────────────────────────────────────────────────┘ │
58
+ │ ┌─────────────────────────────────────────────────────┐ │
59
+ │ │ Demo Runner (runner.py) │ │
60
+ │ │ • 协调 backend + engine + workload │ │
61
+ │ │ • M1 Demo Contract 验证 │ │
62
+ │ └─────────────────────────────────────────────────────┘ │
63
+ ├─────────────────────────────────────────────────────────────┤
64
+ │ sagellm-backend (硬件抽象层) │
65
+ │ • BackendProvider (CPU/CUDA/Ascend) │
66
+ │ • Stream/Event/KVBlock 管理 │
67
+ └─────────────────────────────────────────────────────────────┘
68
+ ```
69
+
70
+ **职责分离**:
71
+ - ❌ **Backend 不再包含**:BaseEngine, EngineFactory(已移至 core)
72
+ - ✅ **Core 负责**:引擎接口、工厂、运行时、配置、协调
73
+ - ✅ **Backend 负责**:硬件抽象、设备管理、内存原语
74
+
75
+ ## Features
76
+
77
+ - 🔧 引擎抽象层与自描述架构
78
+ - 🏭 EngineFactory - 支持自动发现与优先级选择
79
+ - 🎯 内置引擎实现(CPU/CUDA/Embedding)
80
+ - 🔌 插件系统 - 扩展引擎与后端
81
+ - 📊 Demo Runner - M1 验证框架
82
+ - ⚙️ 配置系统 - YAML/JSON + Pydantic v2
83
+ - ✅ CPU-First - 无 GPU 测试支持
84
+
85
+ ## 安装
86
+
87
+ ```bash
88
+ # 从 PyPI 安装(自动安装 protocol + backend 依赖)
89
+ pip install isagellm-core
90
+ ```
91
+
92
+ ## 🚀 开发者快速开始
93
+
94
+ ```bash
95
+ git clone git@github.com:intellistream/sagellm-core.git
96
+ cd sagellm-core
97
+ ./quickstart.sh # 一键安装开发环境(含依赖)
98
+
99
+ # 或手动安装
100
+ pip install -e ".[dev]"
101
+ ```
102
+
103
+ 运行测试:
104
+ ```bash
105
+ pytest tests/ -v
106
+ ```
107
+
108
+ 运行 Demo(CPU 模式):
109
+ ```bash
110
+ python -m sagellm_core.demo --segments short
111
+ ```
112
+
113
+ > 💡 **提示**:`isagellm-protocol` 和 `isagellm-backend` 会自动从 PyPI 安装。
114
+ > 如需本地联调:
115
+ > ```bash
116
+ > pip install -e ../sagellm-protocol
117
+ > pip install -e ../sagellm-backend
118
+ > ```
119
+
120
+ ## Configuration System
121
+
122
+ ### 使用方法
123
+
124
+ ```python
125
+ from sagellm_core import load_config, create_backend, create_engine
126
+
127
+ # 从 YAML/JSON 加载配置
128
+ config = load_config("config.yaml")
129
+
130
+ # 创建 backend 和 engine(通过插件发现)
131
+ backend = create_backend(config.backend)
132
+ engine = create_engine(config.engine, backend)
133
+ ```
134
+
135
+ ### Configuration Structure
136
+
137
+ Main configuration components:
138
+ - `BackendConfig`: Device and backend settings
139
+ - `EngineConfig`: Inference engine configuration
140
+ - `WorkloadConfig`: Workload parameters
141
+ - `OutputConfig`: Output paths and logging
142
+ - `DemoConfig`: Top-level demo configuration
143
+
144
+ ### 配置示例
145
+
146
+ #### 快速开始
147
+
148
+ ```bash
149
+ # CPU 模式(无需 GPU)
150
+ python -m sagellm.demo --config examples/config_cpu.yaml
151
+
152
+ # CUDA 生产模式
153
+ python -m sagellm.demo --config examples/config_cuda.yaml
154
+
155
+ # 昇腾生产模式
156
+ python -m sagellm.demo --config examples/config_ascend.yaml
157
+ ```
158
+
159
+ #### 示例配置文件
160
+
161
+ - [config_cpu.yaml](examples/config_cpu.yaml) - CPU 模式(CI/开发)
162
+ - [config_cuda.yaml](examples/config_cuda.yaml) - CUDA 生产模式
163
+ - [config_ascend.yaml](examples/config_ascend.yaml) - 昇腾生产模式
164
+ - [config_minimal.json](examples/config_minimal.json) - 最小 JSON 配置
165
+
166
+ 更多信息参见 [examples/README.md](examples/README.md)
167
+
168
+ ### 配置格式
169
+
170
+ 支持 YAML(推荐)和 JSON 格式:
171
+
172
+ ```yaml
173
+ backend:
174
+ kind: cpu
175
+ engine:
176
+ kind: cpu
177
+ model: sshleifer/tiny-gpt2
178
+ workload:
179
+ segments: [short, long, stress]
180
+ concurrency: 4
181
+ output:
182
+ metrics_path: ./metrics.json
183
+ ```
184
+
185
+ ### 插件解析
186
+
187
+ 当配置指定的 backend/engine kind 未安装时,会抛出 `PluginResolutionError`:
188
+
189
+ ```python
190
+ from sagellm_core import create_backend, BackendConfig, PluginResolutionError
191
+
192
+ try:
193
+ backend = create_backend(BackendConfig(kind="ascend_cann", device="npu:0"))
194
+ except PluginResolutionError as e:
195
+ print(f"错误: {e}")
196
+ # 输出: No implementation found for sagellm.backends kind='ascend_cann'.
197
+ # Install hint: pip install isagellm-backend-ascend_cann
198
+ ```
199
+
200
+ ## Demo Runner CLI (Task0.08)
201
+
202
+ sagellm-core 提供了 Demo Runner CLI,用于执行 M1 Demo Contract 验证:
203
+
204
+ ### 用法
205
+
206
+ ```bash
207
+ # 使用配置文件运行
208
+ python -m sagellm_core.demo --config examples/demo_config.yaml
209
+
210
+ # 强制使用 CPU 模式(覆盖配置文件)
211
+ python -m sagellm_core.demo --config config.yaml --backend cpu
212
+
213
+ # 覆盖 workload 段选择
214
+ python -m sagellm_core.demo --config config.yaml --segments short,long
215
+
216
+ # 覆盖输出路径
217
+ python -m sagellm_core.demo --config config.yaml --output /tmp/metrics.json
218
+
219
+ # 启用 streaming 模式和详细日志
220
+ python -m sagellm_core.demo --config config.yaml --stream --verbose
221
+ ```
222
+
223
+ ### 示例配置
224
+
225
+ 参见 [examples/demo_config.yaml](examples/demo_config.yaml):
226
+
227
+ ```yaml
228
+ backend:
229
+ kind: cpu
230
+ device: cpu
231
+
232
+ engine:
233
+ kind: cpu
234
+ model: sshleifer/tiny-gpt2
235
+
236
+ workload:
237
+ segments: [short, long, stress]
238
+ concurrency: 4
239
+ kv_budget_tokens: 8192
240
+
241
+ output:
242
+ metrics_path: ./output/metrics.json
243
+ report_path: ./output/report.md
244
+ ```
245
+
246
+ ## Development Guide
247
+
248
+ ### 快速开始
249
+
250
+ ```bash
251
+ # 克隆仓库
252
+ git clone https://github.com/intellistream/sagellm-core.git
253
+ cd sagellm-core
254
+
255
+ # 安装开发依赖
256
+ pip install -e ".[dev]"
257
+
258
+ # 安装 pre-commit hooks
259
+ pre-commit install
260
+
261
+ # 验证环境
262
+ pytest tests/ -v
263
+ ```
264
+
265
+ ### Testing and Quality
266
+
267
+ #### Pre-commit Hooks
268
+
269
+ 安装后,每次 `git commit` 会自动运行:
270
+ - **Ruff**: 代码格式化 + Lint 检查
271
+ - **Mypy**: 静态类型检查
272
+ - **YAML/JSON**: 配置文件验证
273
+
274
+ ```bash
275
+ # 手动运行所有 hooks
276
+ pre-commit run --all-files
277
+
278
+ # 绕过 hooks(紧急情况)
279
+ git commit --no-verify
280
+ ```
281
+
282
+ #### Running Tests
283
+
284
+ ```bash
285
+ # Run all tests
286
+ pytest tests/ -v
287
+
288
+ # Run specific test module
289
+ pytest tests/unit/test_demo.py -v
290
+
291
+ # Generate coverage report
292
+ pytest tests/ --cov=sagellm_core --cov-report=html
293
+ ```
294
+
295
+ #### Continuous Integration
296
+
297
+ GitHub Actions automatically runs on each PR:
298
+ - Code linting and formatting checks
299
+ - Tests across Python 3.10, 3.11, 3.12
300
+ - Package build verification
301
+
302
+ ### Code Style
303
+
304
+ This project uses:
305
+ - **Ruff** for formatting and linting
306
+ - **Mypy** for type checking
307
+ - **Type hints** are required for all functions
308
+
309
+ For detailed guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md)
310
+
311
+ ### 代码检查
312
+
313
+ ```bash
314
+ # 格式化代码
315
+ ruff format .
316
+
317
+ # Lint 检查
318
+ ruff check .
319
+
320
+ # 类型检查
321
+ mypy src/sagellm_core
322
+
323
+ # 一键检查所有
324
+ pre-commit run --all-files
325
+ ```
326
+
327
+ ## 依赖
328
+
329
+ - `pydantic>=2.0.0`: 配置校验
330
+ - `pyyaml>=6.0.0`: YAML 配置支持
331
+ - `isagellm-protocol>=0.1.0,<0.2.0`: 协议定义(Level 0)
332
+ - `isagellm-backend>=0.1.0,<0.2.0`: 后端抽象(Level 1)
333
+
334
+ ## Related Packages
335
+
336
+ - `isagellm-protocol` - Protocol definitions
337
+ - `isagellm-backend` - Backend abstraction layer
338
+ - `isagellm` - Main package with CLI
339
+
340
+ For more packages, see the [sageLLM ecosystem](https://github.com/intellistream/sagellm)
@@ -0,0 +1,44 @@
1
+ sagellm_core/__init__.py,sha256=gduyaxWfhS2iepRxovlk11u2nlseqxxs8jVOkkMd-Qw,2798
2
+ sagellm_core/__init__.pyc,sha256=j_6Q0GNFJX4705JJ8g5P66TYAgHF4FLbZ6npPxL6-08,2758
3
+ sagellm_core/__main__.pyc,sha256=48Ej1ycqV-z87qawGOTNBKNgY3EcbffUOOXrDecOR3g,384
4
+ sagellm_core/config.pyc,sha256=cCMLvMVb_s3HzPYSfqlbRWodQ4Uby8U962l1vmunT5Y,8453
5
+ sagellm_core/demo.pyc,sha256=0hZkAJch6ETjSDsPq8XkDLNcd8qAys_hqOH1qi0xBzg,6028
6
+ sagellm_core/engine.pyc,sha256=VJMpwWH8Dlem1Q54MlQrGNEs54TTFYpNu6KoJkkgFwY,9748
7
+ sagellm_core/engine_factory.pyc,sha256=cNbEImM0MNcCgVeC0zViAT1AZkPAt2WARrVd1U__tS4,14886
8
+ sagellm_core/factory.pyc,sha256=B0s_JSOjVPwE95Oj2moP_vVA3vCrWsi2753UrwF8-eM,2737
9
+ sagellm_core/health.pyc,sha256=c4A60b1ZANbAqck59AV-kczK2b355EPi9JxoYHRlhl8,684
10
+ sagellm_core/plugins.pyc,sha256=g6eke_yH65_7Bu6yfT7v19cZ7gjIAWbkyG7gv1JSXy0,2617
11
+ sagellm_core/py.typed,sha256=ixa8YukDZ3kLo0WsFJRGohLMyHzbMur1ALmmASML2cs,64
12
+ sagellm_core/runner.pyc,sha256=GK_t15IH2etN6flRqUui4iUPkD39zl3_rw1wnOSG5Jg,14238
13
+ sagellm_core/workload.pyc,sha256=G9yMm2L4ZyZpGsCxuEOQ83t78Y_lCQmbg5p6OHl5rn0,4127
14
+ sagellm_core/__pycache__/__init__.cpython-311.pyc,sha256=gm2FQIQMHojIxuM5DWyupCubtTsxXzjQLfMwyrwtVEk,2788
15
+ sagellm_core/__pycache__/base_engine.cpython-311.pyc,sha256=XiynMTxG3srYsUwzIoEbwEJOmpjBBB6UNEoAXDxDgWM,9563
16
+ sagellm_core/__pycache__/config.cpython-311.pyc,sha256=6gUdzUs3m31zGQVa2OzlPcPbX1it2Ziag0cQbCaXvIU,8483
17
+ sagellm_core/__pycache__/demo.cpython-311.pyc,sha256=PN6yZ3PgPWjiZ4XqpqRT-s5YYWitMwR_muYFvPmXdWA,6058
18
+ sagellm_core/__pycache__/engine.cpython-311.pyc,sha256=sEEWFk9NHq8l9Q8NKvSQbomRJx2vMdjvtVUiGKx62jM,9778
19
+ sagellm_core/__pycache__/engine_factory.cpython-311.pyc,sha256=Qte3LXKSpcOWGhu-Hns7xPvTdkyYry3v_EeYQbfVp4w,14916
20
+ sagellm_core/__pycache__/factory.cpython-311.pyc,sha256=R4MbGyreD3U2iWmwQ0r14R347GAY9RM_I1xOiWovozo,2767
21
+ sagellm_core/__pycache__/health.cpython-311.pyc,sha256=Z2mo-4iGINZp0w9AmCJomhHGRSzvbwxCfmdMAjg5vc4,714
22
+ sagellm_core/__pycache__/mock_engine.cpython-311.pyc,sha256=zCHNncwIzEgqZ0lc7kiWkS-zOHf7CQ73UhCXztR6mFM,581
23
+ sagellm_core/__pycache__/plugins.cpython-311.pyc,sha256=gaoaHApylGSrmMxXVwFs2v4idiZJnisttawlXTbXBWY,2647
24
+ sagellm_core/__pycache__/runner.cpython-311.pyc,sha256=krW5MagsiQcX5J9fljblEshfsQB_gAIAWR7S0uD-TzU,14268
25
+ sagellm_core/__pycache__/workload.cpython-311.pyc,sha256=Y01UUCDE85D8GY5kF_UsHyNCBbMkmsoB3vOUJV-vulA,4157
26
+ sagellm_core/engines/__init__.py,sha256=9XyjgaAl6nR3uMSx4EzBQqQ1wE7jQfpR_k69083EZOY,1068
27
+ sagellm_core/engines/__init__.pyc,sha256=2Sh_n2W0ZidghYCT7t0N0RfPZhqVjfhWWEdohNyBBNw,1118
28
+ sagellm_core/engines/cpu.pyc,sha256=_PPwKyYmhSRNg7SjRJ3m5jOmjBV9qjVAvono3502lFI,20109
29
+ sagellm_core/engines/embedding.pyc,sha256=Be4To-qpamFuGcyFZ1MKPk6XOf_HDBKnBGoIisxNemE,11476
30
+ sagellm_core/engines/hf_cuda.pyc,sha256=HTOtHVyX6dbysMc5Lx9DeJpE6rSTG2CQcIn0xb0rcBI,50340
31
+ sagellm_core/engines/pytorch.pyc,sha256=MLcymoDnwMduWoWVDZmYuG6UoQavNO-FjddPQ8ccccI,18408
32
+ sagellm_core/engines/pytorch_engine.pyc,sha256=fdzf-VN2hVRWzP8PCmGV-pg9qUIJWWqEH662CRmh5_0,11645
33
+ sagellm_core/engines/__pycache__/__init__.cpython-311.pyc,sha256=t289gZVTllHWt7jXYL31Cs3CHNgd84Yl6FrEiywxiso,1148
34
+ sagellm_core/engines/__pycache__/cpu.cpython-311.pyc,sha256=c53zodjzFJu1s-Enyum9cj_Zi2ENr1W3xgsNG_13gHE,20139
35
+ sagellm_core/engines/__pycache__/embedding.cpython-311.pyc,sha256=ZNqFpuCsS4Wp0xg7yV3GBbaJ4G0saqGNaKMdivxEBkA,11506
36
+ sagellm_core/engines/__pycache__/hf_cuda.cpython-311.pyc,sha256=1YYE_6xLS9Gqg5O2hrg07IbaVfXhC6SBQBLH31xowJw,50370
37
+ sagellm_core/engines/__pycache__/mock.cpython-311.pyc,sha256=1g9YyKfo9yv-6VTjzzfacv-9ZICHjsVXjyJ_IajRnQo,14641
38
+ sagellm_core/engines/__pycache__/pytorch.cpython-311.pyc,sha256=MRSQN2ZBJmuIxFIA_yflaxarFhslfT0SG0Lw7-EFyDQ,18438
39
+ sagellm_core/engines/__pycache__/pytorch_engine.cpython-311.pyc,sha256=dLBcBODxEqgmH25nCBPWhwy3uu3-dqzyzOwQy-izN7A,11675
40
+ isagellm_core-0.2.2.6.dist-info/METADATA,sha256=_NR4IGCdsRHDZci0NvDFA62Vh9dLjcsbDqHaF4MME-Y,10811
41
+ isagellm_core-0.2.2.6.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
42
+ isagellm_core-0.2.2.6.dist-info/entry_points.txt,sha256=GOAxUrzSeJyOUjseRjJwhNLu8oLEMlbszb4j8xyr2QY,128
43
+ isagellm_core-0.2.2.6.dist-info/top_level.txt,sha256=wcgdWrvkaoYYh_dWSFI5Toi8PZsHutVqfhTB2tb0K6g,13
44
+ isagellm_core-0.2.2.6.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
@@ -0,0 +1,3 @@
1
+ [sagellm.engines]
2
+ cpu = sagellm_core.engines.cpu:create_cpu_engine
3
+ pytorch = sagellm_core.engines.pytorch:create_pytorch_engine
@@ -0,0 +1 @@
1
+ sagellm_core
@@ -0,0 +1,114 @@
1
+ """sageLLM Core 运行时。
2
+
3
+ 本包提供 sageLLM 的核心运行时组件:
4
+ - 配置 schema 与校验
5
+ - Engine 抽象接口与实现
6
+ - Engine 工厂函数
7
+ - 插件系统
8
+ - Demo Runner
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from sagellm_core.engine import BaseEngine, EngineInstanceConfig
14
+ from sagellm_core.config import (
15
+ BackendConfig,
16
+ DemoConfig,
17
+ EngineConfig,
18
+ OutputConfig,
19
+ WorkloadConfig,
20
+ WorkloadSegment,
21
+ load_config,
22
+ )
23
+ from sagellm_core.demo import main as demo_main
24
+ from sagellm_core.engine_factory import EngineFactory
25
+ from sagellm_core.engines import (
26
+ CPUEngine,
27
+ EmbeddingEngine,
28
+ EmbeddingEngineConfig,
29
+ HFCudaEngine,
30
+ HFCudaEngineConfig,
31
+ )
32
+ from sagellm_core.factory import create_backend, create_engine
33
+ from sagellm_core.health import HealthStatus
34
+ from sagellm_core.plugins import PluginResolutionError, list_entry_points, resolve_kind
35
+ from sagellm_core.runner import DemoRunner, RunnerContext
36
+
37
+ # PyTorch engine (optional, loaded lazily)
38
+ PyTorchEngine = None
39
+ PyTorchEngineConfig = None
40
+ PyTorchEngineInstanceConfig = None
41
+ create_pytorch_engine = None
42
+
43
+ try:
44
+ from sagellm_core.engines.pytorch import (
45
+ PyTorchEngine,
46
+ PyTorchEngineConfig,
47
+ PyTorchEngineInstanceConfig,
48
+ create_pytorch_engine,
49
+ )
50
+ except ImportError:
51
+ pass # torch or transformers not available
52
+
53
+ # Auto-register built-in engines (conditional for optional dependencies)
54
+ try:
55
+ EngineFactory.register(CPUEngine)
56
+ except Exception:
57
+ pass # torch not available
58
+
59
+ try:
60
+ EngineFactory.register(HFCudaEngine)
61
+ except Exception:
62
+ pass # torch or CUDA not available
63
+
64
+ try:
65
+ EngineFactory.register(EmbeddingEngine)
66
+ except Exception:
67
+ pass # sentence-transformers not available
68
+
69
+ try:
70
+ if PyTorchEngine is not None:
71
+ EngineFactory.register(PyTorchEngine)
72
+ except Exception:
73
+ pass # torch or transformers not available
74
+
75
+ __version__ = "0.2.2.6"
76
+
77
+ __all__ = [
78
+ # Version
79
+ "__version__",
80
+ # Configuration (for YAML/config files)
81
+ "BackendConfig",
82
+ "DemoConfig",
83
+ "EngineConfig",
84
+ "OutputConfig",
85
+ "WorkloadConfig",
86
+ "WorkloadSegment",
87
+ "load_config",
88
+ # Engine abstraction
89
+ "BaseEngine",
90
+ "EngineInstanceConfig", # For runtime engine instantiation
91
+ "HealthStatus",
92
+ # Engine implementations
93
+ "CPUEngine",
94
+ "HFCudaEngine",
95
+ "HFCudaEngineConfig",
96
+ "EmbeddingEngine",
97
+ "EmbeddingEngineConfig",
98
+ "PyTorchEngine",
99
+ "PyTorchEngineConfig",
100
+ "PyTorchEngineInstanceConfig",
101
+ "create_pytorch_engine",
102
+ # Factory functions
103
+ "create_backend",
104
+ "create_engine",
105
+ "EngineFactory",
106
+ # Plugin system
107
+ "PluginResolutionError",
108
+ "list_entry_points",
109
+ "resolve_kind",
110
+ # Demo runner
111
+ "demo_main",
112
+ "DemoRunner",
113
+ "RunnerContext",
114
+ ]
Binary file
Binary file
Binary file
sagellm_core/demo.pyc ADDED
Binary file
Binary file
Binary file
@@ -0,0 +1,33 @@
1
+ """Engine implementations for sageLLM Core.
2
+
3
+ This module provides built-in engine implementations:
4
+ - CPUEngine: CPU-only inference with HuggingFace Transformers
5
+ - HFCudaEngine: CUDA inference with HuggingFace Transformers
6
+ - PyTorchEngine: Unified PyTorch engine (auto-detects CUDA/NPU/CPU)
7
+ - EmbeddingEngine: Embedding model inference
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from sagellm_core.engines.cpu import CPUEngine
13
+ from sagellm_core.engines.embedding import EmbeddingEngine, EmbeddingEngineConfig
14
+ from sagellm_core.engines.hf_cuda import HFCudaEngine, HFCudaEngineInstanceConfig
15
+ from sagellm_core.engines.pytorch_engine import PyTorchEngine, create_pytorch_engine
16
+
17
+ # Export aliases for backward compatibility
18
+ HFCudaEngineConfig = HFCudaEngineInstanceConfig
19
+
20
+ __all__ = [
21
+ # CPU engine
22
+ "CPUEngine",
23
+ # CUDA engine
24
+ "HFCudaEngine",
25
+ "HFCudaEngineConfig",
26
+ "HFCudaEngineInstanceConfig",
27
+ # PyTorch engine (unified)
28
+ "PyTorchEngine",
29
+ "create_pytorch_engine",
30
+ # Embedding engine
31
+ "EmbeddingEngine",
32
+ "EmbeddingEngineConfig",
33
+ ]
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
sagellm_core/py.typed ADDED
@@ -0,0 +1,2 @@
1
+ # Marker file for PEP 561
2
+ # This package supports type checking
Binary file
Binary file