Skip to content

lecture 06, AttributeError: 'JITFunction' object has no attribute 'cache' for triton-3.5.0 #25

Description

@marvin-0042

Hi Master,

Thanks for the great lecture! it's very solid and deep for developers who need systematic training in AI infra.

requirements.txt doesn't identify torch triton version, when I install latest torch (torch-2.9.0) which needs triton>=3.5.0,
python execute.py -m lecture_06
hit below issue like due to triton JITFunction interface changed

File "/workspace/spring2025-lectures/lecture_06.py", line 607, in print_ptx
return list(kernel.cache[0].values())[0].asm["ptx"]
^^^^^^^^^^^^
AttributeError: 'JITFunction' object has no attribute 'cache'

pip uninstall torch triton -y
pip install torch==2.6.0 triton==3.2.0

reverted triton to 3.2.0 (and torch back to 2.6.0), issue was fixed.

shall we limit triton / torch version into requirements.txt? or revise the kernel.cache according to latest triton API?
I can submit PR for requirements.txt if that helps.

[8147 lecture_06.py:601] """Print out the PTX code generated by Triton for the given kernel."""
[8148 lecture_06.py:602] ptx_path = f"var/{name}-ptx.txt"
[8149 lecture_06.py:603] text("Let's go poke around at the PTX code.")
[8150 lecture_06.py:604] link(get_local_url(ptx_path))
[8151 lecture_06.py:606] with open(ptx_path, "w") as f:
[8152 lecture_06.py:607] return list(kernel.cache[0].values())[0].asm["ptx"]
[8153 lecture_06.py:607] return list(kernel.cache[0].values())[0].asm["ptx"]
[8153 lecture_06.py:606] with open(ptx_path, "w") as f:
[8154 lecture_06.py:586] ptx = print_ptx("triton_gelu", triton_gelu_kernel)
[8155 lecture_06.py:586] ptx = print_ptx("triton_gelu", triton_gelu_kernel)
[8155 lecture_06.py:508] print_ptx_main() # Look at the generated instructions
[8156 lecture_06.py:508] print_ptx_main() # Look at the generated instructions
[8156 lecture_06.py:477] triton_gelu_main()
[8157 lecture_06.py:477] triton_gelu_main()
[8157 lecture_06.py:30] triton_kernels() # Write kernels in Python
[8158 lecture_06.py:30] triton_kernels() # Write kernels in Python
Traceback (most recent call last):
File "/workspace/spring2025-lectures/execute.py", line 264, in
trace = execute(module_name=module, inspect_all_variables=args.inspect_all_variables)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/spring2025-lectures/execute.py", line 241, in execute
module.main()
File "/workspace/spring2025-lectures/lecture_06.py", line 30, in main
triton_kernels() # Write kernels in Python
^^^^^^^^^^^^^^^^
File "/workspace/spring2025-lectures/lecture_06.py", line 477, in triton_kernels
triton_gelu_main()
File "/workspace/spring2025-lectures/lecture_06.py", line 508, in triton_gelu_main
print_ptx_main() # Look at the generated instructions
^^^^^^^^^^^^^^^^
File "/workspace/spring2025-lectures/lecture_06.py", line 586, in print_ptx_main
ptx = print_ptx("triton_gelu", triton_gelu_kernel)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/spring2025-lectures/lecture_06.py", line 607, in print_ptx
return list(kernel.cache[0].values())[0].asm["ptx"]
^^^^^^^^^^^^
AttributeError: 'JITFunction' object has no attribute 'cache'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions