Skip to content

S3 Fix#294

Merged
zhenghh04 merged 15 commits into
mainfrom
s3_fix
May 29, 2025
Merged

S3 Fix#294
zhenghh04 merged 15 commits into
mainfrom
s3_fix

Conversation

@zhenghh04

@zhenghh04 zhenghh04 commented May 29, 2025

Copy link
Copy Markdown
Member

This is to merge the PR from #288 with recent main.

Fixed incompatibility between ksm and randomize tensor

annie-anna and others added 15 commits May 5, 2025 17:25
* configs (#284)

* docker: improve docker cache and remove sources (#287)

* Fixes for v2.0 benchmark (#289)

* Reorganized the code provided by YardenMa for O_DIRECT support with NPY and NPZ formats and pytorch (#286)

* Reorganized the code provided by YardenMa from PR #250 to follow the recommentations in #250 (review)

* Move parse_npy and parse_npz back out of NPZReaderODIRECT  and NPYReaderODirect class due to copy error

Fix some spelling errors in config.rst

* Updated NPZReaderODirect to be a derivative class of NPYReaderODirect to reduce code duplication and move the logic of accessing the dictionary key "x" for npz into NPZReaderODIRECT from ReaderFactory.

Updated NPZReaderODirect and NPYReaderODirect to remove the need to pass in a paser function and make referencing them in ReaderFactory similar to the other formats.

Update ci.yml to add a test for reader.odirect parameter under test-torch-loader-npz

* RAM optimisations for checkpointing (#283)

* Add KSM optimization (checkpoint)

Reduce memory usage by adding the MADVISE flag to tensor pages and
pausing for an arbitrary duration during initialization.

If KSM is enabled, this allows it time to coalesce virtual pages into
shared physical pages, resulting in significant reductions in RAM
watermark usage for write checkpoint operations. This optimization
does not apply to read operations.

* Reduce RAM Usage for checkpointing (zero1)

With zero1, only the first DP saves the model parameters.
There is no need to allocate these parameters on other DP.

The original RAM formula was:
ram = ((model_size/(TP*PP))+(optimizer_size/(TP*PP*DP)))*(TP*PP*DP)

With the patch, this simplifies to:
ram = model_size + optimizer_size
Which is equal to zero3 RAM usage.

The reduction becomes more significant as DP increases. For example, a
70B model with 8TP, 4PP, and 4DP requires 1300GB without the patch,
but only 910GB with it.

This is still not equivalent to zero3, since only the first DP saves
the model parameters.

* Move KSM config under checkpoint.ksm subtree

* Update config.rst for nested KSM checkpoint options

* Correct nested KSM config parsing and add test

* Add KSM checkpoint test in CI

* Chore

---------

Co-authored-by: Boris Glimcher <36732377+glimchb@users.noreply.github.com>
Co-authored-by: Johnu George <johnugeorge109@gmail.com>
Co-authored-by: Timothy Chau <162626440+timohty-chau@users.noreply.github.com>
Co-authored-by: LouisDDN <77112282+LouisDDN@users.noreply.github.com>
…PY and NPZ formats and pytorch (#286)

* Reorganized the code provided by YardenMa from PR #250 to follow the recommentations in #250 (review)

* Move parse_npy and parse_npz back out of NPZReaderODIRECT  and NPYReaderODirect class due to copy error

Fix some spelling errors in config.rst

* Updated NPZReaderODirect to be a derivative class of NPYReaderODirect to reduce code duplication and move the logic of accessing the dictionary key "x" for npz into NPZReaderODIRECT from ReaderFactory.

Updated NPZReaderODirect and NPYReaderODirect to remove the need to pass in a paser function and make referencing them in ReaderFactory similar to the other formats.

Update ci.yml to add a test for reader.odirect parameter under test-torch-loader-npz
* Add KSM optimization (checkpoint)

Reduce memory usage by adding the MADVISE flag to tensor pages and
pausing for an arbitrary duration during initialization.

If KSM is enabled, this allows it time to coalesce virtual pages into
shared physical pages, resulting in significant reductions in RAM
watermark usage for write checkpoint operations. This optimization
does not apply to read operations.

* Reduce RAM Usage for checkpointing (zero1)

With zero1, only the first DP saves the model parameters.
There is no need to allocate these parameters on other DP.

The original RAM formula was:
ram = ((model_size/(TP*PP))+(optimizer_size/(TP*PP*DP)))*(TP*PP*DP)

With the patch, this simplifies to:
ram = model_size + optimizer_size
Which is equal to zero3 RAM usage.

The reduction becomes more significant as DP increases. For example, a
70B model with 8TP, 4PP, and 4DP requires 1300GB without the patch,
but only 910GB with it.

This is still not equivalent to zero3, since only the first DP saves
the model parameters.

* Move KSM config under checkpoint.ksm subtree

* Update config.rst for nested KSM checkpoint options

* Correct nested KSM config parsing and add test

* Add KSM checkpoint test in CI

* Chore
* Randomize tensor data by default (checkpoint)

* Fix checkpoint: Correct TF int8/uint8 random tensor generation and update tests

* Update tests (checkpoint)

* Fix/chore tests for checkpoint
@zhenghh04 zhenghh04 merged commit c170ff8 into main May 29, 2025
13 of 19 checks passed
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.

6 participants