FlagOpen / FlagScale

FlagScale is a large model toolkit based on open-sourced projects.
Other
132 stars 40 forks source link

[NewFeature] Support Patch mechanism #170

Closed shenzhu1993 closed 1 month ago

shenzhu1993 commented 1 month ago

This is a brand-new patch mechanism aimed at helping manufacturers and users better utilize the FlagScale framework for training and inference.

1. homogeneous scenarios

  Under this mechanism, manufacturers use the tools provided by FlagScale to automatically adapt the code between the base commit-id and the current commit-id, generating a compliant patch, automatically commit the code.  The sample command is as follows:

        python patch/patch.py --device-type A_X100 --base-commit-id aaaa --current-commit-id bbbb

        --device-type:  Required. manufacturers name and hip mode 
        --base-commit-id: Required. commit id modified based on FlagScale
        --current-commit-id: not Required. the commit-id that want to  git commit, if it's None, the head commit id will be choosen.
 if manufacturers or user want to unpatch the code adapted, The sample command is as follows:

        python patch/unpatch.py --device-type A_X100 --commit-id aaaa --dir build

        --device-type:  Required. manufacturers name and hip mode 
        --commit-id: Required. the base-commit-id Under the FlagScale's hardwares directory, in the manufacturer's directory. This is the --base commit id you enter when using patch.py.
        --dir: not Required. directory used to store the adapted code. if it's None, The unpatch operation will be performed in the current directory.
 if you want to push the patch code,  Each commit overwrites the previous patch, so there will be only one patch file at a time. Therefore, we recommend using the following command for pushing:

        git push  --force  origin HEAD:main

Notice: If you have iterated development based on the same base_commit_id, you need to rebase to resolve conflicts before pushing (because the same patch file has been modified).

2. heterogeneous scenarios

  Heterogeneous scenarios are as simple as homogeneous scenarios. You only need to add the manufacturer's name to the --device-type option. The sample command is as follows:

       python patch/patch.py --device-type A_X100 B_Y100 --base-commit-id aaaa --current-commit-id bbbb

       --device-type:  Required. both manufacturers name and hip mode adapt to perform heterogeneous training or inference.
       --base-commit-id: Required. the commit-id that  git pull from FlagScale
       --current-commit-id: Required. the commit-id that manufacturers adapted
  The input parameters have the same meaning as in homogeneous scenarios. However, it is important to note that the manufacturer's name and base-commit-id must exist in patch/hetero.txt.The format in patch/hetero.txt is as follows:

       aaaa: A_X100  B_Y100
  if manufacturers or user want to unpatch the code adapted, The sample command is as follows:

      python patch/unpatch.py --device-type A_X100 B_Y100 --commit-id aaaa --dir build

        --device-type:  Required.manufacturers name and hip mode 
        --commit-id: Required. the base-commit-id Under the FlagScale's hardwares directory, in the manufacturer's directory
        --dir: Required. directory used to store the unpatch code.