Skip to content

Commit 0bff404

Browse files
committed
deploy: a71c1b6
1 parent af7e797 commit 0bff404

20 files changed

+4660
-1284
lines changed

_modules/functools.html

Lines changed: 1109 additions & 0 deletions
Large diffs are not rendered by default.

_modules/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
<div itemprop="articleBody">
8585

8686
<h1>All modules for which code is available</h1>
87-
<ul><li><a href="sqlalchemy/orm/attributes.html">sqlalchemy.orm.attributes</a></li>
87+
<ul><li><a href="functools.html">functools</a></li>
88+
<li><a href="sqlalchemy/orm/attributes.html">sqlalchemy.orm.attributes</a></li>
8889
<li><a href="sqlalchemy/orm/decl_api.html">sqlalchemy.orm.decl_api</a></li>
8990
<li><a href="sqlalchemy/orm/decl_base.html">sqlalchemy.orm.decl_base</a></li>
9091
<li><a href="sqlalchemy/orm/instrumentation.html">sqlalchemy.orm.instrumentation</a></li>
@@ -123,6 +124,10 @@ <h1>All modules for which code is available</h1>
123124
<li><a href="trinity/explorer/runner_pool.html">trinity.explorer.runner_pool</a></li>
124125
<li><a href="trinity/explorer/workflow_runner.html">trinity.explorer.workflow_runner</a></li>
125126
<li><a href="trinity/manager/config_manager.html">trinity.manager.config_manager</a></li>
127+
<li><a href="trinity/manager/config_registry/config_registry.html">trinity.manager.config_registry.config_registry</a></li>
128+
<li><a href="trinity/manager/config_registry/explorer_config_manager.html">trinity.manager.config_registry.explorer_config_manager</a></li>
129+
<li><a href="trinity/manager/config_registry/model_config_manager.html">trinity.manager.config_registry.model_config_manager</a></li>
130+
<li><a href="trinity/manager/config_registry/trainer_config_manager.html">trinity.manager.config_registry.trainer_config_manager</a></li>
126131
<li><a href="trinity/manager/manager.html">trinity.manager.manager</a></li>
127132
<li><a href="trinity/trainer/trainer.html">trinity.trainer.trainer</a></li>
128133
<li><a href="trinity/trainer/verl/core_algos.html">trinity.trainer.verl.core_algos</a></li>

_modules/trinity/manager/config_manager.html

Lines changed: 200 additions & 1267 deletions
Large diffs are not rendered by default.

_modules/trinity/manager/config_registry/config_registry.html

Lines changed: 350 additions & 0 deletions
Large diffs are not rendered by default.

_modules/trinity/manager/config_registry/explorer_config_manager.html

Lines changed: 418 additions & 0 deletions
Large diffs are not rendered by default.

_modules/trinity/manager/config_registry/model_config_manager.html

Lines changed: 329 additions & 0 deletions
Large diffs are not rendered by default.

_modules/trinity/manager/config_registry/trainer_config_manager.html

Lines changed: 573 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
trinity.manager.config_registry
2+
===============================
3+
Submodules
4+
----------
5+
6+
trinity.manager.config\_registry.buffer\_config\_manager module
7+
---------------------------------------------------------------
8+
9+
.. automodule:: trinity.manager.config_registry.buffer_config_manager
10+
:members:
11+
:undoc-members:
12+
:show-inheritance:
13+
14+
trinity.manager.config\_registry.config\_registry module
15+
--------------------------------------------------------
16+
17+
.. automodule:: trinity.manager.config_registry.config_registry
18+
:members:
19+
:undoc-members:
20+
:show-inheritance:
21+
22+
trinity.manager.config\_registry.explorer\_config\_manager module
23+
-----------------------------------------------------------------
24+
25+
.. automodule:: trinity.manager.config_registry.explorer_config_manager
26+
:members:
27+
:undoc-members:
28+
:show-inheritance:
29+
30+
trinity.manager.config\_registry.model\_config\_manager module
31+
--------------------------------------------------------------
32+
33+
.. automodule:: trinity.manager.config_registry.model_config_manager
34+
:members:
35+
:undoc-members:
36+
:show-inheritance:
37+
38+
trinity.manager.config\_registry.trainer\_config\_manager module
39+
----------------------------------------------------------------
40+
41+
.. automodule:: trinity.manager.config_registry.trainer_config_manager
42+
:members:
43+
:undoc-members:
44+
:show-inheritance:
45+
46+
Module contents
47+
---------------
48+
49+
.. automodule:: trinity.manager.config_registry
50+
:members:
51+
:undoc-members:
52+
:show-inheritance:

_sources/build_api/trinity.manager.rst.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
trinity.manager
22
===============
3+
Subpackages
4+
-----------
5+
6+
.. toctree::
7+
:maxdepth: 4
8+
9+
trinity.manager.config_registry
10+
311
Submodules
412
----------
513

_sources/tutorial/trinity_programming_guide.md.txt

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,126 @@ trinity run --config <your_yaml_file>
286286

287287
---
288288

289+
## Adding New Config Entries for the Config Generator (Advanced)
290+
291+
### Step 0: Understanding Streamlit
292+
293+
Before adding new parameters to the Config Generator page, it is essential to familiarize yourself with the relevant API and mechanisms of [Streamlit](https://docs.streamlit.io/develop/api-reference). This project primarily utilizes various input components from Streamlit and employs `st.session_state` to store user-input parameters.
294+
295+
### Step 1: Implement New Config Entries
296+
297+
To illustrate the process of creating a new parameter setting for the Config Generator page, we will use `train_batch_size` as an example.
298+
299+
1. Determine the appropriate scope for the parameter. Currently, parameters are categorized into four files:
300+
- `trinity/manager/config_registry/buffer_config_manager.py`
301+
- `trinity/manager/config_registry/explorer_config_manager.py`
302+
- `trinity/manager/config_registry/model_config_manager.py`
303+
- `trinity/manager/config_registry/trainer_config_manager.py`
304+
305+
In this case, `train_batch_size` should be placed in the `buffer_config_manager.py` file.
306+
307+
2. Create a parameter setting function using Streamlit. The function name must follow the convention of starting with 'set_', and the remainder of the name becomes the config name.
308+
309+
3. Decorate the parameter setting function with the `CONFIG_GENERATORS.register_config` decorator. This decorator requires the following information:
310+
- Default value of the parameter
311+
- Visibility condition (if applicable)
312+
- Additional config parameters (if needed)
313+
314+
```{note}
315+
The `CONFIG_GENERATORS.register_config` decorator automatically passes `key=config_name` as an argument to the registered configuration function. Ensure that your function accepts this keyword argument.
316+
```
317+
318+
For `train_batch_size`, we will use the following settings:
319+
- Default value: 96
320+
- Visibility condition: `lambda: st.session_state["trainer_gpu_num"] > 0`
321+
- Additional config: `{"_train_batch_size_per_gpu": 16}`
322+
323+
324+
Here's the complete code for the `train_batch_size` parameter:
325+
326+
```python
327+
@CONFIG_GENERATORS.register_config(
328+
default_value=96,
329+
visible=lambda: st.session_state["trainer_gpu_num"] > 0,
330+
other_configs={"_train_batch_size_per_gpu": 16},
331+
)
332+
def set_train_batch_size(**kwargs):
333+
key = kwargs.get("key")
334+
trainer_gpu_num = st.session_state["trainer_gpu_num"]
335+
st.session_state[key] = (
336+
st.session_state["_train_batch_size_per_gpu"] * st.session_state["trainer_gpu_num"]
337+
)
338+
339+
def on_change():
340+
st.session_state["_train_batch_size_per_gpu"] = max(
341+
st.session_state[key] // st.session_state["trainer_gpu_num"], 1
342+
)
343+
344+
st.number_input(
345+
"Train Batch Size",
346+
min_value=trainer_gpu_num,
347+
step=trainer_gpu_num,
348+
help=_str_for_train_batch_size(),
349+
on_change=on_change,
350+
**kwargs,
351+
)
352+
```
353+
354+
If the parameter requires validation, create a check function. For `train_batch_size`, we need to ensure it is divisible by `trainer_gpu_num`. If not, a warning should be displayed, and the parameter should be added to `unfinished_fields`.
355+
356+
Decorate the check function with the `CONFIG_GENERATORS.register_check` decorator:
357+
358+
```python
359+
@CONFIG_GENERATORS.register_check()
360+
def check_train_batch_size(unfinished_fields: set, key: str):
361+
if st.session_state[key] % st.session_state["trainer_gpu_num"] != 0:
362+
unfinished_fields.add(key)
363+
st.warning(_str_for_train_batch_size())
364+
```
365+
366+
```{note}
367+
The `CONFIG_GENERATORS.register_check` decorator automatically receives `key=config_name` and `unfinished_fields=self.unfinished_fields` as arguments. Ensure your function accepts these keyword arguments.
368+
```
369+
370+
### Step 2: Integrating New Parameters into `config_manager.py`
371+
372+
To successfully integrate new parameters into the `config_manager.py` file, please adhere to the following procedure:
373+
374+
1. Parameter Categorization:
375+
Determine the appropriate section for the new parameter based on its functionality. The config generator page is structured into two primary modes:
376+
- Beginner Mode: Comprises "Essential Configs" and "Important Configs" sections.
377+
- Expert Mode: Includes "Model", "Buffer", "Explorer and Synchronizer", and "Trainer" sections.
378+
379+
2. Parameter Addition:
380+
Incorporate the new parameter into the relevant section using the `self.get_configs` method within the `ConfigManager` class.
381+
382+
Example:
383+
```python
384+
class ConfigManager:
385+
def _expert_buffer_part(self):
386+
self.get_configs("total_epochs", "train_batch_size")
387+
```
388+
389+
3. YAML File Integration:
390+
Locate the appropriate position for the new parameter within the YAML file structure. This should be done in the `generate_config` function and its associated sub-functions.
391+
392+
4. Parameter Value Assignment:
393+
Utilize `st.session_state` to retrieve the parameter value from the config generator page and assign it to the corresponding field in the YAML.
394+
395+
Example:
396+
```python
397+
class ConfigManager:
398+
def _gen_buffer_config(self):
399+
buffer_config = {
400+
"batch_size": st.session_state["train_batch_size"],
401+
# Additional configuration parameters
402+
}
403+
```
404+
405+
By meticulously following these steps, you can ensure that new parameters are successfully added to the Config Generator page and properly integrated into the configuration system. This process maintains the integrity and functionality of the configuration management framework.
406+
407+
---
408+
289409
## Check Code Style
290410

291411
Before submitting the code, make sure it passes the code style check. Follow these steps:

0 commit comments

Comments
 (0)