Skip to content

Add trust_remote_code support in model_registry.py and wire it through CI tests #482

Description

@BenjSz

Background

PR #478 adds an HF adapter for bharatgenai/Param-1-5B, a checkpoint that ships custom modeling code and therefore requires trust_remote_code=True at load time.

The review on that PR (#478 (review)) identified a blocker before it can be merged:

In order to merge this, we would need to add a mechanism that tags a specific entry in model_registry.py as needing trust_remote_code, and then either excludes this checkpoint from the CI tests or wires the parameter to model load in all the relevant tests.

What needs to be done

1. Tag entries in model_registry.py

Add a "trust_remote_code": True field to any registry entry whose checkpoint requires it, e.g.:

"param_1_5b": {
    "name": "BharatGen Param-1 5B",
    "path": "bharatgenai/Param-1-5B",
    "adapter": "hf_bharatgen.py",
    "size": "5b",
    "trust_remote_code": True,   # <-- new field
},

2. Thread the flag through all relevant tests

Anywhere that a registry entry is consumed to load a model in a test, read the trust_remote_code field and forward it to AutoSpyreModelForCausalLM.from_pretrained() (or the equivalent Auto class).
The two viable strategies are:

  • Wire it through — pass trust_remote_code=model_info.get("trust_remote_code") at every from_pretrained call site in the test suite.
  • Exclude from CI — skip parameterized test cases where trust_remote_code is True (similar to how is_gated entries are filtered via SPYRE_INCLUDE_GATED), e.g. a new SPYRE_INCLUDE_TRUST_REMOTE_CODE=1 guard.

Either approach (or a combination) unblocks merging PR #478 without bypassing trust_remote_code globally or hard-coding it inside the adapter.

Affected files (from PR #478)

  • tests/model_registry.py — registry entries need the new field
  • All test files that iterate over CAUSAL_LM_MODELS (or similar registries) and call from_pretrained
  • Potentially hf_adapters/hf_common.py / hf_adapters/auto_spyre_model.py if any plumbing is still needed (PR feat: Add hf adapter for https://huggingface.co/bharatgenai/Param-1-5B #478 has already added the trust_remote_code parameter to the AutoSpyreModel* classes and load_model_common)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions