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
6 changes: 6 additions & 0 deletions examples/text-generation/run_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ def setup_parser(parser):
action="store_true",
help="Run the inference with dataset for specified --n_iterations(default:5)",
)
parser.add_argument(
Comment thread
hsubramony marked this conversation as resolved.
"--sdp_on_bf16", action="store_true", help="Allow pyTorch to use reduced precision in the SDPA math backend"
)

quant_parser_group = parser.add_mutually_exclusive_group()
quant_parser_group.add_argument(
Expand Down Expand Up @@ -389,6 +392,9 @@ def main():

import habana_frameworks.torch.hpu as torch_hpu

if args.sdp_on_bf16:
torch._C._set_math_sdp_allow_fp16_bf16_reduction(True)

if args.dataset_name is None:
# Benchmark over the prompts below
if args.prompt:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_encoder_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def _test_text_translation(
if "opus-mt-zh-en" in model_name:
command_args.append("--max_source_length 512")

if "Babelscape/mrebel-large" in model_name or "nllb-200-distilled-600M" in model_name:
command_args.append("--sdp_on_bf16")

command = self._build_command(
task=task,
deepspeed=deepspeed,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,26 @@ def test(self):
env_variables["PT_HPU_LAZY_MODE"] = "0"
env_variables["PT_ENABLE_INT64_SUPPORT"] = "1"

if self.EXAMPLE_NAME == "run_glue":
if model_name == "bert-large-uncased-whole-word-masking":
Comment thread
hsubramony marked this conversation as resolved.
extra_command_line_arguments.append("--sdp_on_bf16")

if self.EXAMPLE_NAME == "run_qa":
if model_name == "bert-large-uncased-whole-word-masking" or \
model_name == "albert-large-v2":
extra_command_line_arguments.append("--sdp_on_bf16")

if self.EXAMPLE_NAME == "run_bridgetower":
if model_name == "BridgeTower/bridgetower-large-itm-mlm-itc":
extra_command_line_arguments.append("--sdp_on_bf16")

if self.EXAMPLE_NAME == "run_speech_recognition_seq2seq":
if model_name == "openai/whisper-small":
Comment thread
yeonsily marked this conversation as resolved.
extra_command_line_arguments.append("--sdp_on_bf16")

if self.EXAMPLE_NAME == "run_clip":
extra_command_line_arguments.append("--sdp_on_bf16")

with TemporaryDirectory() as tmp_dir:
cmd_line = self._create_command_line(
multi_card,
Expand Down
1 change: 1 addition & 0 deletions tests/test_fsdp_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _test_fsdp(
f"--gaudi_config_name {gaudi_config}",
"--throughput_warmup_steps 100",
"--do_eval",
"--sdp_on_bf16",
]
else:
command += [
Expand Down
5 changes: 5 additions & 0 deletions tests/test_image_to_text_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def _test_image_to_text(
"--use_hpu_graphs",
]

if "meta-llama/Llama-3.2-11B-Vision-Instruct" in model_name or "tiiuae/falcon-11B-vlm" in model_name:
command += [
"--sdp_on_bf16",
]

command.append("--bf16")

with TemporaryDirectory() as tmp_dir:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_text_generation_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ def _test_text_generation(

if "gemma" in model_name.lower():
command += ["--use_flash_attention"]
command += ["--sdp_on_bf16"]

if "decilm" in model_name.lower():
command += ["--sdp_on_bf16"]

if "mamba-130m-hf" in model_name.lower():
command += ["--sdp_on_bf16"]

if (reuse_cache or torch_compile) and not parallel_strategy == "tp" and not is_starcoder_first_gen_model:
command += ["--reuse_cache"]
Expand Down