Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
564e65b
optionally launch with coordinator.
lmcafee-nvidia Oct 21, 2025
0fc1c24
updated 12b.
lmcafee-nvidia Oct 21, 2025
7f022ad
removed and re-added tokenizer/requests; working again.
lmcafee-nvidia Oct 21, 2025
e42fc21
returned mock finished requests to client.
lmcafee-nvidia Oct 21, 2025
cd52491
successfully printed prompt_text/generated_text.
lmcafee-nvidia Oct 21, 2025
45897bd
removed coordinator.requests.
lmcafee-nvidia Oct 21, 2025
25037cc
removed coordinator.tokenize_prompt().
lmcafee-nvidia Oct 21, 2025
b3ae7cb
removed coordinator.tokenizer.
lmcafee-nvidia Oct 21, 2025
cb08e80
relevant engine code deprecated.
lmcafee-nvidia Oct 21, 2025
45ebec0
finalized headers.
lmcafee-nvidia Oct 21, 2025
cc0df53
removed post_process_requests_locally code.
lmcafee-nvidia Oct 21, 2025
4b03283
partially cleaned client, example.
lmcafee-nvidia Oct 21, 2025
b616395
cleaned coordinator.
lmcafee-nvidia Oct 21, 2025
b886c49
minor update.
lmcafee-nvidia Oct 21, 2025
a33d218
reverted example.
lmcafee-nvidia Oct 21, 2025
4935fd2
chore: Format files
Oct 21, 2025
4f903d2
format.
lmcafee-nvidia Oct 21, 2025
384d4c5
Merge remote-tracking branch 'origin/lmcafee/dedupe-engine-coordinato…
lmcafee-nvidia Oct 21, 2025
904456f
serialized dynamic request.
lmcafee-nvidia Oct 24, 2025
66c990a
example coordinator script runs with serialized requests.
lmcafee-nvidia Oct 24, 2025
4cf74ff
added tensor serialize/deserialize.
lmcafee-nvidia Oct 24, 2025
9f282eb
deserialized base InferenceRequest.
lmcafee-nvidia Oct 24, 2025
df197b1
serialized context errors.
lmcafee-nvidia Oct 24, 2025
1f73606
deserialized context errors.
lmcafee-nvidia Oct 24, 2025
3e62d3d
deserialized DynamicInferenceRequest.
lmcafee-nvidia Oct 24, 2025
877ab94
detokenize prompt in postprocessing.
lmcafee-nvidia Oct 24, 2025
648d660
clean up.
lmcafee-nvidia Oct 24, 2025
e7cc2d0
format.
lmcafee-nvidia Oct 24, 2025
f3cf7b5
Merge remote-tracking branch 'origin/main' into lmcafee/dedupe-engine…
lmcafee-nvidia Oct 28, 2025
581caad
copyright.
lmcafee-nvidia Oct 28, 2025
75071c8
Merge branch 'main' into lmcafee/dedupe-engine-coordinator
ko3n1g Oct 28, 2025
cf7a359
Merge branch 'main' into lmcafee/dedupe-engine-coordinator
ko3n1g Oct 28, 2025
1863df0
Merge branch 'main' into lmcafee/dedupe-engine-coordinator
ko3n1g Oct 28, 2025
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
10 changes: 8 additions & 2 deletions examples/inference/gpt/gpt_dynamic_inference_12b.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export CUDA_DEVICE_MAX_CONNECTIONS=1
: ${CUDA_GRAPH_SHARE_IO_BUFFERS=1}

# Miscellaneous.
: ${USE_COORDINATOR=0}
: ${ENGINE=dynamic}
: ${EXTRA_ARGS=""}
# NSIGHT_PREFIX=/path/to/nsight/profile
Expand Down Expand Up @@ -85,7 +86,7 @@ ARGS=" \
"

# Cuda graphs.
if [ "${CUDA_GRAPH_IMPL}" = "local" ]; then
if [ "${NUM_CUDA_GRAPHS}" != "0" ]; then
ARGS+=" \
--cuda-graph-impl local \
--inference-dynamic-batching-num-cuda-graphs ${NUM_CUDA_GRAPHS} \
Expand All @@ -108,7 +109,12 @@ else
fi

# Command.
CMD="python -m examples.inference.gpt.gpt_${ENGINE}_inference ${ARGS}"
if [[ "${USE_COORDINATOR}" == "0" ]]; then
CMD="python -m examples.inference.gpt.gpt_${ENGINE}_inference ${ARGS}"
else
CMD="python -um examples.inference.gpt.gpt_${ENGINE}_inference_with_coordinator ${ARGS}"
fi

if [[ -v NSIGHT_PREFIX ]]; then
CMD="nsys profile -s none -t nvtx,cuda --cudabacktrace=all --cuda-graph-trace=node --python-backtrace=cuda --wait all -o ${NSIGHT_PREFIX} --force-overwrite true --capture-range=cudaProfilerApi --capture-range-end=stop ${CMD}"
fi
Expand Down
10 changes: 8 additions & 2 deletions examples/inference/gpt/gpt_dynamic_inference_357m.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export CUDA_DEVICE_MAX_CONNECTIONS=1
: ${CUDA_GRAPH_SHARE_IO_BUFFERS=1}

# Miscellaneous.
: ${USE_COORDINATOR=0}
: ${ENGINE=dynamic}
: ${EXTRA_ARGS=""}
# NSIGHT_PREFIX=/path/to/nsight/profile
Expand Down Expand Up @@ -71,7 +72,7 @@ ARGS=" \
"

# Cuda graphs.
if [ "${CUDA_GRAPH_IMPL}" = "local" ]; then
if [ "${NUM_CUDA_GRAPHS}" != "0" ]; then
ARGS+=" \
--cuda-graph-impl local \
--inference-dynamic-batching-num-cuda-graphs ${NUM_CUDA_GRAPHS} \
Expand All @@ -94,7 +95,12 @@ else
fi

# Command.
CMD="python -m examples.inference.gpt.gpt_${ENGINE}_inference ${ARGS}"
if [[ "${USE_COORDINATOR}" == "0" ]]; then
CMD="python -m examples.inference.gpt.gpt_${ENGINE}_inference ${ARGS}"
else
CMD="python -um examples.inference.gpt.gpt_${ENGINE}_inference_with_coordinator ${ARGS}"
fi

if [[ -v NSIGHT_PREFIX ]]; then
CMD="nsys profile -s none -t nvtx,cuda --cudabacktrace=all --cuda-graph-trace=node --python-backtrace=cuda --wait all -o ${NSIGHT_PREFIX} --force-overwrite true --capture-range=cudaProfilerApi --capture-range-end=stop ${CMD}"
fi
Expand Down
52 changes: 49 additions & 3 deletions megatron/core/inference/contexts/dynamic_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

import math
import warnings
Expand Down Expand Up @@ -59,8 +59,10 @@ def __init__(
self, request_id: Optional[int], message: Optional[str] = None, *, is_transient: bool = True
):
request_str = '--' if request_id is None else str(request_id)
message = "" if message is None else f" | {message}"
super().__init__(f"request {request_str}{message}")
_message = "" if message is None else f" | {message}"
super().__init__(f"request {request_str}{_message}")
self.request_id = request_id
self.message = message
self.is_transient = is_transient


Expand Down Expand Up @@ -102,6 +104,50 @@ def __init__(self, max_request_count, active_request_count):
)


class ContextErrorFactory:
"""Factory class for serializing/deserializing context errors."""

@classmethod
def serialize(cls, error: ContextOverflowError) -> dict:
"""Serialize error.

Args:
error (ContextOverflowError): Error.

Returns:
(dict) Serialized error data.
"""
assert isinstance(error, ContextOverflowError)
return {
"type": type(error).__name__,
"request_id": error.request_id,
"message": error.message,
"is_transient": error.is_transient,
}

@classmethod
def deserialize(cls, obj: dict) -> ContextOverflowError:
"""Deserialize error.

Args:
obj (dict): Serialized error data.

Returns:
(ContextOverflowError) Deserialized error.
"""
error_cls = {
"ContextOverflowError": ContextOverflowError,
"RequestOverflowError": RequestOverflowError,
"TokenOverflowError": TokenOverflowError,
"MaxSequenceLengthOverflowError": MaxSequenceLengthOverflowError,
"BlockOverflowError": BlockOverflowError,
"ActiveRequestCountOverflowError": ActiveRequestCountOverflowError,
}[obj["type"]]
error = ContextOverflowError(**{k: v for k, v in obj.items() if k != "type"})
error.__class__ = error_cls # todo (@lmcafe): better/safer alternative?
return error


class WarmupEngineMode(Enum):
"""Enumeration for warmup engine modes used during cuda graph capture."""

Expand Down
Loading
Loading