Yijun Zhao 479d7f7873 engine: refactor Scheduler for readability without changing scheduling behavior
- Turn Scheduler into a class: only waiting/running/decode_step (bound by
  pybind) stay public; internals become private.
- Move immutable knobs into SchedulerConfig::capture(), alongside the
  constructor-time checks.
- Drop dead state: dp_size, dp_rank, truncate_len, schedule_counter,
  last_step_*, tokens_chunked_prefill_remaining, and the max_num_prompts
  alias. The unused truncate_len constructor argument is removed from the
  binding, the stub and llm_engine.
- Split _schedule into _schedule_normal / _schedule_prefill /
  _schedule_decode; decode is further split into _admit_prompted and
  _select_decode_batch.
- Share the forked-KV detach logic between prefill and decode
  (_detach_forked_cache) instead of two hand-written copies.
- prompted no longer carries a tuple<seq, bool>: the flag was always true.
- process_outputs: the returned buffers become per-instance members instead
  of function-level statics shared by all Scheduler instances. The binding
  returns them as zero-copy numpy arrays whose base is the Scheduler, so
  holding an array keeps the storage alive.
- SchedulerOutputs is filled incrementally instead of via a 10-arg ctor.
- Fix the LCFS comment: preemption victims are the longest-output seqs.
- block_manager.hpp now includes <sys/time.h> itself for gettimeofday.

Verified with a differential harness that drives the old and new
Scheduler through identical randomized workloads (NORMAL/PROMPT/COMPLETION,
chunked prefill, MTP varlen, forks, preemption, aborts, multimodal chunk
boundaries, simulated multi-rank votes) and compares full per-step state:
120/120 traces identical on macOS/clang and Linux/GCC 15; a Python smoke
test through the real pybind bindings is also identical old vs new.
2026-10-20 20:42:29 +08:00
..
__init__.py initial commit 2026-10-20 12:09:42 +08:00
arg_utils.py initial commit 2026-10-20 12:09:42 +08:00
engine_type.py initial commit 2026-10-20 12:09:42 +08:00
llm_engine.py engine: refactor Scheduler for readability without changing scheduling behavior 2026-10-20 20:42:29 +08:00
profile_server.py initial commit 2026-10-20 12:09:42 +08:00
stats_logger.py initial commit 2026-10-20 12:09:42 +08:00