Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 13 additions & 4 deletions auto_round/autoround.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def __init__(
to_quant_block_names: Union[str, list, None] = kwargs.pop("to_quant_block_names", None)
enable_norm_bias_tuning: bool = kwargs.pop("enable_norm_bias_tuning", False)
enable_quanted_input: bool = kwargs.pop("enable_quanted_input", True)
disable_deterministic_algorithms = kwargs.pop("disable_deterministic_algorithms", False)
disable_deterministic_algorithms = kwargs.pop("disable_deterministic_algorithms", True)
enable_deterministic_algorithms = kwargs.pop("enable_deterministic_algorithms", False)
static_kv_dtype = kwargs.pop("static_kv_dtype", None)
device = kwargs.pop("device", None)
self.quant_lm_head = kwargs.pop("quant_lm_head", False)
Expand All @@ -234,11 +235,19 @@ def __init__(

if kwargs:
logger.warning(f"unrecognized keys {list(kwargs.keys())} were passed. Please check them.")
if "CUBLAS_WORKSPACE_CONFIG" not in os.environ:
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"
# deprecated, default not to use torch.use_deterministic_algorithms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upper case

if not disable_deterministic_algorithms or enable_deterministic_algorithms:
if not disable_deterministic_algorithms:
logger.warning(
"default not use deterministic_algorithms. disable_deterministic_algorithms is deprecated,"
" please use enable_deterministic_algorithms instead. "
)

if not disable_deterministic_algorithms:
if "CUBLAS_WORKSPACE_CONFIG" not in os.environ:
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"
torch.use_deterministic_algorithms(True, warn_only=False)
Copy link
Contributor

@wenhuach21 wenhuach21 Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if enable_deterministic_algorithms is not set, we use warn_only=Ture, which is the default behavior in our previous version, though I admit it's a quite confusing.

else:
torch.use_deterministic_algorithms(True, warn_only=True)

if device is not None:
logger.warning("`device` is deprecated, please use `device_map` instead")
Expand Down
14 changes: 12 additions & 2 deletions auto_round/script/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ def __init__(self, *args, **kwargs):
self.add_argument("--enable_alg_ext", action="store_true", help="whether to enable probably better algorithm")

self.add_argument(
"--disable_deterministic_algorithms", action="store_true", help="disable torch deterministic algorithms."
"--disable_deterministic_algorithms",
action="store_true",
help="deprecated, disable torch deterministic algorithms.",
)
self.add_argument(
"--enable_deterministic_algorithms", action="store_true", help="enable torch deterministic algorithms."
)

self.add_argument(
Expand Down Expand Up @@ -543,6 +548,11 @@ def tune(args):
scheme = args.scheme.upper()
if scheme not in PRESET_SCHEMES:
raise ValueError(f"{scheme} is not supported. only {PRESET_SCHEMES.keys()} are supported ")
if args.disable_deterministic_algorithms:
logger.warning(
"default not use deterministic_algorithms. disable_deterministic_algorithms is deprecated,"
" please use enable_deterministic_algorithms instead. "
)
autoround = round(
model=model,
tokenizer=tokenizer,
Expand Down Expand Up @@ -580,7 +590,7 @@ def tune(args):
super_group_size=args.super_group_size,
super_bits=args.super_bits,
disable_opt_rtn=args.disable_opt_rtn,
disable_deterministic_algorithms=args.disable_deterministic_algorithms,
enable_deterministic_algorithms=args.enable_deterministic_algorithms,
enable_alg_ext=args.enable_alg_ext,
**mllm_kwargs,
)
Expand Down
16 changes: 13 additions & 3 deletions auto_round/script/mllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ def __init__(self, *args, **kwargs):
self.add_argument("--enable_torch_compile", action="store_true", help="whether to enable torch compile")

self.add_argument(
"--disable_deterministic_algorithms", action="store_true", help="disable torch deterministic algorithms."
"--disable_deterministic_algorithms",
action="store_true",
help="deprecated, disable torch deterministic algorithms.",
)

self.add_argument(
"--enable_deterministic_algorithms", action="store_true", help="enable torch deterministic algorithms."
)

## ======================= VLM =======================
Expand Down Expand Up @@ -435,7 +441,11 @@ def tune(args):
scheme = args.scheme.upper()
if scheme not in PRESET_SCHEMES:
raise ValueError(f"{scheme} is not supported. only {PRESET_SCHEMES.keys()} are supported ")

if args.disable_deterministic_algorithms:
logger.warning(
"default not use deterministic_algorithms. disable_deterministic_algorithms is deprecated,"
" please use enable_deterministic_algorithms instead. "
)
autoround = round(
model,
tokenizer,
Expand Down Expand Up @@ -473,7 +483,7 @@ def tune(args):
model_kwargs=model_kwargs,
data_type=args.data_type,
disable_opt_rtn=args.disable_opt_rtn,
disable_deterministic_algorithms=args.disable_deterministic_algorithms,
enable_deterministic_algorithms=args.enable_deterministic_algorithms,
)

model_name = args.model.rstrip("/")
Expand Down