Fix relative imports in modeling_laguna.py that break trust_remote_code loading

#5
by nikivdev - opened

Fixes the trust_remote_code loading failure reported in discussion #3.

modeling_laguna.py keeps two function-local in-tree relative imports inside LagunaModel.forward:

from ...cache_utils import DynamicCache
from ...masking_utils import create_causal_mask, create_sliding_window_causal_mask

Inside the transformers source tree these resolve to the package root, but as Hub custom code transformers' dynamic-module scanner (dynamic_module_utils.get_relative_imports) collects them as sibling snapshot files to fetch, and loading dies before the model class is even built:

FileNotFoundError: [Errno 2] No such file or directory: '.../snapshots/.../..cache_utils.py'

Repro: AutoModelForCausalLM.from_pretrained("poolside/Laguna-XS-2.1", trust_remote_code=True) on transformers 5.12.1. (vLLM is unaffected — it never runs the scanner.)

This PR rewrites the two lines to the absolute imports they resolved to in-tree; both modules are public transformers API, so behavior is identical. Verified locally: with this change the model loads and runs forward/backward (transformers 5.12.1, torch 2.12.1, bf16).

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment