-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[CI] feat: add mypy to pre-commit
#2614
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
Conversation
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.
Code Review
This pull request introduces mypy for static type checking, initially enabling it for the verl.trainer.ppo.core_algos module. The changes include adding the mypy pre-commit hook, configuring it in pyproject.toml, and fixing type errors in the target module. My review focuses on a critical issue with the pre-commit configuration that will break the CI, and a high-severity issue regarding the use of typing.Any which undermines the goal of adding static type analysis. Addressing these will ensure the CI works as expected and improve the long-term maintainability of the typed code.
|
@frrad CI is good. I can help to merge if haibin approve. |
|
copying comment here from Lark
|
|
Let's change it to Optional AlgoConfig|DictConfig] |
|
please take another look |
|
In cc2972c I have added an additional path to the mypy whitelist which make it necessary to change edit: originally I had linked the wrong commit in this message |
|
I think this PR is almost done. Let me help on the merge! @frrad |
verl/trainer/config/algorithm.py
Outdated
| policy_loss: Optional[PolicyLossConfig] = field(default_factory=PolicyLossConfig) | ||
| clip_ratio_high: float = 0.2 | ||
| clip_ratio_low: float = 0.2 | ||
| clip_ratio: float = 0.2 |
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.
There are two issues. One is that verl already has actor_rollout_ref.actor.policy_loss and actor_rollout_ref.actor.clip_ratio_high/low, duplicating them without changing existing example script would be confusing.
Also restructuring algo config & actor config is not a high priority for now and moving them around and breaking others' recipes may lead to bad experience. If we do want to make breaking changes, we usually make announcement for deprecations, keep it for one version before breaking it..
I do not think it's necessary to couple mypy setup with breaking changes ..
This reverts commit cc2972c.
|
I have reverted that commit. |
…ated fixes"" This reverts commit 1bc626c.
|
this is probably a better fix. please take another look. |
|
@frrad Let me merge it after the CI |
* origin/mindspeed: (39 commits) [perf] feat: add optional role selection in discrete mode for NPU Profiler (volcengine#2750) [rollout] feat: remove chat scheduler (volcengine#2725) [trainer] refactor: Make sure to keep the type checking (volcengine#2634) [doc] style: change resize handle from gradient to plain color (volcengine#2746) [CI] feat: add `mypy` to pre-commit (volcengine#2614) [megatron] feat: a bunch of optimzation on vram, sequence packing (volcengine#2678) [docker] feat: upgrade to torch 2.7, sglang 0.4.8 (volcengine#2617) [doc] feat: add resizable sidebar and improve layout (volcengine#2577) [ci] fix: release ascend test time, fix one step off-policy CI (volcengine#2731) [recipe] chore: add retool training script (volcengine#2732) [ci] fix: checkpoint_convertor ci miss a hf model download (volcengine#2730) [doc] feat: Add agent-lightning in the list of "awesome works using verl (volcengine#2726) [tool] fix: geo3k create return str instead of tuple (volcengine#2714) [megatron] fix: resolve backward propagation error in megatron_actor due to shared logits tensor in-place modification (volcengine#2484) [misc] chore: bump main branch version to v0.5.0.dev (volcengine#2718) [sglang] fix: Adding strict naming sanity for sglang (volcengine#2719) [ray] feat: RayWorkerGroup support set worker env (volcengine#2685) [ci] test: add CriticWorker unit test, make some util CPU friendly (volcengine#2717) [cfg] refactor: add ActorConfig, EngineConfig, and ActorWorker unit test, refactor validation code (volcengine#2621) [misc] chore: bump version to v0.5.0 (volcengine#2716) ...
What does this PR do?
Adds
mypytypechecking to pre-commit. Only one module is whitelisted and it is configured to be very permissive.Test
this is a CI / testing change
API and Usage Example
# Add code snippet or script demonstrating how to use thisDesign & Code Changes
Checklist Before Submitting
ci-requestchannel in theverlSlack workspace.