Skip to content

fix accuracy issue - #4376

Merged
zhyncs merged 2 commits into
mainfrom
zhyncs/math
Mar 13, 2025
Merged

zhyncs merged 2 commits into
mainfrom
zhyncs/math

Conversation

@zhyncs

@zhyncs zhyncs commented Mar 13, 2025

Copy link
Copy Markdown
Contributor

Motivation

➜  tests git:(zhyncs/math) ls | grep test_per | xargs -n 1 python3
INFO 03-13 09:03:35 __init__.py:190] Automatically detected platform cuda.
=================================================================================== test session starts ===================================================================================
platform linux -- Python 3.10.12, pytest-8.3.5, pluggy-1.5.0
rootdir: /sgl-workspace/sglang/sgl-kernel
configfile: pyproject.toml
plugins: anyio-4.8.0, typeguard-4.3.0
collected 9 items

test_per_tensor_quant_fp8.py .........                                                                                                                                              [100%]

==================================================================================== warnings summary =====================================================================================
../../../../usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py:1277
  /usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio
    self._mark_plugins_for_rewrite(hook)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================== 9 passed, 1 warning in 0.53s ===============================================================================
=================================================================================== test session starts ===================================================================================
platform linux -- Python 3.10.12, pytest-8.3.5, pluggy-1.5.0
rootdir: /sgl-workspace/sglang/sgl-kernel
configfile: pyproject.toml
plugins: anyio-4.8.0, typeguard-4.3.0
collected 240 items

test_per_token_group_quant_fp8.py ................................................................................................................................................. [ 60%]
...............................................................................................                                                                                     [100%]

==================================================================================== warnings summary =====================================================================================
../../../../usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py:1277
  /usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio
    self._mark_plugins_for_rewrite(hook)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================= 240 passed, 1 warning in 1.25s ==============================================================================
INFO 03-13 09:03:46 __init__.py:190] Automatically detected platform cuda.
=================================================================================== test session starts ===================================================================================
platform linux -- Python 3.10.12, pytest-8.3.5, pluggy-1.5.0
rootdir: /sgl-workspace/sglang/sgl-kernel
configfile: pyproject.toml
plugins: anyio-4.8.0, typeguard-4.3.0
collected 9 items

test_per_token_quant_fp8.py .........                                                                                                                                               [100%]

==================================================================================== warnings summary =====================================================================================
../../../../usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py:1277
  /usr/local/lib/python3.10/dist-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio
    self._mark_plugins_for_rewrite(hook)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================== 9 passed, 1 warning in 0.51s ===============================================================================

Modifications

Checklist

@zhyncs

zhyncs commented Mar 13, 2025

Copy link
Copy Markdown
Contributor Author

@elfiegg @hebiao064 @zcnrex @qingquansong @BBuf

@zhyncs
zhyncs merged commit 2937387 into main Mar 13, 2025
@zhyncs
zhyncs deleted the zhyncs/math branch March 13, 2025 09:06
Comment thread sgl-kernel/setup.py
nvcc_flags.append("-gencode=arch=compute_100,code=sm_100")
nvcc_flags.append("-gencode=arch=compute_100a,code=sm_100a")
else:
nvcc_flags.append("-use_fast_math")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

感觉这个影响更大,因为 fast_math 实现是 用 多项式拟合,超越函数,倒数,基本都是按taylor展开写,应该会掉很多精度。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to be very cautious about it: https://simonbyrne.github.io/notes/fastmath/

At the same time we will verify the accuracy of per token quant asap in our recommendation use cases

hebiao064 pushed a commit to hebiao064/sglang that referenced this pull request Mar 13, 2025
0826joyce pushed a commit to 0826joyce/sglang-perf-opt that referenced this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants