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

Add a Null backend #112

Merged
merged 4 commits into from
Jun 16, 2024
Merged

Conversation

alcrene
Copy link
Contributor

@alcrene alcrene commented Jun 9, 2024

The NullBackend gobbles up draws without storing them

Possible use cases include

  • Online computations: Draws are used and discarded immediately, allowing for much larger sample spaces.
  • Profiling: To use as a baseline, to measure compute time & memory before allocating memory for draws.
    Comparing with another backend would then show how much overhead it adds.

alcrene referenced this pull request in alcrene/mcbackend Jun 9, 2024
Alexandre René and others added 4 commits June 16, 2024 12:13
A null storage for draws from a chain: gobbles up draws without storing them

Possible use cases include
- Online computations: Draws are used and discarded immediately, allowing for much larger sample spaces.
- Profiling: To use as a baseline, to measure compute time & memory before allocating memory for draws.
  Comparing with another backend would then show how much overhead it adds.
Tests were copied from test_backend_numpy and the parts checking the `_samples` array removed.

Fixed issue:
- Reset default preallocation to 1_000, like with NumPyBackend:
  it is still used for the stats array, so it makes sense to use
  a reasonable default.
- Preallocate = 0 no longer switches the allocation to object arrays,
  in contrast to NumPyBackend
  - IMO this is a bug in NumPyBackend: `grow_append` cannot know if
    ``preallocate = 0`` was used; it only looks at the `rigid` value
    to determine how to append.
  - Without this change, `grow_append` will always fail when we use
    `preallocate = 0` with multivariate statistics.
Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

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

I rebased it, and did a little refactor to make the pre-commit checks pass

@michaelosthege michaelosthege merged commit 512e0a7 into pymc-devs:main Jun 16, 2024
1 check passed
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.

2 participants