Gen pyi test - #5
Draft
cleonard530 wants to merge 24 commits into
Draft
cleonard530 wants to merge 24 commits into
cleonard530 wants to merge 24 commits into
Conversation
Signed-off-by: Chris Leonard <chleonar@redhat.com>
… match what was in the legacy code Signed-off-by: Chris Leonard <chleonar@redhat.com>
…helper code from generate_pyi.py Signed-off-by: Chris Leonard <chleonar@redhat.com>
…updates so I updated it to inlcude the type hints Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
…ybind default arguments are no longer there Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
…ther minor formatting issues. Also added comments with examples to help describe each step. These will be removed (as well as main()) in a followup commit, but wanted them here for reference Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
…TORCH_LIBRARY; deep_gemm/_C.py can keep using torch.ops.load_library. Signed-off-by: Chris Leonard <chleonar@redhat.com>
… function that was leftover from migration, replaces torch_compat with torch/all.h, and updated the sm120 files to use torch/all.h instead of torch/python.h
…_library_macros - Drop torch_library_macros.hpp; register ops via TORCH_FN directly and rename torch_library_utils namespace to torch_utils. - Use at::ScalarType/torch.dtype for logits_dtype instead of int + _SCALAR_TYPE dict. - Align schema/wrapper param names with C++ impl (fused_kv_cache, activation_clamp_opt, *_tuple/*_tuple_opt), propagated to _C.py, mega/__init__.py, and tests. - Prefix slice_symm_buffer_for_mega_moe with _ to mark it private. Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
…o align it with the C++ names Signed-off-by: Chris Leonard <chleonar@redhat.com>
cleonard530
force-pushed
the
gen_pyi_test
branch
from
July 22, 2026 18:27
1a0acb9 to
e7fb668
Compare
fp8_fp4_mega_moe and bf16_mega_moe both write into this tensor via a device-side red.add reduction (accumulating per-expert recv counts across calls), but the TORCH_LIBRARY schema declared it as immutable (Tensor?). Fix by annotating it Tensor(cumulative_local_expert_recv_stats!)?. Signed-off-by: Chris Leonard <chleonar@redhat.com>
…filenames on release uploads. Bump the floor to cp310, which every torch version in the matrix (2.4-2.8) already supports. Signed-off-by: Chris Leonard <chleonar@redhat.com>
…as. These were declared optional but the C++ impl always called unconditionally, so would have crashed anyway; the Python wrappers already default to a concrete tuple. Signed-off-by: Chris Leonard <chleonar@redhat.com>
…n by having get_symm_buffer_size_for_mega_moe return the computed layout as an int[] alongside num_bytes, which _slice_symm_buffer_for_mega_moe now reuses instead of rederiving it (and its num_sms-dependent ring sizing) from the original args a second time. Signed-off-by: Chris Leonard <chleonar@redhat.com>
…params like recipe/head_splits, so the schema itself is the source of truth for stub generation instead of a hand-maintained per-name promotion table in generate_pyi.py. Add an _as_int_list wrapper helper so int[N]'s scalar-broadcasting behavior can't silently convert a bad scalar argument into a repeated list. Signed-off-by: Chris Leonard <chleonar@redhat.com>
cleonard530
force-pushed
the
gen_pyi_test
branch
from
July 28, 2026 16:03
e7fb668 to
5772cd5
Compare
…le-factor pairs like q/q_sf, replacing the special-cased _apply_q_qsf_merge, and sort the csrc/ file scan so op ordering in the generated stub no longer shuffles across machines/checkouts. Also drop sanitize_param_name, since it could only keep the .pyi syntactically valid and not guarantee the stub's keyword name actually matches the real wrapper at runtime. Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
cleonard530
force-pushed
the
gen_pyi_test
branch
from
July 28, 2026 19:07
5772cd5 to
66a9b5f
Compare
cleonard530
force-pushed
the
migrate_pybind_to_torch_library
branch
from
September 4, 2026 19:08
61073b9 to
90d0764
Compare
cleonard530
force-pushed
the
migrate_pybind_to_torch_library
branch
from
September 9, 2026 14:52
90d0764 to
343826c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is just to show the difference between _C.pyi before and after move to TORCH_LIBRARY.
Creating this PR because writing comments on commits keep disappearing.
Checkout the latest commit to see the _C.pyi changes 66a9b5f
Originally, this file was generated from the C++ function signatures. It is now generated from the
TORCH_LIBRARYschemas, with default argument values taken from_C.py.The differences fall into the following categories:
.pyisignatures to differ from the actual Python API. The new generator uses the correct Python parameter names, so the generated.pyifile now matches the keyword arguments accepted by the Python bindings. This does not change runtime behavior or break backwards compatibility; it simply makes the type stubs accurate.TORCH_LIBRARYschemas represent string default values using single quotes (') instead of double quotes (").(*args, **kwargs). To register these functions withTORCH_LIBRARY, they were replaced with named functions and their arguments have been parsed like the rest of the functions. As a result, the generated.pyifile now contains more informative and accurate function signatures._slice_symm_buffer_for_mega_moefunction has been added.