Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
913c55b
updated loading in llama 2 demo to use transformer bridge
degenfabian Aug 18, 2025
c9bc71e
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Aug 20, 2025
3b42901
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Aug 22, 2025
52f7b8a
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Aug 26, 2025
20cc89c
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 4, 2025
8319cc2
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 5, 2025
e26da3d
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 6, 2025
95aa144
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 7, 2025
d5e1327
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 10, 2025
ea0f147
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 10, 2025
bd85cb6
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 12, 2025
c419c4f
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 12, 2025
a030fdf
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Sep 12, 2025
5dd19d1
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 10, 2025
23efa9a
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 13, 2025
65d501a
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 14, 2025
ef8951b
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 14, 2025
57fb25e
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 15, 2025
d6dc710
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 15, 2025
dd571c1
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 15, 2025
e595bab
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 16, 2025
0066317
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 16, 2025
b2af109
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 16, 2025
5bd42bf
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 16, 2025
5b588af
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 16, 2025
cbbdd0b
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 17, 2025
d7bc861
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Oct 23, 2025
7724966
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Nov 12, 2025
6332a9d
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Nov 12, 2025
34c6293
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Nov 12, 2025
77b150b
Merge remote-tracking branch 'origin/dev-3.x-folding' into llama_2_de…
bryce13950 Nov 20, 2025
c274596
Merge remote-tracking branch 'origin/dev-3.x' into llama_2_demo_trans…
bryce13950 Mar 23, 2026
d74733b
Merge remote-tracking branch 'origin/dev-3.x-canary' into llama_2_dem…
jlarson4 Apr 6, 2026
d288c49
Updating LLaMA quantized model
jlarson4 Apr 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ jobs:
# - "Head_Detector_Demo"
# - "Interactive_Neuroscope"
# - "LLaMA"
# - "LLaMA2_GPU_Quantized"
# - "LLaMA2_GPU_Quantized" # Requires quantization libs + too slow for CI timeout
- "Main_Demo"
# - "No_Position_Experiment"
- "Othello_GPT"
Expand Down
567 changes: 153 additions & 414 deletions demos/LLaMA2_GPU_Quantized.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"tabulate>=0.9.0",
]
jupyter=["ipywidgets>=8.1.1", "jupyterlab>=3.5.0"]
quantization=["bitsandbytes>=0.46.1", "optimum-quanto>=0.2.7"]

[tool.poetry.dependencies]
accelerate=">=0.23.0" # Needed for Llama Models
Expand Down
5 changes: 5 additions & 0 deletions transformer_lens/model_bridge/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def boot_transformers(
load_weights: bool = True,
trust_remote_code: bool = False,
model_class: Optional[type] = None,
hf_model: Optional[Any] = None,
) -> "TransformerBridge":
"""Boot a model from HuggingFace (alias for sources.transformers.boot).

Expand All @@ -162,6 +163,9 @@ def boot_transformers(
trust_remote_code: Whether to trust remote code for custom model architectures.
model_class: Optional HuggingFace model class to use instead of the default
auto-detected class (e.g., BertForNextSentencePrediction).
hf_model: Optional pre-loaded HuggingFace model to use instead of loading one. Useful
for models loaded with custom configurations (e.g., quantization via
BitsAndBytesConfig). When provided, load_weights is ignored.

Returns:
The bridge to the loaded model.
Expand All @@ -177,6 +181,7 @@ def boot_transformers(
load_weights=load_weights,
trust_remote_code=trust_remote_code,
model_class=model_class,
hf_model=hf_model,
)

@property
Expand Down
9 changes: 8 additions & 1 deletion transformer_lens/model_bridge/sources/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def boot(
load_weights: bool = True,
trust_remote_code: bool = False,
model_class: Any | None = None,
hf_model: Any | None = None,
) -> TransformerBridge:
"""Boot a model from HuggingFace.

Expand All @@ -283,6 +284,9 @@ def boot(
model_class: Optional HuggingFace model class to use instead of the default auto-detected
class. When the class name matches a key in SUPPORTED_ARCHITECTURES, the corresponding
adapter is selected automatically (e.g., BertForNextSentencePrediction).
hf_model: Optional pre-loaded HuggingFace model to use instead of loading one. Useful for
models loaded with custom configurations (e.g., quantization via BitsAndBytesConfig).
When provided, load_weights is ignored.

Returns:
The bridge to the loaded model.
Expand Down Expand Up @@ -368,7 +372,10 @@ def boot(
# Default to eager (required for output_attentions hooks)
model_kwargs["attn_implementation"] = "eager"
adapter.prepare_loading(model_name, model_kwargs)
if not load_weights:
if hf_model is not None:
# Use the pre-loaded model as-is (e.g., quantized models with custom device_map)
pass
elif not load_weights:
from_config_kwargs = {}
if trust_remote_code:
from_config_kwargs["trust_remote_code"] = True
Expand Down
23 changes: 10 additions & 13 deletions transformer_lens/supported_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,9 @@
"bigscience/bloom-3b": ["bloom-3b"],
"bigscience/bloom-560m": ["bloom-560m"],
"bigscience/bloom-7b1": ["bloom-7b1"],
"codellama/CodeLlama-7b-hf": ["CodeLlamallama-2-7b", "codellama/CodeLlama-7b-hf"],
"codellama/CodeLlama-7b-Instruct-hf": [
"CodeLlama-7b-instruct",
"codellama/CodeLlama-7b-Instruct-hf",
],
"codellama/CodeLlama-7b-Python-hf": ["CodeLlama-7b-python", "codellama/CodeLlama-7b-Python-hf"],
"codellama/CodeLlama-7b-hf": ["CodeLlamallama-2-7b"],
"codellama/CodeLlama-7b-Instruct-hf": ["CodeLlama-7b-instruct"],
"codellama/CodeLlama-7b-Python-hf": ["CodeLlama-7b-python"],
"distilgpt2": ["distillgpt2", "distill-gpt2", "distil-gpt2", "gpt2-xs"],
"EleutherAI/gpt-j-6B": ["gpt-j-6B", "gpt-j", "gptj"],
"EleutherAI/gpt-neo-1.3B": ["gpt-neo-1.3B", "gpt-neo-medium", "neo-medium"],
Expand Down Expand Up @@ -404,16 +401,16 @@
"EleutherAI/pythia-19m-v0",
"pythia-19m-v0",
],
"facebook/hubert-base-ls960": ["facebook/hubert-base-ls960", "hubert-base-ls960"],
"facebook/hubert-base-ls960": ["hubert-base-ls960"],
"facebook/opt-1.3b": ["opt-1.3b", "opt-medium"],
"facebook/opt-125m": ["opt-125m", "opt-small", "opt"],
"facebook/opt-13b": ["opt-13b", "opt-xxl"],
"facebook/opt-2.7b": ["opt-2.7b", "opt-large"],
"facebook/opt-30b": ["opt-30b", "opt-xxxl"],
"facebook/opt-6.7b": ["opt-6.7b", "opt-xl"],
"facebook/opt-66b": ["opt-66b", "opt-xxxxl"],
"facebook/wav2vec2-base": ["facebook/wav2vec2-base", "wav2vec2-base", "w2v2-base"],
"facebook/wav2vec2-large": ["facebook/wav2vec2-large", "wav2vec2-large", "w2v2-large"],
"facebook/wav2vec2-base": ["wav2vec2-base", "w2v2-base"],
"facebook/wav2vec2-large": ["wav2vec2-large", "w2v2-large"],
"google-bert/bert-base-cased": ["bert-base-cased"],
"google-bert/bert-base-uncased": ["bert-base-uncased"],
"google-bert/bert-large-cased": ["bert-large-cased"],
Expand Down Expand Up @@ -450,11 +447,11 @@
"llama-30b-hf": ["llama-30b"],
"llama-65b-hf": ["llama-65b"],
"llama-7b-hf": ["llama-7b"],
"meta-llama/Llama-2-13b-chat-hf": ["Llama-2-13b-chat", "meta-llama/Llama-2-13b-chat-hf"],
"meta-llama/Llama-2-13b-hf": ["Llama-2-13b", "meta-llama/Llama-2-13b-hf"],
"meta-llama/Llama-2-13b-chat-hf": ["Llama-2-13b-chat"],
"meta-llama/Llama-2-13b-hf": ["Llama-2-13b"],
"meta-llama/Llama-2-70b-chat-hf": ["Llama-2-70b-chat", "meta-llama-2-70b-chat-hf"],
"meta-llama/Llama-2-7b-chat-hf": ["Llama-2-7b-chat", "meta-llama/Llama-2-7b-chat-hf"],
"meta-llama/Llama-2-7b-hf": ["Llama-2-7b", "meta-llama/Llama-2-7b-hf"],
"meta-llama/Llama-2-7b-chat-hf": ["Llama-2-7b-chat"],
"meta-llama/Llama-2-7b-hf": ["Llama-2-7b"],
"microsoft/phi-1": ["phi-1"],
"microsoft/phi-1_5": ["phi-1_5"],
"microsoft/phi-2": ["phi-2"],
Expand Down
68 changes: 68 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading