Skip to content

fix(adapter/nemo): safely call maybe_finalize_save_checkpoint in on_train_end - #104

Merged
kkkapu merged 4 commits into
mainfrom
fix3
Apr 30, 2026
Merged

fix(adapter/nemo): safely call maybe_finalize_save_checkpoint in on_train_end#104
kkkapu merged 4 commits into
mainfrom
fix3

Conversation

@kkkapu

@kkkapu kkkapu commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

When synchronous checkpoint saving is used (ckpt_async_save=False), the underlying checkpoint_io is the base MLFlashpointCheckpointIO class, which does not possess the maybe_finalize_save_checkpoint method. This method is specifically provided by the async wrapper MLFlashpointAsyncFinalizableCheckpointIO.

Previously, the on_train_end callback unconditionally called this method, leading to an AttributeError and causing unsuccessfull checkpointing.

Change-Id: I5e9bbf698b8ac5137f7ab3a6a723ac1e7cd3c085

…rain_end

When synchronous checkpoint saving is used (`ckpt_async_save=False`),
the underlying `checkpoint_io` is the base `MLFlashpointCheckpointIO`
class, which does not possess the `maybe_finalize_save_checkpoint`
method. This method is specifically provided by the async wrapper
`MLFlashpointAsyncFinalizableCheckpointIO`.

Previously, the `on_train_end` callback unconditionally called this
method, leading to an `AttributeError` and causing unsuccessfull checkpointing.

Change-Id: I5e9bbf698b8ac5137f7ab3a6a723ac1e7cd3c085
@kkkapu
kkkapu requested review from Leahlijuan and g-husam and removed request for g-husam April 23, 2026 20:37
Comment thread src/ml_flashpoint/adapter/nemo/checkpoint_callback.py Outdated
@kkkapu
kkkapu requested a review from g-husam April 24, 2026 20:02
Comment thread tests/adapter/nemo/test_checkpoint_callback.py Outdated
Comment thread tests/adapter/nemo/test_checkpoint_callback.py
Change-Id: Id24bf94613dd567645fe3c2bb31f1291468e1011
Change-Id: Iaaa84c8d96c923ad3c6254e102ebe7b0422a5a73
mock_checkpoint_io = mocker.MagicMock()

# Remove the async-specific method to simulate a synchronous CheckpointIO instance.
del mock_checkpoint_io.maybe_finalize_save_checkpoint

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont think this represents sync saving correctly? Should just use MLFlashpointCheckpointIO directly (not wrapped in AsyncFinalizable) right?

I would actually expect this test to fail now in its current form

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why it doesnt fail, its testing a mock impl, not the actual code, which isnt of type AsyncFinalizableCheckpointIO. Make sure to use a real MLFlashpointCHeckpointIO - this test is not actually validating our logic, its just using a mock that gets ignored

Change-Id: I5650ff22f3c0c4ce41a56eaab3990c788ee09a4a
@github-actions

Copy link
Copy Markdown

Python Code Coverage Summary

Code Coverage

Package Line Rate Branch Rate Health
src.ml_flashpoint 100% 100%
src.ml_flashpoint.adapter 100% 100%
src.ml_flashpoint.adapter.megatron 97% 95%
src.ml_flashpoint.adapter.nemo 98% 93%
src.ml_flashpoint.adapter.pytorch 99% 92%
src.ml_flashpoint.checkpoint_object_manager 93% 93%
src.ml_flashpoint.core 95% 92%
src.ml_flashpoint.replication 81% 81%
Summary 95% (2392 / 2523) 92% (573 / 626)

Minimum allowed line rate is 90%

@github-actions

Copy link
Copy Markdown

C++ Code Coverage Summary

Code Coverage

Package Line Rate Branch Rate Health
src.ml_flashpoint.checkpoint_object_manager.buffer_object 93% 54%
src.ml_flashpoint.replication.transfer_service 79% 40%
Summary 81% (893 / 1097) 43% (665 / 1539)

Minimum allowed line rate is 80%

@kkkapu
kkkapu requested a review from g-husam April 30, 2026 20:57
@kkkapu
kkkapu merged commit 8962c0b into main Apr 30, 2026
7 checks passed
@kkkapu
kkkapu deleted the fix3 branch April 30, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants