Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
Basedformer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Basedformer
Commits
d57cfcec
Commit
d57cfcec
authored
Feb 20, 2022
by
novelailab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
good benchmark. pepe sad
parent
7a721f81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
16 deletions
+10
-16
gptj.py
gptj.py
+8
-14
hfport.py
hfport.py
+2
-2
No files found.
gptj.py
View file @
d57cfcec
...
...
@@ -5,11 +5,6 @@ from time import perf_counter, perf_counter_ns
import
numpy
as
np
from
tqdm
import
tqdm
from
contextlib
import
contextmanager
from
transformers
import
(
AutoModelForCausalLM
,
GPTNeoForCausalLM
,
AutoConfig
,
)
#replicating timeit magic function of ipython
def
timeit
(
func
,
r
=
1
,
n
=
5
,
quiet
=
False
,
function
=
None
,
do_tqdm
=
False
,
first
=
True
):
precision
=
'ns'
...
...
@@ -64,13 +59,12 @@ def timeit(func, r=1, n=5, quiet=False, function=None, do_tqdm=False, first=True
with
torch
.
no_grad
():
model
=
load_gpt_j
()
.
cuda
()
.
half
()
.
eval
()
model
=
load_gpt_j
()
.
cuda
()
.
half
()
x
=
torch
.
zeros
(
1
,
2048
)
.
cuda
()
.
long
()
our
=
model
(
x
)
print
(
our
.
shape
)
del
model
model
=
no_init
(
lambda
:
AutoModelForCausalLM
.
from_pretrained
(
'/home/xuser/models/j6b_ckpt_14001'
))
.
cuda
()
.
half
()
.
eval
()
hf
=
model
(
x
,
output_hidden_states
=
True
)[
"hidden_states"
][
-
1
]
print
(
our
[
0
,
2047
,
1000
:
1020
])
print
(
hf
[
0
,
2047
,
1000
:
1020
])
print
(
hf
.
shape
)
\ No newline at end of file
print
(
model
(
x
)
.
shape
)
print
(
"PyTorch Eager"
)
timeit
(
r
=
1
,
n
=
100
,
func
=
lambda
:
model
(
x
),
do_tqdm
=
False
,
first
=
False
)
module
=
torch
.
jit
.
trace
(
model
,
torch
.
zeros
((
1
,
2048
))
.
long
()
.
cuda
())
torch
.
jit
.
optimize_for_inference
(
module
)
print
(
"PyTorch JIT"
)
timeit
(
r
=
1
,
n
=
100
,
func
=
lambda
:
module
(
x
),
do_tqdm
=
False
,
first
=
False
)
\ No newline at end of file
hfport.py
View file @
d57cfcec
from
main
import
*
state_dict
=
SplitCheckpoint
(
"
/home/xuser/models/j6b_ckpt_14001
"
,
device
=
"cpu"
)
state_dict
=
SplitCheckpoint
(
"
j6b_vanilla
"
,
device
=
"cpu"
)
# ORIGINAL
...
...
@@ -62,4 +62,4 @@ def save(state_dict, path):
torch
.
save
(
x
[
1
],
f
"{path}/b{i}.pt"
)
torch
.
save
(
checkpoint
,
f
"{path}/m.pt"
)
save
(
new_state_dict
,
"models/6b"
)
\ No newline at end of file
save
(
new_state_dict
,
"models/6b_vanilla"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment