Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add falcon180b FP8 test #104

Merged
merged 9 commits into from
Mar 19, 2024
Merged
Changes from 7 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
29 changes: 28 additions & 1 deletion tests/test_text_generation_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from .test_examples import TIME_PERF_FACTOR
from test_examples import TIME_PERF_FACTOR


if os.environ.get("GAUDI2_CI", "0") == "1":
Expand All @@ -26,6 +26,9 @@
("mistralai/Mistral-7B-v0.1", 125.26115369093216),
("mistralai/Mixtral-8x7B-v0.1", 23.78652574031883),
],
"fp8": [
("tiiuae/falcon-180B", 52.525947696914784),
],
"deepspeed": [
("bigscience/bloomz", 36.34664210641816),
("meta-llama/Llama-2-70b-hf", 61.973950428647164),
Expand Down Expand Up @@ -69,6 +72,7 @@ def _test_text_generation(
deepspeed: bool = False,
world_size: int = 8,
torch_compile: bool = False,
fp8: bool = False,
):
command = ["python3"]
path_to_example_dir = Path(__file__).resolve().parent.parent / "examples"
Expand Down Expand Up @@ -103,6 +107,13 @@ def _test_text_generation(
if not deepspeed:
command.append("--bf16")

if fp8:
command += [
"--fp8",
"--reuse_cache",
"--trim_logits",
]

with TemporaryDirectory() as tmp_dir:
command.append(f"--output_dir {tmp_dir}")
print(f"\n\nCommand to test: {' '.join(command)}\n")
Expand All @@ -112,6 +123,15 @@ def _test_text_generation(
pattern = re.compile(r"([\"\'].+?[\"\'])|\s")
command = [x for y in command for x in re.split(pattern, y) if x]

if fp8:
os.environ["QUANT_CONFIG"] = os.path.join(
path_to_example_dir, "text-generation/quantization_config/maxabs_measure_include_outputs.json"
)
subprocess.run(command)
os.environ["QUANT_CONFIG"] = os.path.join(
path_to_example_dir, "text-generation/quantization_config/maxabs_quant.json"
)

proc = subprocess.run(command)

# Ensure the run finished without any issue
Expand All @@ -135,6 +155,13 @@ def test_text_generation_bf16(model_name: str, baseline: float, token: str):
_test_text_generation(model_name, baseline, token)


@pytest.mark.parametrize("model_name, baseline", MODELS_TO_TEST["fp8"])
def test_text_generation_fp8(model_name: str, baseline: float, token: str):
deepspeed = True if "falcon-180B" in model_name else False
world_size = 8 if "falcon-180B" in model_name else None
_test_text_generation(model_name, baseline, token, deepspeed=deepspeed, world_size=world_size, fp8=True)


@pytest.mark.parametrize("model_name, baseline", MODELS_TO_TEST["deepspeed"])
def test_text_generation_deepspeed(model_name: str, baseline: float, token: str):
world_size = 2 if "opt-66b" in model_name else 8
Expand Down