Print the flat, recursive diff between the reference Hub config and the tiny-model config.
(reference_id, model)
| 175 | |
| 176 | |
| 177 | def print_config_diff(reference_id, model): |
| 178 | """Print the flat, recursive diff between the reference Hub config and the tiny-model config.""" |
| 179 | reference_config = AutoConfig.from_pretrained(reference_id) |
| 180 | ref_flat = _flatten(reference_config.to_dict()) |
| 181 | tiny_flat = _flatten(model.config.to_dict()) |
| 182 | |
| 183 | keys = sorted(set(ref_flat) | set(tiny_flat)) |
| 184 | rows = [] |
| 185 | for k in keys: |
| 186 | if any(k == ig or k.endswith(f".{ig}") for ig in _DIFF_IGNORE): |
| 187 | continue |
| 188 | rv, tv = ref_flat.get(k, "<missing>"), tiny_flat.get(k, "<missing>") |
| 189 | if rv != tv: |
| 190 | rows.append((k, rv, tv)) |
| 191 | |
| 192 | print(f"[config_diff] {reference_id} vs tiny ({len(rows)} differences)") |
| 193 | for k, r, t in rows: |
| 194 | print(f" {k:48s} {str(r)[:34]:34s} → {str(t)[:34]}") |
| 195 | |
| 196 | |
| 197 | def _parse_args(): |
no test coverage detected
searching dependent graphs…