[Dev] Add more tests for LayerwiseDistOpt with dist_ckpt - #2132
Conversation
…factor` Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test 669a16c |
|
/ok to test 04154c8 |
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test 6e4c888 |
|
/ok to test 267b06b |
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test 7057451 |
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test aaf7235 |
|
@BoxiangW looks like we need to add "functional_tests" label in order to trigger that functional tests you added in this PR. |
|
/ok to test 669a16c |
@BoxiangW, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
skyw
left a comment
There was a problem hiding this comment.
This PR should not be merged.
- The title says it is only adding tests, but there a lot of code change including public API change. They should be spereate.
- Test is not thorough, i.e. it doesn't catch a know issue that load fail on empty state_dict.
- Plus some other improvement suggested.
|
|
||
| muon_extra_scale_factor: float = 1.0 | ||
| """Additional scale factor for the muon update.""" | ||
| muon_extra_scale_factor: float = 0.2 |
There was a problem hiding this comment.
FIX: Revert this change. Don't change this default scale factor.
ESPECIALLY not in a unrelated PR.
There was a problem hiding this comment.
Reverted, this was recommended by Mkail and we can change it in a separate PR then
| def inspect_types(x: Any, prefix: Tuple = (), indent: int = 4): | ||
| """Helper to print types of (nested) dict values.""" | ||
| print_indent = lambda: print(" " * indent * len(prefix), end="") | ||
| print_indent = lambda: print(" " * indent * len(prefix), end="") # pylint: disable=bad-builtin |
There was a problem hiding this comment.
too many inline disable. just disable it for the section.
# pylint: disable=bad-builtin
...
# pylint: enable=bad-builtinThere was a problem hiding this comment.
I'd suggest we just remove changes from this file(the only change is a comment). and thus we don't need to fix lint for it.
For that comment, I think it is ok for it to catch our empty list issue and we should fix it from layerwise side
| choices=['blockwise', 'duplicated', 'distributed'], | ||
| help='How to perform NS calculation for tensor model parallel weights') | ||
| group.add_argument('--muon-extra-scale-factor', type=float, default=1.0, | ||
| group.add_argument('--muon-extra-scale-factor', type=float, default=0.2, |
|
|
||
| if succeeded: | ||
| logger.info(f"Job succeeded with status: {job_dict["status"]}") | ||
| logger.info(f"Job succeeded with status: {job_dict['status']}") |
There was a problem hiding this comment.
revert meaningless format change, unless their is a new style guide?
There was a problem hiding this comment.
Yes, it was a pylint guide
There was a problem hiding this comment.
but lines above and below all use double quote?
| ) | ||
| assert total_params > 0, "No parameters found in optimizer" | ||
|
|
||
| @pytest.mark.parametrize('tp_pp', [(1, 2), (2, 1), (2, 2)]) |
There was a problem hiding this comment.
Fix: Bad variable grouping. should use TP and PP separately.
Same for all other tests.
There was a problem hiding this comment.
This is not applicable for all the cases, since we have 8GPU max, if we do
@pytest.mark.parametrize('tp', [2, 4])
@pytest.mark.parametrize('pp', [2, 4])
It will reach 16 GPUs in total
There was a problem hiding this comment.
you can skip test (with a message) if total number of GPU exceeded.
| try: | ||
| state_dict = load(load_sharded_sd, ckpt_dir) | ||
| optimizer_B.load_state_dict(state_dict) | ||
| except Exception: |
There was a problem hiding this comment.
Don't silently pass tests. Can skip the test if there is a known reason.
There was a problem hiding this comment.
Removed this special treatment
| optim_param_state_B = optimizer_B.state_dict() | ||
|
|
||
| # Test both param state dicts are equal | ||
| diffs = diff(optim_param_state_A, optim_param_state_B) |
There was a problem hiding this comment.
Try not to use self made diff function as testing metric, it mixes things together unnecessarily. e.g. a bug in diff could have very large blast radius because all tests depend on it become faulty.
Better to explicitly compare everything here.
There was a problem hiding this comment.
Added a similar but simpler explicitly checking in this file as a util function
| def inspect_types(x: Any, prefix: Tuple = (), indent: int = 4): | ||
| """Helper to print types of (nested) dict values.""" | ||
| print_indent = lambda: print(" " * indent * len(prefix), end="") | ||
| print_indent = lambda: print(" " * indent * len(prefix), end="") # pylint: disable=bad-builtin |
There was a problem hiding this comment.
I'd suggest we just remove changes from this file(the only change is a comment). and thus we don't need to fix lint for it.
For that comment, I think it is ok for it to catch our empty list issue and we should fix it from layerwise side
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test a6693fc |
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test 73e424b |
skyw
left a comment
There was a problem hiding this comment.
I mostly reviewed unit test part and suggested more improvement. LGTM overall.
I didn't review "functional" test as I don't exactly know what to expect there.
| ) | ||
| assert total_params > 0, "No parameters found in optimizer" | ||
|
|
||
| @pytest.mark.parametrize('tp_pp', [(1, 2), (2, 1), (2, 2)]) |
There was a problem hiding this comment.
you can skip test (with a message) if total number of GPU exceeded.
| pp = dp_size | ||
| tp = world_size // pp | ||
|
|
||
| if tp == 0: |
There was a problem hiding this comment.
Should check broadly whether world_size is divisible by pp.
|
/ok to test 896b2d7 |
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test b478987 |
|
Hi @BoxiangW , the golden values of this MR is not added, which cause the functional tests fail https://gitlab-master.nvidia.com/ADLR/megatron-lm/-/pipelines/38398052. |
What does this PR do ?
PR to main
Contribution process
flowchart LR A[Pre-checks] --> B[PR Tests] subgraph Code Review/Approval C1[Expert Review] --> C2[Final Review] end B --> C1 C2 --> D[Merge]Pre-checks
Core 0.8)Code review
The following process is enforced via the CODEOWNERS file for changes into
megatron/core. For changes outside ofmegatron/core, it is up to the PR author whether or not to tag the Final Reviewer team.For MRs into `main` branch
(Step 1): Add PR label
Expert Review(Step 2): Collect the expert reviewers reviews
Expert Reviewlabel when your PR is ready for review.Final Review might get declined if these requirements are not fulfilled.
(Step 3): Final Review
Final Reviewlabel(Optional Step 4): Cherry-pick into release branch
If this PR also needs to be merged into
core_r*release branches, after this PR has been merged, selectCherry-pickto open a new PR into the release branch.For MRs into `dev` branch
The proposed review process for `dev` branch is under active discussion.MRs are mergable after one approval by either
eharper@nvidia.comorzijiey@nvidia.com.Merging your PR
Any member of core-adlr and
core-nemowill be able to merge your PR.