MCPcopy
hub / github.com/huggingface/trl / print_config_diff

Function print_config_diff

scripts/generate_tiny_models/_common.py:177–194  ·  view source on GitHub ↗

Print the flat, recursive diff between the reference Hub config and the tiny-model config.

(reference_id, model)

Source from the content-addressed store, hash-verified

175
176
177def 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
197def _parse_args():

Calls 2

_flattenFunction · 0.85
from_pretrainedMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…