Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ jobs:
fail-fast: false
matrix:
# 3.14 is the default python3 on Ubuntu 26.04 (ubuntu-latest).
# actions/setup-python has no CPython 3.9 build for 26.04, so the
# requires-python floor (>=3.9) is not exercised here.
# 3.11 is the requires-python floor (>=3.11).
python-version: ['3.11', '3.13', '3.14']
steps:
- uses: actions/checkout@v7
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Changed

- **The Python client now requires Python 3.11 or newer** (#3013). `requires-python` moves from `>=3.9` to `>=3.11`, matching the oldest interpreter CI tests on `ubuntu-latest` (3.11, 3.13, 3.14); 3.9 is past end of life and 3.10 was never tested after #3013. Installs on 3.9 or 3.10 are now refused by pip instead of running untested.
- **Held the single-sequence XLA decode step's KV cache in module globals so a step updates it in place** (#3043). The graph returned the two cache tensors as results, so IREE lowered every step as two 16 MiB `stream.cmd.copy` ops, 32 MiB of device traffic that the 4-bit 1B decode does not otherwise need. The decode module now declares `util.global private mutable @kcache` and `@vcache`, the step loads them, writes its own row and stores them back, so the update is a read-write binding into one persistent buffer with no copy and no change to the ops or the results; a private global is not host-visible, so a new `decode_step.kv_import` entry seeds it from the prefill result once per request, and every graph that does not export it (Gemma3n's fixed-schedule CUDA decode, an older compiled cache) keeps the previous full-cache ABI. The decode compile also turns on `--iree-dispatch-creation-enable-aggressive-fusion`, which cuts the decode flow from 309 to 277 dispatches by fusing two elementwise pairs per layer; prefill compiles keep the default. On `gfx1151` with llama-3.2-1b-instruct-4bit, native quant, context capacity 512 and `n=128`, one interleaved six-round A/B of the old and new binaries measures a median 196.06 tok/s against 179.78 for the old path (5.10 against 5.56 ms per step), ahead in all six paired rounds, with greedy output identical to the old binary on the same prompt. The same A/B on a GB10 host over CUDA, where native quant is HIP-only so both arms run the f16 path, measures a median 24.47 tok/s against 22.59 (5.22 against 5.66 ms per step), also ahead in all six paired rounds with identical greedy output, so the in-place update is not a HIP-only lowering effect. Those f16 figures are comparable only with the other CUDA arm, not with the native 4-bit figures above.
- **Reused the single-sequence XLA decode step's scalar inputs and token readback** (#3028). Each step used to allocate three input buffer views and one host staging buffer for the 4-byte token readback, and on HIP each host-visible transfer is a pinned `hipHostMalloc`/`hipHostFree` pair; a microbenchmark on `gfx1151` puts the free alone at 122 us, which showed up as GPU-idle gaps at every step boundary. The three inputs and the readback slot are now allocated once per context as host-local, device-visible page-locked memory, mapped for the context's lifetime and written in place, and the readback is a device-to-device copy into the persistent slot. A device whose allocator cannot serve that heap logs one status line and keeps the per-step path, and `test-support` counters assert both the reuse and the fallback. On `gfx1151` with llama-3.2-1b-instruct-4bit, native quant, context capacity 512 and `n=256`, two interleaved four-round A/Bs of the old and new binaries measure a combined median 150.1 tok/s against 140.7 for the old path (6.66 against 7.11 ms per step), with the new path ahead in 7 of 8 paired rounds and byte-identical greedy output.
- **Split XLA load timing and excluded engine load from `xla_batch_bench` throughput** (#2961). `MLXCEL_XLA_LOAD_TIMING` now reports `language-module-load` (instance, device, session and vmfb creation) apart from `language-weight-upload`, and `language-weight-upload-parts` appends the tensor count, uploaded bytes, host dequantize time, f16 pack time and device copy time, so an f16 ragged load can be attributed instead of guessed; a capacity bucket prints the parts line with zero counters because it shares the base context's weights. `xla_batch_bench` loads the engine outside its timed window and prints the two load times separately, so its `tok/s` and `BENCH` lines report decode throughput instead of decode plus a one-time weight upload.
Expand Down
2 changes: 1 addition & 1 deletion docs/python-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pip install ./python # from a repo checkout
pip install "./python[dev]" # adds pytest, ruff, mypy
```

Requires Python 3.9 or newer. Runtime dependencies are `openai>=1.40` and `httpx>=0.27`. Managed mode additionally needs the `mlxcel` binary; the client finds it via the `binary=` argument, the `MLXCEL_BIN` environment variable, or `mlxcel` on `PATH`, in that order. See [Installation](installation.md) for building the binary.
Requires Python 3.11 or newer. Runtime dependencies are `openai>=1.40` and `httpx>=0.27`. Managed mode additionally needs the `mlxcel` binary; the client finds it via the `binary=` argument, the `MLXCEL_BIN` environment variable, or `mlxcel` on `PATH`, in that order. See [Installation](installation.md) for building the binary.

## Managed mode

Expand Down
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pip install ./python # from a repo checkout
pip install "./python[dev]" # with pytest, ruff, mypy for development
```

Requires Python 3.9+. The client itself is pure Python (`openai>=1.40`, `httpx>=0.27`). Managed mode additionally needs the `mlxcel` binary on `PATH`, or pass `binary=` / set `MLXCEL_BIN`.
Requires Python 3.11+. The client itself is pure Python (`openai>=1.40`, `httpx>=0.27`). Managed mode additionally needs the `mlxcel` binary on `PATH`, or pass `binary=` / set `MLXCEL_BIN`.

## Usage

Expand Down
16 changes: 8 additions & 8 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "mlxcel"
version = "0.1.0"
description = "Python client for the mlxcel OpenAI-compatible inference server"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.11"
license = "Apache-2.0"
authors = [
{ name = "Lablup Inc." },
Expand All @@ -19,9 +19,9 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Typing :: Typed",
]
Expand Down Expand Up @@ -53,24 +53,24 @@ testpaths = ["tests"]

[tool.ruff]
line-length = 100
target-version = "py39"
target-version = "py311"
src = ["src", "tests", "examples"]

[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B", "W"]
ignore = [
"UP006", # keep typing.List etc. usable on 3.9 where needed
"UP007", # keep Optional[...] / Union[...] for 3.9 runtime compatibility
"UP035", # allow typing imports under requires-python 3.9
"UP006", # keep typing.List etc. (existing style, not rewritten)
"UP007", # keep Optional[...] / Union[...] (existing style)
"UP035", # allow typing imports (existing style)
"UP037", # keep quoted self-referential annotations
"UP045", # keep Optional[...] over X | None for 3.9 clarity
"UP045", # keep Optional[...] over X | None (existing style)
]

[tool.ruff.lint.per-file-ignores]
"tests/fake_server.py" = ["B008"]

[tool.mypy]
python_version = "3.9"
python_version = "3.11"
strict = true
warn_unused_configs = true
disallow_untyped_defs = true
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_async_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async def close():
# an assertion failure in a deliberately broken implementation.
try:
await asyncio.wait_for(asyncio.shield(task), 4.0)
except (asyncio.CancelledError, RuntimeError, asyncio.TimeoutError):
except (TimeoutError, asyncio.CancelledError, RuntimeError):
pass
elif not task.cancelled():
task.exception()
Expand Down
Loading