pyds4 1.0.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 (55) hide show
  1. pyds4-1.0.0/.clang-format +15 -0
  2. pyds4-1.0.0/.clang-tidy +23 -0
  3. pyds4-1.0.0/.github/workflows/fake-native.yml +37 -0
  4. pyds4-1.0.0/.github/workflows/release.yml +252 -0
  5. pyds4-1.0.0/.gitignore +10 -0
  6. pyds4-1.0.0/CMakeLists.txt +432 -0
  7. pyds4-1.0.0/LICENSE +21 -0
  8. pyds4-1.0.0/Makefile +245 -0
  9. pyds4-1.0.0/PKG-INFO +507 -0
  10. pyds4-1.0.0/README.md +454 -0
  11. pyds4-1.0.0/RELEASING.md +78 -0
  12. pyds4-1.0.0/examples/generate_text.py +191 -0
  13. pyds4-1.0.0/examples/generate_text_async.py +159 -0
  14. pyds4-1.0.0/pyproject.toml +169 -0
  15. pyds4-1.0.0/scripts/benchmark_generation.py +740 -0
  16. pyds4-1.0.0/scripts/bump_version.py +64 -0
  17. pyds4-1.0.0/scripts/install_release_tools.py +32 -0
  18. pyds4-1.0.0/scripts/wheel_smoke.py +194 -0
  19. pyds4-1.0.0/src/pyds4/__init__.py +92 -0
  20. pyds4-1.0.0/src/pyds4/_build_config.py.in +7 -0
  21. pyds4-1.0.0/src/pyds4/_build_config.pyi +8 -0
  22. pyds4-1.0.0/src/pyds4/_capabilities.py +114 -0
  23. pyds4-1.0.0/src/pyds4/_metadata.py +58 -0
  24. pyds4-1.0.0/src/pyds4/_metal.py +69 -0
  25. pyds4-1.0.0/src/pyds4/_native.cpp +1341 -0
  26. pyds4-1.0.0/src/pyds4/_native.pyi +5 -0
  27. pyds4-1.0.0/src/pyds4/_native_common.hpp +69 -0
  28. pyds4-1.0.0/src/pyds4/_native_tokens.hpp +43 -0
  29. pyds4-1.0.0/src/pyds4/_version.py +73 -0
  30. pyds4-1.0.0/src/pyds4/asyncio.py +864 -0
  31. pyds4-1.0.0/src/pyds4/availability.py +114 -0
  32. pyds4-1.0.0/src/pyds4/dsml.py +1036 -0
  33. pyds4-1.0.0/src/pyds4/errors.py +30 -0
  34. pyds4-1.0.0/src/pyds4/kv_cache.py +1008 -0
  35. pyds4-1.0.0/src/pyds4/native.py +1074 -0
  36. pyds4-1.0.0/src/pyds4/thinking.py +53 -0
  37. pyds4-1.0.0/src/pyds4/types.py +489 -0
  38. pyds4-1.0.0/tests/_real_ds4_profiles.py +216 -0
  39. pyds4-1.0.0/tests/fake_ds4/ds4.c +1048 -0
  40. pyds4-1.0.0/tests/fake_ds4/ds4.h +204 -0
  41. pyds4-1.0.0/tests/native/test_native_cxx.cpp +302 -0
  42. pyds4-1.0.0/tests/test_async_facade.py +2199 -0
  43. pyds4-1.0.0/tests/test_async_real_ds4_integration.py +143 -0
  44. pyds4-1.0.0/tests/test_build_configuration.py +34 -0
  45. pyds4-1.0.0/tests/test_dsml.py +962 -0
  46. pyds4-1.0.0/tests/test_engine_open_errors.py +421 -0
  47. pyds4-1.0.0/tests/test_fake_ds4_source.py +30 -0
  48. pyds4-1.0.0/tests/test_kv_cache.py +618 -0
  49. pyds4-1.0.0/tests/test_metadata.py +506 -0
  50. pyds4-1.0.0/tests/test_metal_sources.py +89 -0
  51. pyds4-1.0.0/tests/test_native_public_validation.py +383 -0
  52. pyds4-1.0.0/tests/test_native_raii.py +1286 -0
  53. pyds4-1.0.0/tests/test_public_types.py +730 -0
  54. pyds4-1.0.0/tests/test_real_ds4_integration.py +202 -0
  55. pyds4-1.0.0/tests/test_real_ds4_profiles.py +115 -0
@@ -0,0 +1,15 @@
1
+ BasedOnStyle: LLVM
2
+ Language: Cpp
3
+ Standard: c++17
4
+ ColumnLimit: 79
5
+ IndentWidth: 4
6
+ ContinuationIndentWidth: 4
7
+ TabWidth: 4
8
+ UseTab: Never
9
+ PointerAlignment: Left
10
+ ReferenceAlignment: Left
11
+ SortIncludes: CaseSensitive
12
+ AllowShortFunctionsOnASingleLine: Empty
13
+ AllowShortIfStatementsOnASingleLine: Never
14
+ AllowShortLoopsOnASingleLine: false
15
+ BreakBeforeBraces: Attach
@@ -0,0 +1,23 @@
1
+ Checks: >
2
+ -*,
3
+ bugprone-*,
4
+ clang-analyzer-*,
5
+ performance-*,
6
+ portability-*,
7
+ modernize-*,
8
+ readability-*,
9
+ -bugprone-easily-swappable-parameters,
10
+ -modernize-avoid-c-arrays,
11
+ -modernize-use-trailing-return-type,
12
+ -readability-convert-member-functions-to-static,
13
+ -readability-function-cognitive-complexity,
14
+ -readability-identifier-length,
15
+ -readability-implicit-bool-conversion,
16
+ -readability-magic-numbers,
17
+ -readability-named-parameter
18
+ HeaderFilterRegex: '^(src/pyds4|tests/native|tests/fake_ds4)/'
19
+ FormatStyle: file
20
+ WarningsAsErrors: ''
21
+ CheckOptions:
22
+ - key: readability-braces-around-statements.ShortStatementLines
23
+ value: '1'
@@ -0,0 +1,37 @@
1
+ name: fake-native
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ name: Python ${{ matrix.python-version }}
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ python-version:
15
+ - "3.11"
16
+ - "3.12"
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install fake-native test build
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ PYDS4_USE_FAKE_DS4=1 PYDS4_BACKEND=cpu python -m pip install -e '.[test]'
29
+
30
+ - name: Run tests
31
+ run: python -m pytest -q
32
+
33
+ - name: Run native C++ tests
34
+ run: make test-cpp
35
+
36
+ - name: Run native C++ sanitizer tests
37
+ run: make test-cpp-sanitizers
@@ -0,0 +1,252 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Version to release, for example 1.0.0.
8
+ required: true
9
+ type: string
10
+ cuda_arch:
11
+ description: CUDA architectures for NVIDIA wheels, passed to CMAKE_CUDA_ARCHITECTURES.
12
+ required: false
13
+ default: "90"
14
+ type: string
15
+
16
+ concurrency:
17
+ group: release-${{ github.event.inputs.version }}
18
+ cancel-in-progress: false
19
+
20
+ permissions:
21
+ contents: read
22
+
23
+ env:
24
+ DS4_SOURCE_REF: 8809b90a1e3247389d7652b565ab6772e036f1ea
25
+
26
+ jobs:
27
+ validate:
28
+ name: Validate release input
29
+ runs-on: ubuntu-latest
30
+ outputs:
31
+ version: ${{ steps.version.outputs.version }}
32
+
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+
36
+ - uses: actions/setup-python@v5
37
+ with:
38
+ python-version: "3.11"
39
+
40
+ - name: Validate version
41
+ id: version
42
+ env:
43
+ VERSION: ${{ github.event.inputs.version }}
44
+ run: |
45
+ python - <<'PY'
46
+ import os
47
+ import re
48
+ import sys
49
+ import tomllib
50
+ from pathlib import Path
51
+
52
+ version = os.environ["VERSION"]
53
+ if re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(?:(?:a|b|rc)[0-9]+)?(?:\.post[0-9]+)?(?:\.dev[0-9]+)?", version) is None:
54
+ raise SystemExit(f"Invalid version {version!r}.")
55
+
56
+ pyproject_version = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
57
+ if pyproject_version != version:
58
+ raise SystemExit(
59
+ f"pyproject.toml is at {pyproject_version}, not {version}. "
60
+ "Run `make version VERSION=...`, merge that bump, then rerun this workflow."
61
+ )
62
+ PY
63
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
64
+
65
+ sdist:
66
+ name: Build sdist
67
+ needs: validate
68
+ runs-on: ubuntu-latest
69
+
70
+ steps:
71
+ - uses: actions/checkout@v4
72
+
73
+ - uses: actions/setup-python@v5
74
+ with:
75
+ python-version: "3.11"
76
+
77
+ - name: Install release tools
78
+ run: |
79
+ python -m pip install --upgrade pip
80
+ make release-tools
81
+
82
+ - name: Build sdist
83
+ run: make release-sdist DIST_DIR=dist
84
+
85
+ - uses: actions/upload-artifact@v4
86
+ with:
87
+ name: pyds4-sdist
88
+ path: dist/*
89
+ if-no-files-found: error
90
+
91
+ macos-metal-wheels:
92
+ name: Build macOS arm64 Metal wheel / Python ${{ matrix.python-version }}
93
+ needs: validate
94
+ runs-on: macos-15
95
+ strategy:
96
+ fail-fast: false
97
+ matrix:
98
+ python-version:
99
+ - "3.11"
100
+ - "3.12"
101
+
102
+ steps:
103
+ - uses: actions/checkout@v4
104
+
105
+ - uses: actions/setup-python@v5
106
+ with:
107
+ python-version: ${{ matrix.python-version }}
108
+
109
+ - name: Install release tools
110
+ run: |
111
+ python -m pip install --upgrade pip
112
+ make release-tools
113
+
114
+ - name: Check out pinned DS4 source
115
+ run: |
116
+ git clone https://github.com/antirez/ds4.git .local/ds4
117
+ git -C .local/ds4 checkout "$DS4_SOURCE_REF"
118
+
119
+ - name: Build Metal wheel
120
+ env:
121
+ DS4_SOURCE_DIR: ${{ github.workspace }}/.local/ds4
122
+ PYDS4_BACKEND: metal
123
+ run: make release-wheel DIST_DIR=dist
124
+
125
+ - uses: actions/upload-artifact@v4
126
+ with:
127
+ name: pyds4-macos-metal-py${{ matrix.python-version }}
128
+ path: dist/*
129
+ if-no-files-found: error
130
+
131
+ linux-cuda-wheels:
132
+ name: Build Linux x86_64 CUDA wheel / Python ${{ matrix.python-version }}
133
+ needs: validate
134
+ runs-on: ubuntu-latest
135
+ container:
136
+ image: nvidia/cuda:12.6.3-devel-ubuntu24.04
137
+ strategy:
138
+ fail-fast: false
139
+ matrix:
140
+ python-version:
141
+ - "3.11"
142
+ - "3.12"
143
+
144
+ steps:
145
+ - name: Install system dependencies
146
+ run: |
147
+ apt-get update
148
+ apt-get install -y --no-install-recommends git gzip make tar
149
+ rm -rf /var/lib/apt/lists/*
150
+
151
+ - uses: actions/checkout@v4
152
+
153
+ - uses: actions/setup-python@v5
154
+ with:
155
+ python-version: ${{ matrix.python-version }}
156
+
157
+ - name: Install release tools
158
+ run: |
159
+ python -m pip install --upgrade pip
160
+ make release-tools
161
+
162
+ - name: Check out pinned DS4 source
163
+ run: |
164
+ git clone https://github.com/antirez/ds4.git .local/ds4
165
+ git -C .local/ds4 checkout "$DS4_SOURCE_REF"
166
+
167
+ - name: Build CUDA wheel
168
+ env:
169
+ DS4_SOURCE_DIR: ${{ github.workspace }}/.local/ds4
170
+ PYDS4_BACKEND: cuda
171
+ CUDA_ARCH: ${{ github.event.inputs.cuda_arch }}
172
+ run: make release-wheel DIST_DIR=dist
173
+
174
+ - name: Audit CUDA wheel
175
+ run: make audit-wheel DIST_DIR=dist
176
+
177
+ - uses: actions/upload-artifact@v4
178
+ with:
179
+ name: pyds4-linux-cuda-py${{ matrix.python-version }}
180
+ path: dist/*
181
+ if-no-files-found: error
182
+
183
+ publish:
184
+ name: Publish to PyPI
185
+ needs:
186
+ - validate
187
+ - sdist
188
+ - macos-metal-wheels
189
+ - linux-cuda-wheels
190
+ runs-on: ubuntu-latest
191
+ environment: pypi
192
+ permissions:
193
+ contents: write
194
+ id-token: write
195
+
196
+ steps:
197
+ - uses: actions/checkout@v4
198
+ with:
199
+ fetch-depth: 0
200
+
201
+ - uses: actions/setup-python@v5
202
+ with:
203
+ python-version: "3.11"
204
+
205
+ - uses: actions/download-artifact@v5
206
+ with:
207
+ path: dist
208
+ merge-multiple: true
209
+
210
+ - name: Install release tools
211
+ run: |
212
+ python -m pip install --upgrade pip
213
+ make release-tools
214
+
215
+ - name: Check distributions
216
+ run: make dist-check DIST_DIR=dist
217
+
218
+ - name: Prepare PyPI distributions
219
+ run: |
220
+ mkdir -p pypi-dist
221
+ cp dist/*.tar.gz pypi-dist/
222
+ cp dist/*macosx*.whl pypi-dist/
223
+
224
+ - name: Check PyPI distributions
225
+ run: make dist-check DIST_DIR=pypi-dist
226
+
227
+ - name: Publish package to PyPI
228
+ uses: pypa/gh-action-pypi-publish@release/v1
229
+ with:
230
+ packages-dir: pypi-dist
231
+
232
+ - name: Configure git identity
233
+ run: |
234
+ git config --local user.name "github-actions[bot]"
235
+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
236
+
237
+ - name: Create and push tag
238
+ env:
239
+ VERSION: ${{ needs.validate.outputs.version }}
240
+ run: |
241
+ if git rev-parse "v$VERSION" >/dev/null 2>&1; then
242
+ echo "Tag v$VERSION already exists."
243
+ exit 1
244
+ fi
245
+ git tag -a "v$VERSION" -m "Release v$VERSION"
246
+ git push origin "v$VERSION"
247
+
248
+ - name: Create GitHub release
249
+ env:
250
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
251
+ VERSION: ${{ needs.validate.outputs.version }}
252
+ run: gh release create "v$VERSION" dist/* --generate-notes --title "v$VERSION"
pyds4-1.0.0/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ specs/
2
+ tests/COVERAGE.md
3
+ .venv/
4
+ .local/
5
+ .pytest_cache/
6
+ dist/
7
+ *.sw[mnop]
8
+ build/
9
+ __pycache__/
10
+ *.py[cod]