You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- For **numerical threshold** knobs, suffix with `_limit`, `_size`, `_count`, `_len_` or `_ratio`
56
+
Examples: `max_seq_len`, `prefill_batch_size`
57
+
58
+
**Avoid Redundant Prefixes**
59
+
60
+
Example (in `MoeConfig`):
61
+
62
+
✅ **Good**: `backend`
63
+
❌ **Bad**: `moe_backend` (redundant since it's already in `MoeConfig`)
64
+
65
+
**Use Specific Names for Narrow Scenarios**
66
+
67
+
When adding knobs for specific use cases, make the name convey the restriction clearly via a prefix. It's acceptable to rename later when the knob becomes more generic or is moved into a dedicated config.
68
+
69
+
Example (argument to the LLM class):
70
+
71
+
✅ **Good**: `rope_scaling_factor` → clearly indicates it's for RoPE
72
+
❌ **Bad**: `scaling_factor` → too generic and prone to misuse
73
+
74
+
### 2. Hierarchical Configuration
75
+
76
+
Organize complex or hierarchical arguments into **dedicated configuration dataclasses** with intuitive and consistent naming.
The dataclass name should represent a coherent functional unit, not an arbitrary grouping
85
+
86
+
-**Avoid over-nesting**
87
+
Use only one level of configuration hierarchy whenever possible (e.g., `LlmArgs → ParallelConfig`) to balance readability and modularity
88
+
89
+
### 3. Prefer `LlmArgs` Over Environment Variables
90
+
91
+
`LlmArgs` is the central place for all configuration knobs. It integrates with our infrastructure to ensure:
92
+
93
+
-**API Stability**
94
+
- Protects committed (stable) APIs
95
+
- GitHub reviewer committee oversees API stability
96
+
97
+
-**API Status Registration**
98
+
- Uncommitted (unstable) APIs must be marked as `"prototype"` or `"beta"`
99
+
- API statuses are displayed in the documentation
100
+
101
+
-**API Documentation**
102
+
- Each knob uses a `Field` with a description
103
+
- Automatically rendered in public documentation
104
+
105
+
> Managing knobs in `LlmArgs` remains **scalable and maintainable** thanks to our existing infrastructure and review processes.
106
+
107
+
**Drawbacks of Environment Variables:**
108
+
109
+
- Dispersed across the codebase
110
+
- Lack documentation and discoverability
111
+
- Pose challenges for testing and validation
112
+
113
+
**Guidelines for Adding Knobs:**
114
+
115
+
- ✅ Add clear, descriptive documentation for each field
116
+
- ✅ It's fine to add temporary knobs and refine them later
117
+
- ⚠️ Always mark temporary knobs as `"prototype"` if not stable yet
118
+
- ✅ Refactor prototype knobs as they mature, promote them to "beta" or "stable".
119
+
39
120
## Modifying LLM Constructor Arguments
40
121
41
122
The LLM class accepts numerous configuration parameters for models, runtime, and other components. These are managed through a Pydantic dataclass called `LlmArgs`.
0 commit comments