Commit b59d99f
committed
extension/llm/runner: Python bindings for the Engine/Session API
Bind LLMEngine and LLMSession (PyLLMEngine/PyLLMSession), exposing
create_session(), serving_capacity(), and the token-step methods
(prefill_tokens/decode_one/seek/position/reset/stop) only on LLMSession.
PyTextLLMRunner stays a legacy direct runner and no longer exposes token-step
methods, so LLMSession is the single Python serving surface. Backend execution
across an engine's sessions is serialized by an engine-owned lock.
TokenStringCallback buffers byte-level BPE tokens so a multi-byte character
split across callbacks does not break UTF-8 decoding. Stubs in _llm_runner.pyi;
boundary and session tests in test_runner_pybindings.py.
Second of four stacked commits; depends on the C++ core.
ghstack-source-id: 86cd500
ghstack-comment-id: 4617262734
Pull-Request: #199921 parent 5d85624 commit b59d99f
4 files changed
Lines changed: 446 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
| 239 | + | |
| 240 | + | |
237 | 241 | | |
238 | 242 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
414 | 474 | | |
415 | 475 | | |
416 | 476 | | |
| |||
0 commit comments