Skip to content

Conversation

@mikaylagawarecki
Copy link
Contributor

@mikaylagawarecki mikaylagawarecki commented Jul 30, 2025

…(pending header-onlyness)

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Jul 30, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159508

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 188f656 with merge base a44a0d3 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

mikaylagawarecki added a commit that referenced this pull request Jul 30, 2025
…(pending header-onlyness)

ghstack-source-id: 6cde171
Pull Request resolved: #159508
…le::Tensor (pending header-onlyness)"

needs ScalarType.h, which needs to be header-only




[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Aug 4, 2025
…(pending header-onlyness)

ghstack-source-id: b06a267
Pull Request resolved: #159508
…le::Tensor (pending header-onlyness)"

needs ScalarType.h, which needs to be header-only




[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Aug 11, 2025
ghstack-source-id: 4c53a24
Pull Request resolved: #159508
Comment on lines +407 to +416
if not has_function_variant:
# Functions with both function and method variants can use the at::{*}_symint version
# (e.g., narrow -> at::narrow_symint), BUT
# Method-only functions with symint parameters should use at::symint:: namespace
# Remove the _symint suffix since at::symint:: namespace uses the base name
# (e.g., new_empty -> at::symint::new_empty<c10::SymInt>)
base_name = cpp_sig.name()
base_name = base_name.removesuffix("_symint") # Remove "_symint" suffix
return f"at::symint::{base_name}<c10::SymInt>"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the relevant part here

pytorch/torchgen/gen.py

Lines 717 to 739 in 6d91d6d

if Variant.function in f.variants:
result += f"""
// aten::{f.func}
inline {sig.decl()} {{
return at::_ops::{f.func.name.unambiguous_name()}::call({exprs_str});
}}"""
# The template function can be used from template situations
# where you want to switch between the symint or not version
# depending on a template argument
#
# NB: we ALWAYS generate this even for methods. But we put it in
# this header so it can take advantage of per-op headers
if has_symint:
result += f"""
namespace symint {{
template <typename T, typename = std::enable_if_t<std::is_same_v<T, {intlike_t}>>>
{sig.decl(suppress_symint_suffix=True)} {{
return at::_ops::{f.func.name.unambiguous_name()}::call({exprs_str});
}}
}}
"""
return result

@mikaylagawarecki mikaylagawarecki changed the title Add new_empty to torch::stable + dtype/scalar_type to stable::Tensor (pending header-onlyness) Add new_empty (with dtype argument only) to torch::stable Aug 11, 2025
needs ScalarType.h, which needs to be header-only




[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Aug 11, 2025
ghstack-source-id: ac037b9
Pull Request resolved: #159508
@mikaylagawarecki mikaylagawarecki marked this pull request as ready for review August 11, 2025 21:31
// Handle dtype - use input tensor's dtype if not specified
int32_t target_dtype;
if (dtype.has_value()) {
target_dtype = static_cast<int32_t>(dtype.value());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm lol is this actually stable...this looks to expose a detail on how dtype is encapsulated. Should we/I write that translation layer from the headeronly ScalarType to their corresponding shim aoti_torch_get_dtype... maybe there's no other way to hide this

Copy link
Contributor Author

@mikaylagawarecki mikaylagawarecki Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would be nice if you could write that!

Can you describe what you mean in more detail of what the translation layer would do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like a pair of utils that take in and return ScalarType::BFloat`6 -> aoti_torch_dtype_bfloat16 and vice versa. I'll prioritize writing this (i think it;d be helpful for my Tensor scalar_type PR too)

cpp_sig = gen_static_dispatch_backend_call_signature(sig, f)

if backend_index is None:
# Check if this is a symint function and if the function only has method variants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other ops we expect to go through this branch? Maybe list new_empty as an example here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm it's listed below (when all the if checks pass) on 412

Copy link
Contributor

@janeyx99 janeyx99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, this is making me think i need to land my scalartype liaisoning asap so we aren't exposing weird details by accident

mikaylagawarecki added a commit that referenced this pull request Aug 19, 2025
ghstack-source-id: 4c8f1d6
Pull Request resolved: #159508
mikaylagawarecki added a commit that referenced this pull request Aug 19, 2025
ghstack-source-id: d64e073
Pull Request resolved: #159508
@mikaylagawarecki mikaylagawarecki added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 19, 2025
@mikaylagawarecki mikaylagawarecki added the release notes: build release notes category label Aug 19, 2025
@mikaylagawarecki
Copy link
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the gh/mikaylagawarecki/331/head branch September 19, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants