Skip to content
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

re-add support for tf.function with abstract shape #5089

Merged
merged 7 commits into from
Jan 24, 2024

Conversation

timmysilv
Copy link
Contributor

@timmysilv timmysilv commented Jan 22, 2024

Context:
While working on adding poetry support, this qcut test failed in a familiar way - it tried to check batching with an abstract TensorShape (of None)! Sub-context: it hasn't been run for a very long time because it needs networkx<3 and poetry is making me use that, unlike today's CI runs. I thought I had fixed this in #4911 mostly because tests stopped failing. However, they (eg. the test that I am changing here) stopped failing because we were no longer running the batch-size evaluation. It's a niche corner case (see that PR description for more details), but it used to pass and it now fails on master.

Description of the Change:

  • Re-add the previous functionality to Operator._check_batching() where it skips the check if the operator params are abstract TF tensors with a shape of None in its signature within a tf.function
  • Removed the MyRX from the test because it only made sense when I added it (in other words, before I re-defined Operator.ndim_params in the linked PR), but am now calling op.batch_size to ensure the loading of the property

Benefits:
Tests that used to pass are passing again, specifically if you use tf.function with input_signature=(tf.TensorSpec(shape=None))

Possible Drawbacks:
Additional try-except logic (re-)added to Operator._check_batching() which is called frequently

Copy link

codecov bot commented Jan 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4e2e344) 99.68% compared to head (43234dc) 99.68%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5089      +/-   ##
==========================================
- Coverage   99.68%   99.68%   -0.01%     
==========================================
  Files         392      392              
  Lines       35844    35578     -266     
==========================================
- Hits        35732    35465     -267     
- Misses        112      113       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@timmysilv timmysilv requested review from dwierichs and a team January 22, 2024 20:13
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

I recall we made batch checking lazy for tapes. Curious to see how much of a difference this PR actually makes with that change in mind. Do you have any light benchmarks?

@timmysilv
Copy link
Contributor Author

not personally, I do believe @albi3ro mentioned the performance improvement so she might have some numbers handy. Either way, this change is now concerned with correctness because I broke something that used to work, so I'd like to restore functionality

@timmysilv timmysilv requested a review from a team January 23, 2024 22:36
@timmysilv
Copy link
Contributor Author

[sc-55335]

@timmysilv timmysilv enabled auto-merge (squash) January 24, 2024 16:39
@timmysilv timmysilv merged commit 24cf8f6 into master Jan 24, 2024
35 checks passed
@timmysilv timmysilv deleted the fix-tf-ndim-batching-check branch January 24, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants