Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Self-Rewarding Algorithm with TRT Support #321
base: main
Are you sure you want to change the base?
feat: Self-Rewarding Algorithm with TRT Support #321
Changes from 250 commits
d81caef
92c19f6
7088f54
472a56c
032bf35
d5f55f5
c7cdca1
04d02c8
56ccacf
d23865f
3c21c81
2c99dcb
9e8526d
c1daeb9
e16c357
410eaf5
e405432
07cfa67
b2dfee0
63cd6b3
6901348
74a0bb1
b6a05fd
db2701b
8dd5c59
b5d6f88
5464827
00e4298
fe6864b
80579ec
f81f55a
4a034f4
66b5a54
7841381
1779c51
e357ef9
6b606e8
a669837
ada5f45
393acc6
b6a4d59
977e6e7
621718d
6109b8b
866c22b
02aa2b8
e6f27c5
c689d2a
cd4aaa5
993e358
28fcaf3
ef347e5
752d0bd
78e6536
4de3eeb
8a39881
666e969
3bec1bc
3e7ca5f
12a0aae
3956b6d
e090663
af83947
cc03b76
605bda1
b3dedfd
9fb90ff
bf62bcc
aea50ad
0a9416e
41ffeb5
e3d85bf
1225041
5315fc5
9c6141b
2cef93e
f5bd8c5
cbd7095
c72e4c1
220cf17
1ed3c46
aa4249d
22615b7
95a9507
0fdb124
031287c
fa37930
c83a98d
a9f722a
15460d2
f6c09ea
1d85152
b3078c5
1eb0823
6203e90
e51c45f
1b220f1
0815b56
8d75cbf
ab4c549
82fb3a1
12f85d2
f90f4d6
527557d
fe9d288
f3124d3
efadcae
35a2895
4487932
7e7f27b
e9c7b39
c6f6da4
ebb69f4
2775e81
fe0399f
ffa253f
7ca9e34
8181168
4d0853d
ec548b8
ce7a07f
bb2fc48
606f690
f48dc29
708bc24
48ad685
d053475
0b4a92d
b72a5ec
984acaa
c11e1d7
14a9926
7c2fc3e
fe02867
02ad2fa
24c53be
8a25e5e
24f138a
9c72c53
5ed9cd8
8b6627a
56032c8
1e17f8b
e0a94d0
280ad36
3af712d
835b3b3
2b95331
261269a
83ba660
f3912e7
09d2783
5105ed9
a2bf8a0
d9d45d6
f00d09e
830e599
09c357c
c41cc08
ab8c97b
92fec51
7f7d4f9
395cf04
3a8da14
4174248
36d8ab4
82e8793
7506be0
c8b88c3
1d1f051
aae1cd3
b4afcf6
dab8c61
5651e20
ff3bc1c
aadc662
314c217
2fdb5b0
31f4ba3
7dd511c
11d22e8
de8dda8
4f81524
723f55f
acd4d07
a249a44
ce687ed
005702b
a35e359
fc1def7
eab62af
8805db5
fb61b86
a7817b3
71029d9
9051695
35f8ee4
ab2d3ce
294afcd
c465f30
2092084
99c7bcd
4e435f7
3d429fb
b460a14
780e8ab
cc487fb
83e830a
5b7aae3
a1f9620
01aced0
224de3d
82ff16d
c608520
e4d36b6
34e4994
4314347
92c6ee3
260eb90
f93acab
e4b1712
e18d2fc
d646801
de7b8aa
449bee7
0e35eb4
7178c88
b93549f
0b04388
0b06d95
a5c9614
cf58ead
bbaf99f
139d739
1794fc1
5e163ef
deb3604
58a9c4c
d895625
f4179c5
8239056
8925c02
6365f73
8c9d4f7
cfe86fa
18f17f5
d3e55ee
bfc81c6
8fa17bb
24e857a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise heading for SEO
Model Generation with Data Parallelism and TensorRT (TRT)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest a revision to the introductory text, including the purpose and other copyedits
This tutorial demonstrates efficient model generation using NeMo Framework and the NeMo-Aligner codebase. It shows how to set up a 2B GPT model with a sequence length of 4096, available on
Hugging Face <https://huggingface.co/nvidia/GPT-2B-001>
__, and applies to other models like Llama.The tutorial covers obtaining and preparing a pretrained model, configuring parameters, and running the generation process. It highlights using aligned models for better outputs and provides steps for terminal and Slurm execution, ensuring efficient data parallelism and handling TransformerEngine issues. All NeMo-Aligner algorithms work with any GPT-based model from Megatron Core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix capitalization and change procedural heading to an imperative verb
Obtain a Pretrained Model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested revision and fix grammar
To get started, we need an aligned model for generating responses. We recommend two models: 2B GPT and LLaMa2 7B. While the tutorial works with either, we will use the smaller 2B model for demonstration purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a period
#. Get the 2B checkpoint via
wget https://huggingface.co/nvidia/GPT-2B-001/resolve/main/GPT-2B-001_bf16_tp1.nemo
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a period, fix capitalization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise (remove And then) and add definite article "the"
#. Run the script to convert from the old NeMo checkpoint to the Megatron-Core checkpoint. The script is located
here <https://github.com/NVIDIA/NeMo/blob/86b198ff93438d454f9c7f3550bcfb7d4e59feab/scripts/nlp_language_modeling/convert_nemo_gpt_to_mcore.py>
__.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a colon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comma
After these steps, you should have a file,
mcore_gpt.nemo
, to use in NeMo-Aligner.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise
Mcore models utilize TransformerEngine as a backend to find efficient kernels. However, depending on your GPU, it may not always succeed. If you encounter errors related to kernel finding, set these variables at the top of your script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise
Additionally, TransformerEngine is non-deterministic by default. This means that running the same generation with identical parameters multiple times will yield different results, which is not ideal for generation consistency. Fortunately, TransformerEngine provides a flag that you can set to ensure deterministic generation runs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix capitalization and punctuation
Aligned Model vs. Foundational (Base) Model for Generation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested revision to break up long sentences and fix punctuation
Generation can be executed on either base or foundational models. These are models that have been trained solely on autoregressive language prediction tasks and not on instruction-following tasks. Alternatively, you can run generation on models that have been aligned with instruction-based or preference-based datasets, similar to DPO/PPO. Both types of models are capable of performing generation. However, you will achieve significantly higher quality responses (generations) from an aligned model. Therefore, we highly recommend using an aligned model for generation if you want high-quality responses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise and use full name/capitalization for NeMo-Aligner and NeMo
The input files for generation in NeMo-Aligner use the same format of .jsonl files as those used by SFT in NeMo and NeMo-Aligner. Please see the data formatting section of SFT to understand the necessary data format for self-rewarding training :ref:SFT guide . Note that NeMo-Aligner generation does not support the use of mmap or binary files, only .jsonl files in SFT format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change procedural heading to imperative verb and add hyphen
Run Generation in NeMo-Aligner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise
After processing your data into the correct format, you can begin generation. Start with a pretrained or aligned model. For this section, we'll use the aligned model from the previous section to generate the content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix punctuation
For the purposes of the following sections, we'll assume your generation .jsonl file is located in
/path/to/generation_sft_format.jsonl
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a period
model.generation.num_responses_to_gen
- controls how many responses you want the model to generate per prompt.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise and use full name/capitalization for NeMo-Aligner and NeMo
The following block shows the standard NeMo sampling params for generating responses, which are the same as we use across all NeMo and NeMo-Aligner codebases:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix subject-verb agreement
Finally, we have the TRT parameters, which allow for faster TRTLLM-based response generation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested revision
.. note::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revise
With your data prepared, you can now run the generation. We demonstrate two techniques below: one using command-line inputs directly, and another demonstrating the use of SLURM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested revision
The output file containing the responses will be located in
${RESULTS_DIR}/generations/generations.jsonl
. All responses will be stored in this file as they are generated. If your generation process abruptly terminates, it will resume where it left off once restarted. Upon completion, all responses will be located in this file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested revision
You do not need the step and
consumed_samples
fields. However, they are included to ensure that the process can accurately resume if it is unexpectedly interrupted during a generation run.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested revision
Please note that the responses will include all raw tokens generated by the model. This includes special headers, turn starts/ends, and BOS/EOS tokens. To obtain a "clean" output, you will need to filter these out through a post-processing step, which is not currently provided.