You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Arm backend: Make int64 representable under EXT-INT64 (1/3) - #24128
Makes int64 representable in the TOSA backend when a spec declares EXT-INT64. keeps_int64() gates it on the INT profile plus the extension, TosaArg accepts the dtype, the cast table is restricted to the bool and i32 pairs the extension defines, and the dialect validators and node visitors accept int64 for the operators it covers.
This is inert on its own. The narrowing passes still convert int64 to int32 before anything reaches these paths, so behavior is unchanged for every existing spec string. Part 1 of 3.
Test Plan
44 single-op models under TOSA-1.0+INT: identical to main.
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Scalar precision loss and inconsistent partitioner checks can cause incorrect results or lowering failures, while the new tests do not verify int64 preservation.
Skipping placeholder narrowing lets unsupported int64 operators reach lowering. Under TOSA-1.1+INT+int64, BoolBitwiseSupported accepts int64 x | y, but the BITWISE_OR dialect validator and visitor only accept int8/int16/int32. Lowering then raises instead of leaving the operation on the portable path; BITWISE_XOR has the same mismatch. Keep the narrowing skip, but reject these unsupported dtype/operator combinations during partitioning, or implement int64 lowering where the TOSA specification permits it.
Assert delegation and preservation of INT64 operands
backends/arm/test/misc/test_int64.py:158
These cases only check that conversion completes; they do not assert delegation or preserved INT64 operands. They can therefore pass if the operators fall back to CPU or are silently narrowed. The small inputs would also hide narrowing in an output comparison. Assert that the expected operators delegate and retain INT64 operands, including the inputs to GREATER whose output is BOOL. Alternatively, assert delegation and compare execution results using values outside the int32 range.
Allow extension-enabled int64 comparison inputs in negative checks
The dialect now accepts int64 comparisons under TOSA-1.1+FP+int64, but _floating_profile_negative_checks() still installs CheckFPComparisonInputs whenever the INT profile is absent. That check rejects int64 inputs, so eq/gt/ge with int64 placeholders remain undelegated under this valid spec. Pass the specification to the negative check and allow extension-enabled int64 comparison inputs while preserving rejection for specs without the extension.
Add delegation, operator, and INT64 preservation assertions
backends/arm/test/misc/test_int64.py:158
This chain checks only that lowering completes. It still passes if every operation falls back to CPU or if tensors are narrowed to int32; it neither asserts delegation nor executes or inspects the lowered computation. Add delegate-count and no-leftover-operator assertions, then verify INT64 tensor dtypes in the delegated graph or compare exact outputs with width-sensitive inputs outside the int32 range. The current small inputs would not expose narrowing even if output comparison were added.
meta-claBot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Oct 23, 2026
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contributions! I've left a few comments on the PR. Personally, I'd prefer to split this into several smaller PRs if feasible:
General int64 lowering support
Avoid unnecessary int64->int32 narrowing under the INT+EXT-INT64 profile
Handle other corner cases in int64 lowering
An independent fix in backends/transforms/replace_scalar_with_tensor.py
FYI, we also have some internal INT64-related patches in progress. I believe @oscarandersson8218 and @Erik-Lundell can provide more context on this work.
The reason will be displayed to describe this comment to others. Learn more.
Maybe use get_context_spec to get the tosa_profile in the passes directly instead of passing the tosa_spec to the pass. @oscarandersson8218@Erik-Lundell Have you reached an agreement to use which style?
The reason will be displayed to describe this comment to others. Learn more.
I think it is required. keeps_int64() is support_integer() and support_extension("int64"), so the INT profile has to be declared. Dropping the support_integer() half means TOSA-1.1+FP+int64 keeps int64 even though it declares only FP, which introduces new errors under the FP profile.
abm-77
changed the title
Arm backend: Keep int64 tensors under the int64 extension
Arm backend: Make int64 representable under EXT-INT64 (1/3)
Oct 27, 2026
I have cut this PR down to the first part, which makes int64 representable under EXT-INT64. It is inert on its own, since the narrowing passes still convert int64 to int32 before anything reaches it.
The other two parts are ready on branches, and I will open them as PRs once this one lands:
arm-int64-narrowing makes the narrowing passes consult the spec and adds the tests
I tried to put these up as a GitHub stack, but a pull request base has to be a branch in this repository and mine are on a fork, so the chaining is rejected. Is there a way you normally handle stacked PRs from forks, or would you rather I open all three now, either against main or on top of each other?
The reason will be displayed to describe this comment to others. Learn more.
TosaArg.__validate() in backends/arm/tosa/mapping.py checks whether the required extension is enabled when constructing a TosaArg. Could we add ts.DType.INT64 directly to input_dtypes, as we already do for ts.DType.BF16, to follow the existing pattern?
The reason will be displayed to describe this comment to others. Learn more.
EXT-INT64 doesn't require PRO-INT. PRO-FP + EXT-INT64 is valid. For example, GATHER with FP32 input and INT64 indices is supported under this combination.
This might become clearer once EXT-INT64 is included in an officially released version of the TOSA specification.
The reason will be displayed to describe this comment to others. Learn more.
Could we move the dtype == torch.int64 check to the call sites and rename this helper to validate_int64_support(op)? This would keep dtype branching consistent with the surrounding code while sharing the extension check.
This branch has not been deployed
No deployments
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
ciflow/trunkCLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.community: contributionPRs coming from community (excluding hardware partners)module: armIssues related to arm backendpartner: armFor backend delegation, kernels, demo, etc. from the 3rd-party partner, Armrelease notes: armChanges to the ARM backend delegate
5 participants
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.
Summary
Makes int64 representable in the TOSA backend when a spec declares
EXT-INT64.keeps_int64()gates it on the INT profile plus the extension,TosaArgaccepts the dtype, the cast table is restricted to theboolandi32pairs the extension defines, and the dialect validators and node visitors accept int64 for the operators it covers.This is inert on its own. The narrowing passes still convert int64 to int32 before anything reaches these paths, so behavior is unchanged for every existing spec string. Part 1 of 3.
Test Plan
44 single-op models under
TOSA-1.0+INT: identical to main.This PR was authored with Claude Code.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani