Getting Started with RBLN Profiler¶
This section outlines the basic steps for using the RBLN Profiler. The following example demonstrates how to get profiling data using a PyTorch BERT model from the RBLN Model Zoo.
Prerequisites¶
Before we start, please make sure you have installed the following pip packages in your system.
Note
RBLN profiler is a feature in rebel-compiler package. Therefore, it is installed when you install rebel-compiler
and you don't have to install RBLN profiler explicitly.
How to Extract Profiled Data¶
RBLN Profiler can extract profiling data from both rebel-compiler
and optimum-rbln
.
In this example, we will compile BERT-base, which has been trained for question answering. The model supports both rebel-compiler
(Option 1) and optimum-rbln
(Option 2) in the RBLN Model zoo, so we will handle how to extract profiling data in both options.
Option 1: Using rebel-compiler
¶
You can extract the profiling data in the following way with rebel-compiler
Compile Model¶
The BERT-base model can be compiled with the folowing command. When the model compilation is completed, you will find bert-base.rbln
file in the directory.
Activate RBLN Profiler¶
Profile the model by either setting the environment variable RBLN_PROFILER=1
while running inference, or by using the argument activate_profile=True
in rebel.Runtime
.
-
Using environment variable: set the environment variable
RBLN_PROFILER=1
to enable RBLN Profiler. -
Using RBLN Runtime API: set
activate_profiler=True
to activate RBLN Profiler.
Extract Profiled Data with Inference¶
-
Generally, you can obtain the profiling data without specifying any signature, as shown below:
-
To configure profiling for the various controls, we support scoped profiling methods as follows:
Option 2: Using optimum-rbln
¶
You can extract the profiling data in the following way with optimum-rbln
.
Compile Model¶
The BERT-base model from optimum-rbln
can be compiled with the following command. When the model compilation is completed, you will find bert-base-cased-squad2
directory.
Activate RBLN Profiler¶
Profile the model by either setting the environment variable RBLN_PROFILER=1
while running inference, or by using the argument activate_profile=True
in optimum-rbln
.
-
Using environment variable: set the environment variable
RBLN_PROFILER=1
to enable RBLN Profiler. -
Using optimum-rbln API: set
rbln_activate_profiler=True
to activate RBLN Profiler.
Extract Profiled Data with Inference¶
-
You can obtain the profiling data without specifying any signature:
-
optimum-rbln
API also support scoped profiling methods as shown below:
Check the Profiling Result¶
After running one of the above commands, you can see the profiling results as below:
RBLN Profiler Generation Status Report
shows all status information generated during the tracing and generation process of the RBLN profiler, displayed across three categories.
-
System Passes
: monitor general system issues, verify memory allocation status as well as the profiling data generated by the Command Processor. -
Compilation Passes
: verify and modify model information generated by the Compiler based on system constraints. -
Tracing Passes
: collect and verify profiling data from the Command Processor, conduct analysis, perform visualization preprocessing through data analysis, layout reorganization and structure transformation for Protocol Buffer file generation and serialization.
Note
If the RBLN Profiler Generation Status Report
consistently reports Failed
, please contact to support@rebellions.ai.
- Extracted Filename
Multi Stream
(Full log) :rbln_{date}_{time}.pb
- This file represents all tracing information from all inferences within a single profiler instance in one plot, recorded in a single
*.pb
file.
- This file represents all tracing information from all inferences within a single profiler instance in one plot, recorded in a single
Single Stream
(Log by sequence):rbln_{date}_{time}_{sequence_index}.pb
- These files represents tracing information for a single module inference within a single profiler instance in one plot. Specifically,
*.pb
files are generated corresponding to the number of modules and their respective inference counts.
- These files represents tracing information for a single module inference within a single profiler instance in one plot. Specifically,
The generated *.pb
files can be visualized using Perfetto.