FlagOpen / FlagScale

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

[NewFeature] Support Patch mechanism #174

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:

        cd FlagScale
        python tools/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:

        cd FlagScale
        python tools/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 may need to resolve conflicts before pushing, because the same patch file has been modified. We recommend using rebase to resolve them.

  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:

       cd FlagScale
       python tools/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: Not required. The commit-id that want to  git commit, if it's None, the head commit id will be choosen.

    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:

      cd FlagScale
      python tools/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.