Skip to content

Commit

Permalink
Update functional.py
Browse files Browse the repository at this point in the history
  • Loading branch information
IndigoDosSantos authored May 28, 2024
1 parent 2e46eef commit 7a338db
Showing 1 changed file with 70 additions and 18 deletions.
88 changes: 70 additions & 18 deletions bitsandbytes/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,57 +28,94 @@ def prod(iterable):
"""C FUNCTIONS FOR OPTIMIZERS"""
str2optimizer32bit = {
"adagrad": (
lib.cadagrad32bit_grad_32,
lib.cadagrad32bit_grad_16,
lib.cadagrad32bit_grad_fp32,
lib.cadagrad32bit_grad_fp16,
),
"adam": (
lib.cadam32bit_grad_fp32,
lib.cadam32bit_grad_fp16,
lib.cadam32bit_grad_bf16,
),
"pagedadam": (
lib.cpagedadam32bit_grad_fp32,
lib.cpagedadam32bit_grad_fp16,
lib.cpagedadam32bit_grad_bf16,
),
"adamw": (
lib.cadam32bit_grad_fp32,
lib.cadam32bit_grad_fp16,
lib.cadam32bit_grad_bf16,
),
"pagedadamw": (
lib.cpagedadam32bit_grad_fp32,
lib.cpagedadam32bit_grad_fp16,
lib.cpagedadam32bit_grad_bf16,
),
"lamb": (
lib.cadam32bit_grad_fp32,
lib.cadam32bit_grad_fp16,
),
"lars": (
lib.clars32bit_grad_fp32,
lib.clars32bit_grad_fp16,
),
"lion": (
lib.clion32bit_grad_fp32,
lib.clion32bit_grad_fp16,
lib.clion32bit_grad_bf16,
),
"momentum": (
lib.cmomentum32bit_grad_32,
lib.cmomentum32bit_grad_16,
lib.cmomentum32bit_grad_fp32,
lib.cmomentum32bit_grad_fp16,
),
"rmsprop": (
lib.crmsprop32bit_grad_32,
lib.crmsprop32bit_grad_16,
lib.crmsprop32bit_grad_fp32,
lib.crmsprop32bit_grad_fp16,
),
}

str2optimizer8bit = {
"adagrad": (
lib.cadagrad8bit_grad_fp32,
lib.cadagrad8bit_grad_fp16,
),
"adam": (
lib.cadam_static_8bit_grad_32,
lib.cadam_static_8bit_grad_16,
lib.cadam_static_8bit_grad_fp32,
lib.cadam_static_8bit_grad_fp16,
),
"pagedadam": (
lib.cpagedadam8bit_grad_fp32,
lib.cpagedadam8bit_grad_fp16,
lib.cpagedadam8bit_grad_bf16,
),
"adamw": (
lib.cadam_static_8bit_grad_fp32,
lib.cadam_static_8bit_grad_fp16,
),
"pagedadamw": (
lib.cpagedadam8bit_grad_fp32,
lib.cpagedadam8bit_grad_fp16,
lib.cpagedadam8bit_grad_bf16,
),
"lamb": (
lib.cadam_static_8bit_grad_32,
lib.cadam_static_8bit_grad_16,
lib.cadam_static_8bit_grad_fp32,
lib.cadam_static_8bit_grad_fp16,
),
"lars": (
lib.cmomentum_static_8bit_grad_32,
lib.cmomentum_static_8bit_grad_16,
lib.clars8bit_grad_fp32,
lib.clars8bit_grad_fp16,
),
"lion": (
lib.clion_static_8bit_grad_32,
lib.clion_static_8bit_grad_16,
lib.clion_static_8bit_grad_fp32,
lib.clion_static_8bit_grad_fp16,
),
"momentum": (
lib.cmomentum_static_8bit_grad_32,
lib.cmomentum_static_8bit_grad_16,
lib.cmomentum_static_8bit_grad_fp32,
lib.cmomentum_static_8bit_grad_fp16,
),
"rmsprop": (
lib.crmsprop_static_8bit_grad_32,
lib.crmsprop_static_8bit_grad_16,
lib.crmsprop_static_8bit_grad_fp32,
lib.crmsprop_static_8bit_grad_fp16,
),
}

Expand All @@ -92,6 +129,21 @@ def prod(iterable):
lib.cadam_8bit_blockwise_grad_fp16,
lib.cadam_8bit_blockwise_grad_bf16,
),
"pagedadam": (
lib.cpagedadam8bit_blockwise_fp32,
lib.cpagedadam8bit_blockwise_fp16,
lib.cpagedadam8bit_blockwise_bf16,
),
"adamw": (
lib.cadam_8bit_blockwise_grad_fp32,
lib.cadam_8bit_blockwise_grad_fp16,
lib.cadam_8bit_blockwise_grad_bf16,
),
"pagedadamw": (
lib.cpagedadam8bit_blockwise_fp32,
lib.cpagedadam8bit_blockwise_fp16,
lib.cpagedadam8bit_blockwise_bf16,
),
"lion": (
lib.clion_8bit_blockwise_grad_fp32,
lib.clion_8bit_blockwise_grad_fp16,
Expand Down

0 comments on commit 7a338db

Please sign in to comment.