FagerholmEmil commited on
Commit
4e7555f
·
1 Parent(s): 4047c81

Simplify device handling by removing explicit device selection

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -1,23 +1,10 @@
1
  # app.py
2
- import os
3
  import gradio as gr
4
  from transformer_lens import HookedTransformer
5
  from transformer_lens.utils import to_numpy
6
- import torch
7
 
8
  model_name = "gpt2-small"
9
- # Determine device based on CUDA availability
10
- device = "cuda" if torch.cuda.is_available() else "cpu"
11
- model = HookedTransformer.from_pretrained(
12
- model_name,
13
- device=device
14
- )
15
-
16
- # Only print GPU info if using CUDA
17
- if device == "cuda":
18
- print(f"Using GPU: {torch.cuda.get_device_name(0)}")
19
- else:
20
- print("Using CPU")
21
 
22
  def get_neuron_acts(text, layer, neuron_index):
23
  cache = {}
@@ -92,7 +79,7 @@ Nested loops:
92
 
93
  The moon glows silver, wanes to shadow.
94
  Patterns persist: 11, 22, 33—harmonic echoes.
95
- "Reshape," calls the river, "reflect, refract, renew."
96
  Yellow hexagons tessellate, shifting into orange octagons.
97
  1/3 -> 1/9 -> 1/27: recursive reduction spirals infinitely.
98
 
@@ -129,7 +116,7 @@ Symmetry hums:
129
  Palindromes—"radar", "level", "madam"—appear and fade.
130
  Blue fades to white, white dissolves to black.
131
  Sequences echo: 1, 10, 100, 1000…
132
- "Cycle," whispers the clock, "count forward, reverse.""" # Shortened for example
133
  default_layer = 1
134
  default_neuron_index = 1
135
  default_max_val = 4.0
 
1
  # app.py
 
2
  import gradio as gr
3
  from transformer_lens import HookedTransformer
4
  from transformer_lens.utils import to_numpy
 
5
 
6
  model_name = "gpt2-small"
7
+ model = HookedTransformer.from_pretrained(model_name)
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  def get_neuron_acts(text, layer, neuron_index):
10
  cache = {}
 
79
 
80
  The moon glows silver, wanes to shadow.
81
  Patterns persist: 11, 22, 33—harmonic echoes.
82
+ Reshape,” calls the river, reflect, refract, renew.”
83
  Yellow hexagons tessellate, shifting into orange octagons.
84
  1/3 -> 1/9 -> 1/27: recursive reduction spirals infinitely.
85
 
 
116
  Palindromes—"radar", "level", "madam"—appear and fade.
117
  Blue fades to white, white dissolves to black.
118
  Sequences echo: 1, 10, 100, 1000…
119
+ Cycle,” whispers the clock, count forward, reverse.""" # Shortened for example
120
  default_layer = 1
121
  default_neuron_index = 1
122
  default_max_val = 4.0