Repository navigation
Conversation
wloiola7
approved these changes
Nov 4, 2026
This branch has not been deployed
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.
Fixes #138
Two fixes for
_FP16Casting:Guards
torch.topkon ANE: Runningaten.topkin FP16 on Apple Neural Engine packs two 16-bit indices into each 32-bit output word (Apple Radar FB24904516 / FP16 model silently returns wrong outputs with default specialization on iPhone 17 Pro; CPU-only, GPU-preferred and FP32 are correct coreai-torch#115), corrupting downstream indexing in detection models like RF-DETR and YOLO. Addedguard_ane_topk: bool = True(with opt-out) to keeptopkin FP32 with boundary casts.Downcasts multi-output containers at
operator.getitem: Multi-output operations returning tuples (topk,split,chunk) that ran in FP32 skipped downcast insertion because container tuples lack.dtype. Extracted FP32 tensors leaked into downstream layers, forcing them into FP32 and triggering runtime weight upcasts. We insert downcasts on extracted float elements inoperator.getitem(preserving FP32 if the activation overflowed during calibration or was explicitly ignored).Tested with
pytest tests/casting/ -v(142 passed) andmake check(all 25 checks passed).