Repository navigation
[graph_trainer] Import the paged stash Triton kernels at launch - #5611
Conversation
|
|
There was a problem hiding this comment.
should be put under graph_trainer folder
There was a problem hiding this comment.
@tianyu-l Sure, moved to torchtitan/experiments/graph_trainer/tests/test_optional_imports.py with no other change. One note, the CPU unit test workflow only collects tests/unit_tests/cpu and the graph_trainer workflows run named files, so nothing in CI executes it from here. Happy to add a line to integration_test_8gpu_graph_trainer.yaml if you want it run (it blocks triton inside its subprocess, so it passes on the GPU runners as well).
|
@tianyu-l Have just sent a LinkedIn connection request, I am https://www.linkedin.com/in/manish-khilari/ |
|
@claude is this just code move? |
|
Claude finished @SherlockNoMad's task in 56s —— View job Yes. It's a code move plus two lazy imports: the Triton kernels are byte-identical, and the only behavioral change is when What I checked (diff vs base 3ed5aa9)
Numerics / perf: no change where Triton is installed: same kernels, same launch sites, same arguments. |
SherlockNoMad
left a comment
There was a problem hiding this comment.
Thanks for the fix!
|
I see you are working at Microsoft, wondering what's your interests in GraphTrainer? |
|
@SherlockNoMad Thanks for the review. I'm contributing to GraphTrainer to build up my open source contributions, and eventually work in AI training and research, at Pytorch, Meta or elsewhere. GraphTrainer stood out because the idea of training large models from a single compiled graph instead of eager PyTorch was cool. |
Summary
paged_stash_memory_policy.pyimportedtritonat module level, andgraph_trainer.trainerimports it throughgraph_pp/pipeline.py -> graph_builder.py -> graph_builder_utils.py. On a platform without Triton wheels (macOS, CPU only)GraphTrainertherefore did not import, and three CPU test modules did not collect:tests/unit_tests/cpu/test_trainer.py,config/test_config_validation.py,config/test_cuda_graph_validation_config.py(noted as the remaining collection errors in #5565, now merged).paged_stash_copy_kernel,paged_stash_pop_kernel) andGLOBAL_BLOCK_SIZEmove verbatim, with their "copied from Megatron Core 0.19.0, do not clean up" header, intopaged_stash_kernels.py. Nothing outsidePagedStashBuffer.launch_copy/launch_popreferenced them (they were in__all__, which no longer lists them).launch_copyandlaunch_popimport the kernel module at launch. The policy module imports everywhere, a launch on a machine without Triton raises Python's ownModuleNotFoundError: No module named 'triton', and the kernels can only run on CUDA anyway.sys.modulesafter the first launch.Test plan
New
torchtitan/experiments/graph_trainer/tests/test_optional_imports.py, in a subprocess that blockstritononsys.meta_path,GraphTrainerandpaged_stash_memory_policyimport withtritonnever loaded, importingpaged_stash_kernelsand callingPagedStashBuffer.launch_copyraiseModuleNotFoundErrorwithname == "triton". Fails on main (the policy import raises), passes with this change.On macOS 15 (no Triton), torch 2.16.0.dev20261022 CPU, torch_checkpointing 0.1.1, on main 3ed5aa9 (with #5565 merged):
pytest tests/unit_tests/cpu --collect-only, 3 errors / 1847 tests collected on main (test_trainer.py,config/test_config_validation.py,config/test_cuda_graph_validation_config.py, all the Triton import) -> 0 errors / 1926 tests collected with this change.tests/unit_tests/cpu/test_trainer.py,config/test_config_validation.py,config/test_cuda_graph_validation_config.py, 79 passed.import tritonlines of the new module (no Triton locally) and diagnostics that pre date this change inpaged_stash_memory_policy.py.The GPU paged stash tests (
torchtitan/experiments/graph_trainer/tests/test_paged_stash.py) import only the policy module's public names, which are unchanged, I could not run them here (no CUDA).