Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8f70fe7
Add asynchronous prefill scheduling
lmcafee-nvidia Jul 20, 2026
cda97a7
Label asynchronous prefill phases
lmcafee-nvidia Jul 21, 2026
d4a9758
Reorder controller methods by dependency
lmcafee-nvidia Jul 21, 2026
da72be8
Remove serial async scheduling mode
lmcafee-nvidia Jul 22, 2026
1965c8d
Remove obsolete async scheduling events
lmcafee-nvidia Jul 22, 2026
25ff376
Remove redundant async token metadata compaction
lmcafee-nvidia Jul 22, 2026
7739953
Separate async request resolution from token commits
lmcafee-nvidia Jul 22, 2026
529dca3
Move async token count ownership out of resolution
lmcafee-nvidia Jul 22, 2026
cc7bc5a
Select async scheduling by overlap
lmcafee-nvidia Jul 22, 2026
661236d
Support lifecycle fallback in async scheduling
lmcafee-nvidia Jul 23, 2026
7164358
Preserve counters across async dummy resets
lmcafee-nvidia Jul 23, 2026
c9bb286
Merge remote-tracking branch 'main/main' into async-sched-prefill
lmcafee-nvidia Jul 23, 2026
4c6a1ea
Run autoformat after merging main
lmcafee-nvidia Jul 23, 2026
48ff876
Fix async scheduling step classification
lmcafee-nvidia Jul 23, 2026
ddc839a
Simplify async scheduling log labels
lmcafee-nvidia Jul 23, 2026
06f8912
Merge remote-tracking branch 'main/main' into async-sched-prefill
lmcafee-nvidia Jul 23, 2026
61ada4f
Merge remote-tracking branch 'main/main' into async-sched-prefill
lmcafee-nvidia Jul 24, 2026
b819e71
Merge remote-tracking branch 'main/main' into async-sched-prefill
lmcafee-nvidia Jul 27, 2026
f00aa8d
Fix async sampling buffer test
lmcafee-nvidia Jul 27, 2026
d85e283
Remove async resolution forward synchronization
lmcafee-nvidia Jul 27, 2026
19535cc
Support Mamba async scheduling
lmcafee-nvidia Jul 28, 2026
71e2e18
Support async prefix caching and chunked prefill
lmcafee-nvidia Jul 28, 2026
b771239
Support sampling modes with async scheduling
lmcafee-nvidia Jul 28, 2026
cc4187c
Support log probabilities with async scheduling
lmcafee-nvidia Jul 28, 2026
ce7b988
Support stop words with async scheduling
lmcafee-nvidia Jul 28, 2026
5b236ba
Merge remote-tracking branch 'main/main' into async-sched-prefill
lmcafee-nvidia Jul 28, 2026
403b1a9
Remove async scheduling functional test recipe
lmcafee-nvidia Jul 28, 2026
2c957eb
Merge remote-tracking branch 'main/main' into async-sched-prefill
lmcafee-nvidia Jul 28, 2026
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
7 changes: 5 additions & 2 deletions examples/inference/advanced/gpt_dynamic_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def _process_step_result(result):
"""Process a single engine step result, updating bookkeeping state."""
nonlocal total_output_tokens, num_requests_finished

is_decode_only = engine.is_decode_only
decode_only = engine.decode_only
is_decode_only = (
decode_only.launched if decode_only.launched is not None else decode_only.consumed
)

# Record cuda_graph_request_count.
cuda_graph_request_count = result["cuda_graph_request_count"]
Expand Down Expand Up @@ -228,7 +231,7 @@ def _process_step_result(result):
add_times.append(get_curr_time(do_broadcast=False) - add_start)

# Step inference engine (i.e., generate a token for each active request).
# Before step, we haven't done the scheduling, so we cannot know the is_decode_only
# The engine reports the consumed and launched decode-only states after scheduling.
try:
result = engine.step_modern()
except EngineSuspendedError as e:
Expand Down
7 changes: 2 additions & 5 deletions megatron/core/inference/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,8 @@ class AsyncScheduleMode(str, Enum):
LEGACY = "legacy"
"""Resolve requests before preparing the next forward pass."""

SERIAL = "serial"
"""Prepare and forward speculatively before resolving the sampled requests."""

OVERLAP = "overlap"
"""Overlap async scheduling prepare/sample and forward/resolve phases."""
ASYNC = "async"
"""Overlap asynchronous scheduling phases by reordering them to prepare-before-resolve."""


@dataclass
Expand Down
264 changes: 182 additions & 82 deletions megatron/core/inference/contexts/dynamic_context.py

Large diffs are not rendered by default.

193 changes: 143 additions & 50 deletions megatron/core/inference/engines/dynamic_engine.py

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions megatron/training/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2012,13 +2012,11 @@ def _add_inference_args(parser):
'is requested but the package is not installed.')
group.add_argument('--inference-dynamic-batching-async-sched-mode',
type=str, default='legacy',
choices=['legacy', 'serial', 'overlap'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically this is not strictly backwards compatible, though im not sure how much we care about back compat for inference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should at least leave a comment. Is async a (improved) rename of overlap?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, async is a rename of overlap.

and @jiemingz , I believe inference has not being enforcing backwards compatibility for a while. also, all of this async stuff has been going in in the last couple weeks, so it's relatively short-lived.

choices=['legacy', 'async'],
help='Async scheduling mode for dynamic batching. '
'"legacy" (default) preserves the existing resolve-before-prepare '
'path. "serial" speculatively prepares and forwards decode-only '
'steps before resolving finished requests. "overlap" uses the same '
'async scheduling path while overlapping prepare/sample and '
'forward/resolve phases.')
'path. "async" overlaps asynchronous scheduling phases by reordering '
'them to prepare-before-resolve.')
group.add_argument('--inference-dynamic-batching-logprobs-mode',
type=str, default='raw_logprobs',
choices=['raw_logprobs', 'processed_logprobs'],
Expand Down
7 changes: 3 additions & 4 deletions megatron/training/config/inference_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ class InferenceSetupConfig:
"""Which sampling kernels to use during inference. Falls back to "torch" with a warning if
"flashinfer" is requested but the package is not installed."""

inference_dynamic_batching_async_sched_mode: Literal["legacy", "serial", "overlap"] = "legacy"
inference_dynamic_batching_async_sched_mode: Literal["legacy", "async"] = "legacy"
"""Async scheduling mode for dynamic batching. "legacy" (default) preserves the
existing resolve-before-prepare path. "serial" speculatively prepares and forwards decode-only
steps before resolving finished requests. "overlap" uses the same async scheduling path while
overlapping prepare/sample and forward/resolve phases."""
existing resolve-before-prepare path. "async" overlaps asynchronous scheduling phases by
reordering them to prepare-before-resolve."""

inference_dynamic_batching_logprobs_mode: Literal["raw_logprobs", "processed_logprobs"] = (
"raw_logprobs"
Expand Down
Loading