-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Add inference functions to support MCore-/MBridge- training refactor and remove legacy modelbuilder functions #5169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7d35d0c
f51bd1f
c6893aa
edbb694
e83fac9
593c713
9c91aa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| from megatron.core.msc_utils import MultiStorageClientFeature | ||
| from megatron.core.optimizer import OptimizerConfig | ||
| from megatron.training.config.common_config import DistributedInitConfig, ProfilingConfig, RNGConfig | ||
| from megatron.training.config.inference_config import InferenceSetupConfig | ||
| from megatron.training.config.instantiate_utils import InstantiationMode, instantiate | ||
| from megatron.training.config.resilience_config import ( | ||
| RerunStateMachineConfig, | ||
|
|
@@ -247,3 +248,35 @@ class PretrainConfigContainer(ConfigContainerBase): | |
|
|
||
| rerun_state_machine: RerunStateMachineConfig = field(default_factory=RerunStateMachineConfig) | ||
| straggler: StragglerDetectionConfig | None = None | ||
|
|
||
|
|
||
| @dataclass(kw_only=True) | ||
| class InferenceConfigContainer(ConfigContainerBase): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered megatron/inference/config/, but the container is built entirely from megatron/training/config/ pieces (ConfigContainerBase, plus model/checkpoint/dist/tokenizer/logger configs) and is the direct counterpart of PretrainConfigContainer, which lives here. This also comes from this refactor document that MAaanu put together https://docs.google.com/document/d/1_aox_TNjhFn0hFYEgvELil-MKeudye_aLPH_FHj7P6Q/edit?tab=t.0 (Section 5.3 and 4.2) . LMK if you have a strong preference. Can change it |
||
| """Top-level container for inference entry points. | ||
|
|
||
| This is the inference counterpart to :class:`PretrainConfigContainer`. It holds only the | ||
| configs that inference actually needs and is intentionally shaped differently from the | ||
| training container: there is no optimizer, LR schedule, train/validation loop, DDP, rerun | ||
| state machine, or straggler detection. | ||
|
|
||
| Explicitly NOT included (relative to ``PretrainConfigContainer``): ``TrainingConfig``, | ||
| ``OptimizerConfig``, ``SchedulerConfig``, ``ValidationConfig``, | ||
| ``DistributedDataParallelConfig``, ``RerunStateMachineConfig``, ``StragglerDetectionConfig``. | ||
| """ | ||
|
|
||
| model: HybridModelConfig | GPTModelConfig | ||
| """Which model to load for inference.""" | ||
|
|
||
| checkpoint: CheckpointConfig | ||
| """Checkpoint configuration used to load model weights.""" | ||
|
|
||
| inference: InferenceSetupConfig | ||
| """Declarative inference settings (the serializable, args-shaped layer). Use | ||
| ``InferenceSetupConfig.to_inference_config(model, ...)`` to build the runtime | ||
| ``megatron.core.inference.config.InferenceConfig`` consumed by the engine.""" | ||
|
|
||
| dist: DistributedInitConfig = field(default_factory=DistributedInitConfig) | ||
| rng: RNGConfig = field(default_factory=RNGConfig) | ||
| tokenizer: TokenizerConfig = field(default_factory=TokenizerConfig) | ||
| logger: LoggerConfig = field(default_factory=LoggerConfig) | ||
| profiling: ProfilingConfig = field(default_factory=ProfilingConfig) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably safe but is ModelOpt relevant for inference? Could we in theory just assert that
modelopt_enabledis False?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to be on the safer side sincet he old system had this. Can remove it in later MR's if required