Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
bitsandbytes
Commits
3cff6795
Commit
3cff6795
authored
Nov 29, 2021
by
Tim Dettmers
Browse files
Merge branch 'main' of github.com:facebookresearch/bitsandbytes into 0.26.0
parents
108cf9fc
262350c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
bitsandbytes/nn/modules.py
bitsandbytes/nn/modules.py
+2
-2
bitsandbytes/optim/adam.py
bitsandbytes/optim/adam.py
+8
-3
No files found.
bitsandbytes/nn/modules.py
View file @
3cff6795
...
...
@@ -15,8 +15,8 @@ from bitsandbytes.optim import GlobalOptimManager
class
StableEmbedding
(
torch
.
nn
.
Embedding
):
def
__init__
(
self
,
num_embeddings
:
int
,
embedding_dim
:
int
,
padding_idx
:
Optional
[
int
]
=
None
,
max_norm
:
Optional
[
float
]
=
None
,
norm_type
:
float
=
2.
,
scale_grad_by_freq
:
bool
=
False
,
sparse
:
bool
=
Tru
e
,
_weight
:
Optional
[
Tensor
]
=
None
)
->
None
:
super
(
StableEmbedding
,
self
).
__init__
(
num_embeddings
,
embedding_dim
,
padding_idx
,
max_norm
,
norm_type
,
scale_grad_by_freq
,
Fal
se
,
_weight
)
sparse
:
bool
=
Fals
e
,
_weight
:
Optional
[
Tensor
]
=
None
)
->
None
:
super
(
StableEmbedding
,
self
).
__init__
(
num_embeddings
,
embedding_dim
,
padding_idx
,
max_norm
,
norm_type
,
scale_grad_by_freq
,
spar
se
,
_weight
)
self
.
norm
=
torch
.
nn
.
LayerNorm
(
embedding_dim
)
GlobalOptimManager
.
get_instance
().
register_parameters
(
self
.
weight
)
GlobalOptimManager
.
get_instance
().
override_config
(
self
.
weight
,
'optim_bits'
,
32
)
...
...
bitsandbytes/optim/adam.py
View file @
3cff6795
...
...
@@ -2,7 +2,12 @@
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import
math
import
os
import
torch
import
torch.distributed
as
dist
from
bitsandbytes.optim.optimizer
import
Optimizer2State
import
bitsandbytes.functional
as
F
...
...
@@ -219,9 +224,9 @@ class AnalysisAdam(torch.optim.Optimizer):
if
self
.
savedir
!=
''
and
state
[
'step'
]
%
100
==
0
:
if
not
os
.
path
.
exists
(
self
.
savedir
):
os
.
makedirs
(
self
.
savedir
)
shapestr
=
'_'
.
join
([
str
(
dim
)
for
dim
in
p_data_fp32
.
shape
])
pathe
=
join
(
self
.
savedir
,
f
'
{
p_id
}
_
{
shapestr
}
_abserr.pkl'
)
pathrele
=
join
(
self
.
savedir
,
f
'
{
p_id
}
_
{
shapestr
}
_relerr.pkl'
)
pathcounts
=
join
(
self
.
savedir
,
f
'
{
p_id
}
_
{
shapestr
}
_counts.pkl'
)
pathe
=
os
.
path
.
join
(
self
.
savedir
,
f
'
{
p_id
}
_
{
shapestr
}
_abserr.pkl'
)
pathrele
=
os
.
path
.
join
(
self
.
savedir
,
f
'
{
p_id
}
_
{
shapestr
}
_relerr.pkl'
)
pathcounts
=
os
.
path
.
join
(
self
.
savedir
,
f
'
{
p_id
}
_
{
shapestr
}
_counts.pkl'
)
torch
.
save
(
e
,
pathe
)
torch
.
save
(
rele
,
pathrele
)
torch
.
save
(
counts
,
pathcounts
)
...
...
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