-
Notifications
You must be signed in to change notification settings - Fork 613
Preserve DASC numeric argument compatibility #2396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kaix-nv
merged 2 commits into
feature/dasc-state-sparsity-review-public-api
from
feature/dasc-state-sparsity-review-validation-source
Sep 11, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMPORTANT Compatibility] The normalized exception set misses
RuntimeError, which is exactly what a non-scalar tensor raises — so the publicValueErrorcontract this PR is consolidating now leaks for a whole input class that the previous version rejected cleanly.What changed: the version removed from
policy.pygated onisinstance(epsilon, float | int)first, so any non-float/intargument (including everytorch.Tensor) took theValueErrorpath. This one drops the isinstance gate and relies onmath.isfiniteraising a normalizable exception instead. That holds for lists/strings/complex (TypeError), numpy arrays (TypeError), and oversized ints (OverflowError) — butmath.isfinitereaches a tensor's__float__, and torch raisesRuntimeError: a Tensor with N elements cannot be converted to Scalarfor any tensor whosenumel() != 1(including empty tensors).RuntimeErroris not in theexcepttuple, so it propagates unchanged out ofmtss.analyze_gdn_decayandmtss.compute_gdn_decay_horizons.Why it matters: the new
test_analysis_accepts_tensor_scalar_argumentsdeliberately makes 0-d tensors a supported input, which makesepsilon=torch.tensor([1e-3, 2e-3])(or a strayA_log-shaped tensor) a very plausible caller mistake rather than an exotic one. Callers that follow the documented contract and wrap these entry points inexcept ValueErrorwill crash instead of surfacing the intended message — a regression relative to the base branch, on the exact axis this PR is about.0.0 < epsilon < 1.0and theif not epsilon_is_validbool conversion have the same exposure for multi-element tensors.Fix: add
RuntimeErrorto both handlers (a targeted follow-up test with a 2-element tensor would lock it in):There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #2397 with a stricter scalar boundary rather than catching arbitrary framework RuntimeError. The annotated inputs now require numbers.Real; NumPy real scalars remain accepted, while scalar and multi-element tensors are rejected uniformly with ValueError before math.isfinite. Multi-element regressions cover both public entry points.