Skip to content

[None][fix] drop the placeholder MicroBatchScheduler that shadows the ABC - #19087

Closed
Anai-Guo wants to merge 1 commit into
NVIDIA:mainfrom
Anai-Guo:fix-microbatchscheduler-placeholder-shadow
Closed

Anai-Guo wants to merge 1 commit into
NVIDIA:mainfrom
Anai-Guo:fix-microbatchscheduler-placeholder-shadow

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 11, 2026

Copy link
Copy Markdown

Description

tensorrt_llm/_torch/pyexecutor/scheduler/scheduler.py binds the module-level name
MicroBatchScheduler twice:

# line 474 - the real contract
class MicroBatchScheduler(ABC):
    @abstractmethod
    def schedule(self, active_requests, inflight_request_ids): ...
        # to be aligned with MicroBatchScheduler::scheduleRequests
        # in cpp/tensorrt_llm/batch_manager/microBatchScheduler.h

# line 867 - placeholder
class MicroBatchScheduler:
    """Base class to match structure."""

Python executes both class statements, so the second one silently wins. The
placeholder came in with dbb858a ([TRTLLM-10029][scheduler] Re-implement MicroBatchScheduler and CapacityScheduler…) alongside PyMicroBatchScheduler, which
is declared right after it and therefore inherits the placeholder rather than the ABC.

This matters because MicroBatchScheduler is a public export — it is listed in
tensorrt_llm/_torch/pyexecutor/scheduler/__init__.py's __all__, so
from tensorrt_llm._torch.pyexecutor.scheduler import MicroBatchScheduler hands the
caller the empty placeholder.

Effect

Lifting the three class statements out of the file in their upstream order (headers

  • method signatures only, ABC/abstractmethod bound for real, no torch needed):
BEFORE (upstream main)
  MicroBatchScheduler is an ABC ............ False
  MicroBatchScheduler.schedule exists ...... False
  issubclass(BindMicroBatchScheduler, MBS) . False
  issubclass(PyMicroBatchScheduler,   MBS) . True
  PyMicroBatchScheduler.__mro__ ............ ['PyMicroBatchScheduler', 'MicroBatchScheduler', 'object']

AFTER  (placeholder deleted)
  MicroBatchScheduler is an ABC ............ True
  MicroBatchScheduler.schedule exists ...... True
  issubclass(BindMicroBatchScheduler, MBS) . True
  issubclass(PyMicroBatchScheduler,   MBS) . True
  PyMicroBatchScheduler.__mro__ ............ ['PyMicroBatchScheduler', 'MicroBatchScheduler', 'ABC', 'object']

So today BindMicroBatchScheduler — the binding used by _util.py and
auto_deploy/shim/ad_executor.py — is not a subclass of the exported
MicroBatchScheduler, and neither scheduler implementation gets the
@abstractmethod enforcement the ABC was written to provide.

Fix

Delete the two-line placeholder (4 lines including the surrounding blank lines,
+0 / -4, one file). PyMicroBatchScheduler already implements schedule(), so it
satisfies the ABC as-is and nothing else changes: no method bodies, no signatures, no
call sites.

Test Coverage

No behaviour change, so no new test. Existing tests/unittest/_torch/executor/test_py_scheduler.py
covers PyMicroBatchScheduler and continues to apply unchanged.

PR Checklist

  • PR title is in the format [JIRA ticket/NVBugs ID/GitHub issue/None][type] Summary
  • Commit is signed off (DCO)
  • Change is limited to the described fix

AI-assisted (found by a duplicate-module-level-class sweep; the effect table above
was produced by lifting the real class statements out of the upstream file, and I
reviewed the change before submitting).

🤖 Generated with Claude Code

Dev Engineer Review

Removed the duplicate MicroBatchScheduler placeholder. The original abstract base class remains exported, so schedule() enforcement and BindMicroBatchScheduler subclass recognition are restored. No other source behavior or API changes were identified.

QA Engineer Review

No test changes.

Per-File QA Perspective

  • tensorrt_llm/_torch/pyexecutor/scheduler/scheduler.py: Verify that MicroBatchScheduler exposes the abstract schedule() contract and that BindMicroBatchScheduler is recognized as its subclass. Existing scheduler tests should remain applicable.

… ABC

tensorrt_llm/_torch/pyexecutor/scheduler/scheduler.py binds the module-level
name MicroBatchScheduler twice:

* the abstract base at the top of the file -- class MicroBatchScheduler(ABC)
  with the @AbstractMethod schedule() that documents the contract and is
  aligned with MicroBatchScheduler::scheduleRequests in
  cpp/tensorrt_llm/batch_manager/microBatchScheduler.h
* a two-line placeholder further down:

      class MicroBatchScheduler:
          """Base class to match structure."""

Python executes both statements, so the second one silently wins. After import
the exported name (it is in scheduler/__init__.py's __all__) refers to the
empty placeholder, not to the ABC:

* issubclass(BindMicroBatchScheduler, MicroBatchScheduler) is False --
  BindMicroBatchScheduler is still attached to the now-unreachable ABC
* MicroBatchScheduler.schedule does not exist, and the class is no longer
  abstract, so PyMicroBatchScheduler gets no abstract-method enforcement

PyMicroBatchScheduler already implements schedule(), so deleting the
placeholder restores the intended base class with no behaviour change.

Signed-off-by: Tai An <antai12232931@outlook.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 419a092a-ed09-4d96-991c-30a693c8a016

📥 Commits

Reviewing files that changed from the base of the PR and between a85c26c and 774625a.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/pyexecutor/scheduler/scheduler.py
💤 Files with no reviewable changes (1)
  • tensorrt_llm/_torch/pyexecutor/scheduler/scheduler.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The change removes an empty MicroBatchScheduler placeholder from the scheduler module. The functional scheduler abstraction remains.

Changes

Scheduler cleanup

Layer / File(s) Summary
Remove obsolete scheduler declaration
tensorrt_llm/_torch/pyexecutor/scheduler/scheduler.py
Removes the empty MicroBatchScheduler placeholder. The functional scheduler abstraction remains.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Bug fix

Suggested reviewers: bowenfu

Merge Risk: ⚪ Minimal · up to 77462

This cleanup restores the intended scheduler abstraction without introducing an identified merge risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required [ticket][type] format and clearly states that the placeholder MicroBatchScheduler is removed to prevent it from shadowing the ABC.
Description check ✅ Passed The description explains the issue, root cause, fix, impact, and test coverage. It includes the required Description and Test Coverage sections and documents the relevant checklist items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@mikeiovine

Copy link
Copy Markdown
Collaborator

You have many small PRs open; please consolidate

@mikeiovine mikeiovine closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants