Skip to content

Update 02-fused-softmax.md#24

Open
GlowLED wants to merge 1 commit intohyperai:masterfrom
GlowLED:patch-1
Open

Update 02-fused-softmax.md#24
GlowLED wants to merge 1 commit intohyperai:masterfrom
GlowLED:patch-1

Conversation

@GlowLED
Copy link
Copy Markdown

@GlowLED GlowLED commented Apr 30, 2026

compiled kernel启动时,现在的官方文档已经是需要传入BLOCK SIZE和num stages的写法了。现在compiled kernel启动时需要传入constexpr参数。 按照原写法,启动kernel时会报错:Traceback (most recent call last):
File "/root/triton-learn/src/fused_softmax.py", line 92, in
y_triton = fused_softmax(x)
File "/root/triton-learn/src/fused_softmax.py", line 78, in fused_softmax
kernel[(num_programs, 1, 1)](
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
x,
^^
...<4 lines>...
n_cols,
^^^^^^^
)
^
File "/root/triton-learn/.venv/lib/python3.13/site-packages/triton/compiler/compiler.py", line 498, in runner
self.run(grid[0], grid[1], grid[2], stream, self.function, self.packed_metadata, launch_metadata,
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
knobs.runtime.launch_enter_hook, knobs.runtime.launch_exit_hook, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/triton-learn/.venv/lib/python3.13/site-packages/triton/backends/nvidia/driver.py", line 713, in call
self.launch(gridX, gridY, gridZ, stream, function, self.launch_cooperative_grid, self.launch_pdl,
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
global_scratch, profile_scratch, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: function takes exactly 21 arguments (19 given)

少了两个参数,正好是那两个constexpr。
详情见英文官方文档:https://triton-lang.org/main/getting-started/tutorials/02-fused-softmax.html

compiled kernel启动时,现在的官方文档已经是需要传入BLOCK SIZE和num stages的写法了。现在compiled kernel启动时需要传入constexpr参数。
按照原写法,启动kernel时会报错:Traceback (most recent call last):
  File "/root/triton-learn/src/fused_softmax.py", line 92, in <module>
    y_triton = fused_softmax(x)
  File "/root/triton-learn/src/fused_softmax.py", line 78, in fused_softmax
    kernel[(num_programs, 1, 1)](
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        x,
        ^^
    ...<4 lines>...
        n_cols,
        ^^^^^^^
    )
    ^
  File "/root/triton-learn/.venv/lib/python3.13/site-packages/triton/compiler/compiler.py", line 498, in runner
    self.run(grid[0], grid[1], grid[2], stream, self.function, self.packed_metadata, launch_metadata,
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             knobs.runtime.launch_enter_hook, knobs.runtime.launch_exit_hook, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/triton-learn/.venv/lib/python3.13/site-packages/triton/backends/nvidia/driver.py", line 713, in __call__
    self.launch(gridX, gridY, gridZ, stream, function, self.launch_cooperative_grid, self.launch_pdl,
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                global_scratch, profile_scratch, *args)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: function takes exactly 21 arguments (19 given)

少了两个参数,正好是那两个constexpr。
详情见英文官方文档:https://triton-lang.org/main/getting-started/tutorials/02-fused-softmax.html
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.

1 participant