Skip to content

Commit 1fa9131

Browse files
authored
[worker] fix: new engine saves megatron LoRA adapters checkpoints (verl-project#4866)
### What does this PR do? forgot to pass `self.peft_cls` to MegatronCheckpointManager, which is necessary for it to check whether it needs to save megatron LoRA adapters checkpoints. ### Checklist Before Starting - [X] Search for similar PRs. Paste at least one query link here: ... - [X] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data`, `cfg`, `reward` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python # Add code snippet or script demonstrating how to use this ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [X] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [X] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) - [ ] If your PR is related to the `recipe` submodule, please also update the reference to the submodule commit via `git submodule update --remote` or `cd recipe && git pull origin main`. Signed-off-by: Hollow Man <hollowman@opensuse.org>
1 parent 145a28b commit 1fa9131

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

verl/workers/engine/megatron/transformer_impl.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333
from verl.utils.debug import log_gpu_memory_usage
3434
from verl.utils.device import get_device_id, get_device_name
3535
from verl.utils.megatron.pipeline_parallel import make_batch_generator
36-
from verl.utils.megatron.tensor_parallel import (
37-
vocab_parallel_entropy,
38-
vocab_parallel_log_probs_from_logits,
39-
)
36+
from verl.utils.megatron.tensor_parallel import vocab_parallel_entropy, vocab_parallel_log_probs_from_logits
4037
from verl.utils.megatron_utils import (
4138
get_megatron_module_device,
4239
load_megatron_model_to_gpu,
@@ -45,17 +42,11 @@
4542
offload_megatron_optimizer,
4643
register_megatron_training_hooks,
4744
)
48-
from verl.utils.model import (
49-
extract_multi_modal_inputs,
50-
load_mcore_dist_weights,
51-
)
45+
from verl.utils.model import extract_multi_modal_inputs, load_mcore_dist_weights
5246
from verl.workers.config import HFModelConfig, McoreEngineConfig, McoreOptimizerConfig
5347

5448
from ..base import BaseEngine, BaseEngineCtx, EngineRegistry
55-
from ..utils import (
56-
postprocess_batch_func,
57-
prepare_micro_batches,
58-
)
49+
from ..utils import postprocess_batch_func, prepare_micro_batches
5950
from .utils import set_random_seed
6051

6152
logger = logging.getLogger(__file__)
@@ -182,10 +173,7 @@ def _build_tf_config(self):
182173
)
183174

184175
def _build_megatron_module(self):
185-
from verl.utils.megatron_utils import (
186-
McoreModuleWrapperConfig,
187-
make_megatron_module,
188-
)
176+
from verl.utils.megatron_utils import McoreModuleWrapperConfig, make_megatron_module
189177
from verl.utils.model import print_model_size
190178

191179
# TODO: add more cases
@@ -240,10 +228,7 @@ def _build_megatron_module(self):
240228
return module
241229

242230
def _build_optimizer(self):
243-
from verl.utils.megatron.optimizer import (
244-
get_megatron_optimizer,
245-
init_megatron_optim_config,
246-
)
231+
from verl.utils.megatron.optimizer import get_megatron_optimizer, init_megatron_optim_config
247232

248233
optim_config_megatron = init_megatron_optim_config(
249234
self.optimizer_config,
@@ -313,6 +298,7 @@ def initialize(self):
313298
use_checkpoint_opt_param_scheduler=self.optimizer_config.use_checkpoint_opt_param_scheduler,
314299
bridge=self.bridge,
315300
provider=self.provider,
301+
peft_cls=self.peft_cls,
316302
use_dist_checkpointing=self.engine_config.use_dist_checkpointing,
317303
)
318304

0 commit comments

Comments
 (0)