Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8debc5e
feat(inference): add ServeConfig and _EventLoopManager
YangFei1990 May 7, 2026
4ca3c95
feat(inference): add coordinator runtime and _MegatronLLMBase
YangFei1990 May 7, 2026
d7e68f1
feat(inference): add MegatronAsyncLLM, slim base class
YangFei1990 May 7, 2026
c03ab48
feat(inference): add MegatronLLM
YangFei1990 May 7, 2026
5c38044
refactor(inference): drop model_name fields from ServeConfig
YangFei1990 May 7, 2026
6331cc0
feat(inference): add MegatronAsyncLLM.serve(), drop ServeConfig.role
YangFei1990 May 7, 2026
b6448e8
feat(inference): add offline_inference example, fix high-level API bugs
YangFei1990 May 7, 2026
44ec5a9
feat(inference): add launch_inference_server example, fix daemon-thre…
YangFei1990 May 8, 2026
0d8ae8b
fix(tests): repoint inference recipes and cuda_graphs.sh to examples/…
YangFei1990 May 8, 2026
589626d
test(inference): add unit tests for the high-level inference API
YangFei1990 May 8, 2026
2eb2e81
test(inference): add functional tests for offline_inference 4 modes w…
YangFei1990 May 8, 2026
739f3b0
test(inference): add HTTP smoke test for launch_inference_server with…
YangFei1990 May 8, 2026
8ff9a26
docs(inference): add README for the high-level inference API
YangFei1990 May 8, 2026
9e7fae3
docs(inference): rewrite examples README and remove stale llama_mistr…
YangFei1990 May 8, 2026
5f651b7
Merge branch 'main' into inference_apis
YangFei1990 May 8, 2026
34494c5
ci(inference): satisfy linting, copyright-check, and build-docs
YangFei1990 May 8, 2026
8caa84d
Merge branch 'inference_apis' of https://github.com/YangFei1990/Megat…
YangFei1990 May 8, 2026
963f663
Merge branch 'main' into inference_apis
YangFei1990 May 8, 2026
67a9122
handle coordinator subprocess during partial shutdown
YangFei1990 May 18, 2026
b754bd2
do not hardcode return_log_probs
YangFei1990 May 18, 2026
e1c6353
raise when running sync inside a eventloop
YangFei1990 May 18, 2026
dd70796
add future roadmap and knwn limitations
YangFei1990 May 18, 2026
db9f475
always use Optional instead of |; remove unneeded doc
YangFei1990 May 18, 2026
30f1020
raise error when ep > 1 and coordinator is not enabled
YangFei1990 May 18, 2026
93b30a0
use event to wait the loop ready
YangFei1990 May 18, 2026
2759cdd
docs(inference): rename examples/inference/legacy to advanced and exp…
YangFei1990 May 18, 2026
856c851
fix bcast and import path
YangFei1990 May 18, 2026
c38eb66
forbid running async + direct
YangFei1990 May 18, 2026
34ca470
refactor(inference): move high-level API to megatron/core/inference/apis
YangFei1990 May 18, 2026
dac4fc2
Merge branch 'main' into inference_apis
YangFei1990 May 18, 2026
4be95ff
update doc
YangFei1990 May 18, 2026
a3aade9
Merge branch 'main' into inference_apis
YangFei1990 May 18, 2026
dd41c05
fix lint
YangFei1990 May 20, 2026
4cff952
simplify tests
YangFei1990 May 20, 2026
450380d
add meaningful tests
YangFei1990 May 20, 2026
1bbdada
Merge branch 'main' into inference_apis
YangFei1990 May 20, 2026
ec780e5
fix lint
YangFei1990 May 20, 2026
7f53bd1
Merge branch 'main' into inference_apis
YangFei1990 May 21, 2026
7b513a0
modify inaccurate doc and make torch import default
YangFei1990 May 21, 2026
ea0bc17
Merge branch 'main' into inference_apis
YangFei1990 May 28, 2026
74eb926
update doc to remove async + direct mode
YangFei1990 May 28, 2026
0b44fb8
fix CI
YangFei1990 May 28, 2026
d76fca4
Merge branch 'main' into inference_apis
YangFei1990 May 28, 2026
27b920e
Merge branch 'main' into inference_apis
YangFei1990 May 28, 2026
0298310
increase test coverage
YangFei1990 May 29, 2026
4e3269d
Merge branch 'main' into inference_apis
YangFei1990 May 29, 2026
42a9ead
fix import
YangFei1990 May 29, 2026
f85df57
Revert "increase test coverage"
YangFei1990 May 29, 2026
87ba21c
Merge branch 'inference_apis' of https://github.com/YangFei1990/Megat…
YangFei1990 May 29, 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
18 changes: 0 additions & 18 deletions docs/llama_mistral.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ Architecturally Llama-2, Llama-3 and Mistral-7b are very similar. As such Megatr
- [Download Huggingface checkpoints](#download-huggingface-checkpoints)
- [Convert checkpoint format](#convert-checkpoint-format)
- [Huggingface format](#huggingface-format)
- [(Optional) Validate checkpoints](#optional-validate-checkpoints)
- [Launch model](#launch-model)
- [Mistral-7b](#mistral-7b)
- [Download Huggingface checkpoints](#download-huggingface-checkpoints)
- [Convert checkpoint format](#convert-checkpoint-format)
- [(Optional) Validate checkpoints](#optional-validate-checkpoints)
- [Launch model](#launch-model)
- [Other Llama-like model support](#other-llama-like-model-support)
- [Known numerical differences](#known-numerical-differences)
Expand Down Expand Up @@ -210,14 +208,6 @@ python Megatron-Bridge/examples/conversion/convert_checkpoints.py import \

After this conversion, we are ready to load the checkpoints into a Megatron GPT model.

## (Optional) Validate checkpoints

A Megatron-LM text generation server for Llama3 can be launched using the script `examples/inference/llama_mistral/run_text_generation_llama3.sh <PATH_TO_CONVERTED_CORE_CHECKPOINT> <PATH_TO_DOWNLOADED_HUGGINGFACE_CHECKPOINT>`. For Llama3.1, please use `examples/inference/llama_mistral/run_text_generation_llama3.1.sh`.

Once running, query the server with `curl 'http://<TEXT_GENERATION_SERVER_IP>:5000/api' -X 'PUT' -H 'Content-Type: application/json; charset=UTF-8' -d '{"prompts":["<SOME_PROMPT>"], "tokens_to_generate":100, "top_k":1}'`.

A reference generation for comparison can be obtained from the Huggingface transformers library by running `python examples/llama_mistral/huggingface_reference.py --model_path <PATH_TO_DOWNLOADED_HUGGINGFACE_CHECKPOINT> --prompt <SOME_PROMPT>`.

## Launch model

If loading for either inference or finetuning, use the following arguments for Llama 3.0:
Expand Down Expand Up @@ -314,14 +304,6 @@ python Megatron-Bridge/examples/conversion/convert_checkpoints.py import \

After this conversion, we are ready to load the checkpoints into a Megatron GPT model.

## (Optional) Validate checkpoints

A Megatron-LM text generation server for Mistral-7B can be launched using the script `examples/inference/llama_mistral/run_text_generation_mistral.sh <PATH_TO_CONVERTED_MCORE_CHECKPOINT> <PATH_TO_DOWNLOADED_HUGGINGFACE_CHECKPOINT>`.

Once running, query the server with `curl 'http://<TEXT_GENERATION_SERVER_IP>:5000/api' -X 'PUT' -H 'Content-Type: application/json; charset=UTF-8' -d '{"prompts":["<SOME_PROMPT>"], "tokens_to_generate":100, "top_k":1}'`.

A reference generation for comparison can be obtained from the Huggingface transformers library by running `python examples/inference/llama_mistral/huggingface_reference.py --model_path <PATH_TO_DOWNLOADED_HUGGINGFACE_CHECKPOINT> --prompt <SOME_PROMPT>`.
Comment thread
shanmugamr1992 marked this conversation as resolved.

## Launch model

If loading for either inference or finetuning, use the following arguments:
Expand Down
359 changes: 91 additions & 268 deletions examples/inference/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir))
)

from examples.inference.gpt.utils import (
from examples.inference.utils import (
Request,
build_dynamic_engine_setup_prefix,
build_requests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import torch
import torch.distributed as dist

from examples.inference.gpt.utils import Request, build_dynamic_engine_setup_prefix, build_requests
from examples.inference.utils import Request, build_dynamic_engine_setup_prefix, build_requests
from megatron.core.inference.engines import DynamicInferenceEngine
from megatron.core.inference.engines.dynamic_engine import EngineState
from megatron.core.inference.inference_client import InferenceClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import json
from typing import List

from examples.inference.gpt.utils import build_requests
from examples.inference.utils import build_requests
from megatron.inference.utils import add_inference_args, get_model_for_inference
from megatron.training import get_args, get_tokenizer, print_rank_0
from megatron.training.initialize import initialize_megatron
Expand Down
127 changes: 0 additions & 127 deletions examples/inference/gpt/gpt_dynamic_inference_12b.sh

This file was deleted.

115 changes: 0 additions & 115 deletions examples/inference/gpt/gpt_dynamic_inference_357m.sh

This file was deleted.

Loading
Loading