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

NameError: name '_seed' is not defined #95

Closed
TED-EE opened this issue Jul 4, 2024 · 2 comments
Closed

NameError: name '_seed' is not defined #95

TED-EE opened this issue Jul 4, 2024 · 2 comments

Comments

@TED-EE
Copy link

TED-EE commented Jul 4, 2024

Reproduce steps:

git clone https://github.com/FlagOpen/FlagGems.git
cd FlagGems
pip install .
cd tests
pytest test_xx_ops.py
  1. error:
tests/test_binary_pointwise_ops.py:3: in <module>
    import flag_gems
/usr/local/lib/python3.10/dist-packages/flag_gems/__init__.py:4: in <module>
    from .ops import *  # noqa: F403
/usr/local/lib/python3.10/dist-packages/flag_gems/ops/__init__.py:21: in <module>
    from .dropout import native_dropout
/usr/local/lib/python3.10/dist-packages/flag_gems/ops/dropout.py:24: in <module>
    del _seed
E   NameError: name '_seed' is not defined

Solution:
I tried to workaround this problem by defining _seed and _offset, hacking FlagGems/src/flag_gems/ops/dropout.py from

try:
    tl_rand_dtype = tl.int64

    @triton.jit
    def _rand(seed, offset):
        offset = offset.to(tl_rand_dtype)

    _grid = (1,)
    _seed, _offset = philox_cuda_seed_offset(0)
    _rand[_grid](_seed, _offset)
except Exception:
    tl_rand_dtype = tl.int32

to

try:
    tl_rand_dtype = tl.int64

    @triton.jit
    def _rand(seed, offset):
        offset = offset.to(tl_rand_dtype)

    _seed = 0
    _offset = 0
    _grid = (1,)
    _seed, _offset = philox_cuda_seed_offset(0)
    _rand[_grid](_seed, _offset)
except Exception:
    tl_rand_dtype = tl.int32

, and it worked properly.

Is there any formal solution for it?

@StrongSpoon
Copy link
Collaborator

StrongSpoon commented Jul 4, 2024

operator dropout has been updated. please take a try on the new commit.

@TED-EE
Copy link
Author

TED-EE commented Jul 5, 2024

It works. Thanks.

@TED-EE TED-EE closed this as completed Jul 5, 2024
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

No branches or pull requests

2 participants