Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
162 lines (147 loc) · 6.23 KB
/
Copy pathpyproject.toml
File metadata and controls
162 lines (147 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
[build-system]
requires = ["setuptools>=77"]
build-backend = "setuptools.build_meta"
[project]
name = "trnrt"
dynamic = ["version"]
description = "LLM inference on AWS Trainium2, with NKI megakernels: an OpenAI-compatible server, 1M-token context and prefix caching"
readme = "README.md"
requires-python = ">=3.13"
license = "Apache-2.0"
license-files = ["LICENSE", "NOTICE"]
authors = [{ name = "RunAnywhere", email = "security@runanywhere.ai" }]
keywords = ["llm", "inference", "trainium", "aws", "neuron", "nki", "serving", "openai"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
"numpy",
"safetensors",
"tokenizers",
"torch>=2.11",
"transformers>=5.17",
"jinja2",
"huggingface_hub",
"fastapi",
"uvicorn",
"httpx",
]
[project.optional-dependencies]
test = ["pytest>=8", "openai>=1.40", "ml_dtypes"]
# Guided decoding (--structured-outputs): the grammar engine. Optional: without it guided requests get a 400.
grammar = ["xgrammar>=0.1.19"]
lint = ["ruff==0.17.5", "pre-commit>=4", "mypy==2.4.1"]
dev = ["trnrt[test,lint]"]
[project.urls]
Homepage = "https://github.com/RunanywhereAI/trnrt"
Repository = "https://github.com/RunanywhereAI/trnrt"
Documentation = "https://github.com/RunanywhereAI/trnrt/tree/main/docs"
Issues = "https://github.com/RunanywhereAI/trnrt/issues"
Changelog = "https://github.com/RunanywhereAI/trnrt/blob/main/CHANGELOG.md"
[project.scripts]
trnrt = "trnrt.__main__:main"
[tool.setuptools.dynamic]
version = { attr = "trnrt.__version__" }
[tool.setuptools.packages.find]
include = ["trnrt*"]
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = ["-ra", "--strict-markers", "--strict-config"]
xfail_strict = true
[tool.ruff]
target-version = "py313"
line-length = 120
# tests/reference holds DeepSeek's released encoder and inference code, and benchmarks/accuracy/lm_eval_patch
# InferenceX's lm-eval hooks, each kept byte for byte (THIRD_PARTY_NOTICES.md): never reformatted or linted.
extend-exclude = ["build", "dist", "tests/reference/deepseek_v41_encoding.py", "tests/reference/deepseek_v41/model.py",
"tests/reference/deepseek_v41/engram.py", "benchmarks/accuracy/lm_eval_patch"]
[tool.ruff.format]
# Traced code is never reformatted: a moved line can change a kernel's compiled binary, and with it every compile-cache
# key (AGENTS.md, "Traced code is frozen"). Everything else is formatted.
exclude = [
"trnrt/kernels/**",
"trnrt/models/**",
"trnrt/engine/model_runner.py",
"trnrt/compile/capture.py",
"trnrt/config.py",
"trnrt/platform.py",
]
[tool.ruff.lint]
select = [
"E", "W", # pycodestyle
"F", # pyflakes
"I", # isort
"UP", # pyupgrade (Python 3.13)
"B", # bugbear
"S", # bandit: security
"BLE", # blind except
"A", # shadowed builtins
"C4", # comprehensions
"DTZ", # naive datetimes
"T10", # debugger calls
"T20", # print (allowed only in CLIs, tools and tests: per-file-ignores)
"EXE", # shebangs
"ISC", # implicit string concatenation
"ICN", # import conventions
"LOG", "G", # logging
"PIE", # misc lint
"PT", # pytest style
"RET", # returns
"SIM", # simplify
"TC", # type-checking imports
"ARG", # unused arguments
"ERA", # commented-out code
"PGH", # pygrep hooks
"PLE", "PLW", # pylint errors and warnings
"PERF", # performance anti-patterns
"FURB", # refurb
"FLY", # f-strings over join
"SLOT", # __slots__ on subclasses of immutables
"RUF", # ruff-specific
]
ignore = [
"E501", # line length: the formatter wraps code; long strings and URLs stay whole
"B905", # zip(strict=): truncation is intended where lengths differ; equal-length zips are asserted where it matters
"PT018", # composite assertions: one assert per invariant reads better in numerics tests
"S603", # subprocess with an argument list (never a shell): every call site is reviewed, this rule cannot tell
"S607", # executables found on PATH (git, docker, neuron-ls): intended
"TID252", # relative imports inside the package are the convention; tools/graph_equiv.py relies on them
]
[tool.ruff.lint.per-file-ignores]
# Traced code (see [tool.ruff.format]): correctness rules only, never an edit that could move a graph.
"trnrt/kernels/**" = ["E", "W", "I", "UP", "B", "S", "BLE", "A", "C4", "DTZ", "T20", "EXE", "ISC", "ICN", "LOG", "G", "PIE", "PT", "RET", "SIM", "TC", "ARG", "ERA", "PGH", "PLW", "PERF", "FURB", "FLY", "SLOT", "RUF", "F401", "F841"]
"trnrt/models/**" = ["E", "W", "I", "UP", "B", "S", "BLE", "A", "C4", "DTZ", "T20", "EXE", "ISC", "ICN", "LOG", "G", "PIE", "PT", "RET", "SIM", "TC", "ARG", "ERA", "PGH", "PLW", "PERF", "FURB", "FLY", "SLOT", "RUF", "F841"]
"trnrt/{engine/model_runner,compile/capture,config,platform}.py" = ["E", "W", "I", "UP", "B", "S", "BLE", "A", "C4", "DTZ", "T20", "EXE", "ISC", "ICN", "LOG", "G", "PIE", "PT", "RET", "SIM", "TC", "ARG", "ERA", "PGH", "PLW", "PERF", "FURB", "FLY", "SLOT", "RUF"]
# Tests: asserts are pytest's API, stubs keep their callee's signature, seeded randomness is not cryptography, and a
# tokenizer's unk_token is not a password.
"tests/**" = ["S101", "S106", "S311", "ARG", "T20"]
# Command-line programs print their output.
"tools/**" = ["T20"]
"benchmarks/**" = ["T20"]
"docker/**" = ["T20"]
"trnrt/__main__.py" = ["T20"]
"trnrt/compile/farm.py" = ["T20"]
[tool.ruff.lint.isort]
known-first-party = ["trnrt"]
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
[tool.mypy]
python_version = "3.13"
files = ["trnrt", "tools", "docker"]
ignore_missing_imports = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
strict_equality = true
check_untyped_defs = true
no_implicit_optional = true
# Traced code is frozen (see [tool.ruff.format]); it is not type-checked here.
[[tool.mypy.overrides]]
module = ["trnrt.kernels.*", "trnrt.models.*", "trnrt.engine.model_runner", "trnrt.compile.capture", "trnrt.config", "trnrt.platform"]
ignore_errors = true