[BUG] Fix UlyssesSPAttentionHF.register_with_transformers() crash with PEFT models (#7737)
**Description**
This PR fixes a crash in
`UlyssesSPAttentionHF.register_with_transformers()` when a PEFT-wrapped
model (e.g., `PeftModel`) is passed as the `model_name_or_path`
argument.
**The Issue**
The function previously used an overly strict
`isinstance(model_name_or_path, PreTrainedModel)` check. Since PEFT
models do not subclass `PreTrainedModel` (though they forward to one),
the check would fail. The logic then fell through to the `else` block,
treating the model object as a string path and calling
`AutoConfig.from_pretrained(model_name_or_path)`, which immediately
raised a `TypeError` or `OSError`.
**Changes**
* Updated the logic to use duck-typing: if the input object has a
`.config` attribute, we treat it as a model and access the configuration
directly.
* Hugging Face string paths (Hub IDs or local paths) continue to be
handled by the fallback to `AutoConfig`.
**Validation**
Verified that:
1. PEFT-wrapped models now successfully register without crashing.
2. Standard `PreTrainedModel` objects still register correctly.
3. String paths successfully trigger `AutoConfig.from_pretrained` as
expected.
Fixes #7729
---------
Signed-off-by: Rakshit-gen <sisodiarakshit456@gmail.com>
Co-authored-by: Olatunji Ruwase <tunji.ruwase@snowflake.com>