Skip to content

Commit 8bd712d

Browse files
authored
[RFC] Qualcomm AI Engine Direct - RFC for LLMConfig ModelType (pytorch#20402)
### Summary This PR adds an RFC proposing a structural split of base.model_class (ModelType) in extension/llm/export/config/llm_config.py into two explicit fields ModelType currently mixes two kinds of identifiers with no documented rule - architecture families (llama3_2, where size comes from base.params/base.checkpoint) and concrete HF model ids (qwen2_5_0_5b, which drives auto-download via HUGGING_FACE_REPO_IDS). This leads to a split - Llama is size-agnostic in the enum while Qwen bakes the size in. The RFC proposes two new fields on BaseConfig: model_family: Optional[ModelFamily] - architecture (replaces the family-style ModelType values) model_id: Optional[str] - normalized HF model name, drives auto-download (replaces the concrete-id-style ModelType values) model_class becomes Optional[ModelType] = None and is retained for backward compatibility. Call sites that unconditionally call on model_class must be updated with a helper for resolution with model_id and model_family.
1 parent 02b38d6 commit 8bd712d

1 file changed

Lines changed: 119 additions & 0 deletions

File tree

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# RFC: Model naming consistency in `LlmConfig`
2+
3+
**Status:** **RFC**
4+
5+
**Author:** Mahesh Madhavan
6+
7+
**Last Update:** 2026-06-10
8+
9+
10+
## Scope
11+
12+
This RFC is scoped to the generic, backend-agnostic config in
13+
`extension/llm/export/config/llm_config.py` — specifically `BaseConfig` and the
14+
`ModelType` enum that backs `base.model_class`.
15+
16+
## Motivation
17+
18+
A single field, `base.model_class` (a `ModelType` enum), currently encodes **two
19+
different things at once**, inconsistently:
20+
21+
* **Architecture/family** — e.g. `llama3_2`.
22+
* **A concrete model id** — e.g. `qwen2_5_0_5b` (the normalized HuggingFace
23+
name, which also drives auto-download via `HUGGING_FACE_REPO_IDS`).
24+
* `static_llama` - this doesn't fall under either category, it's not a family or a specific model id.
25+
26+
27+
This RFC proposes **segregating the two types into explicit fields** so each
28+
has a single, clear meaning.
29+
30+
## Proposal: two fields
31+
32+
```diff
33+
@dataclass
34+
class BaseConfig:
35+
- model_class: ModelType = ModelType.llama3
36+
+ model_class: Optional[ModelType] = None
37+
+ model_family: Optional[ModelFamily] = None
38+
+ model_id: Optional[str] = None # concrete upstream HF id
39+
params: Optional[str] = None
40+
checkpoint: Optional[str] = None
41+
...
42+
```
43+
44+
### `model_family` — the architecture
45+
46+
* An enum of **architectures/versions only**: `llama2`, `llama3`, `llama3_1`,
47+
`llama3_2`, `llama3_2_vision`, `qwen2_5` etc.
48+
* **Optional.** When provided, this would require the checkpoint and params.
49+
50+
### `model_id` — the concrete-model id
51+
52+
* **Optional** string: the normalized upstream HuggingFace model name
53+
(`qwen2_5_0_5b`, `phi_4_mini`).
54+
55+
* When `checkpoint` is provided along with the `model_id`, download is skipped.
56+
57+
* When omitted, the `model_family` + `params` + `checkpoint` fully
58+
determine the export (today's model_class behavior).
59+
60+
### How the three weight/identity inputs relate
61+
62+
| Field | Meaning | Required | Example |
63+
|---|---|---|---|
64+
| `model_family` | which architecture/code path | optional | `llama3_2` |
65+
| `model_id` | which concrete HF model | optional | `qwen2_5_0_5b` |
66+
| `checkpoint` | explicit local weights (overrides `model_id` download) | optional | `/path/consolidated.pth` |
67+
| `params` | architecture dims | user-supplied | `/path/to/1b_config.json` |
68+
69+
70+
### `model_class` - existing field
71+
This will become optional - existing models will remain as-is, for backward compatibility
72+
73+
## How it works — examples
74+
75+
```yaml
76+
# Family + explicit local weights (today's Llama flow)
77+
base:
78+
model_family: llama3_2
79+
params: /path/to/1b_config.json
80+
checkpoint: /path/to/consolidated.00.pth
81+
82+
# Concrete id → auto-download the pinned HF checkpoint
83+
base:
84+
model_id: qwen2_5_0_5b # → Qwen/Qwen2.5-0.5B via HUGGING_FACE_REPO_IDS
85+
params: examples/models/qwen2_5/config/0_5b_config.json
86+
87+
# Concrete id + checkpoint override (use local weights, keep the id label)
88+
base:
89+
model_id: qwen2_5_0_5b
90+
checkpoint: /path/to/local.pth # overrides the download
91+
params: /path/to/0_5b_config.json
92+
```
93+
94+
The family alone is enough to export (with user `params`/`checkpoint`); `model_id`
95+
adds concrete identity and enables HF auto-download.
96+
97+
## Backward compatibility & migration
98+
99+
100+
* The `model_class` field can stay for backward compatibility, but we could eventually deprecate the `--model` arg.
101+
* `params`, `checkpoint`, and all other `BaseConfig` fields are unchanged.
102+
103+
## Affected code
104+
105+
* `extension/llm/export/config/llm_config.py` — `model_family` (new `ModelFamily` enum) + `model_id` (str)
106+
* `examples/models/llama/export_llama_lib.py` — read `model_family` for the
107+
code-path dispatch (`:1599`, `:674`) and `model_id` for the
108+
`HUGGING_FACE_REPO_IDS` lookup (`:672`).
109+
110+
## What we're asking for
111+
112+
1. **Agreement** on splitting `model_class` into `model_family` (architecture) +
113+
`model_id` (concrete HF id).
114+
115+
## Open questions
116+
* **Decision on `static_llama`** — under this split it is neither a family nor a
117+
model_id. It seems like this functionally behaves the same as llama3_2. Where should this live?
118+
119+
* Is the migration cost of a split justified, over just having an overloaded `ModelType`, and supporting both `model_family` and `model_id` through the existing `model_class`(`ModelType`)?

0 commit comments

Comments
 (0)