Skip to content

Fix MPI crash in Observation when allocate_tod=False#491

Merged
paganol merged 2 commits intomasterfrom
fix_tod_mpi
Feb 3, 2026
Merged

Fix MPI crash in Observation when allocate_tod=False#491
paganol merged 2 commits intomasterfrom
fix_tod_mpi

Conversation

@paganol
Copy link
Copy Markdown
Member

@paganol paganol commented Feb 3, 2026

This PR addresses a TypeError that occurs when initializing an Observation with allocate_tod=False in an MPI environment.

When allocate_tod is set to False, the Time-Ordered Data (TOD) attributes (e.g., self.tod) are initialized as None. However, the Observation.__init__ method immediately calls setattr_det_global to synchronize detector metadata. Inside setattr_det_global, an assertion attempts to verify the length of the incoming metadata against the length of the TOD array using len().

Because len(None) is an invalid operation, the simulation crashes during the observation creation phase.

Changes:

  • litebird_sim/observations.py: Modified setattr_det_global to check if the TOD attribute is None before attempting to validate its length.

  • Added a conditional check: the assertion is now only executed if tod_list is present and the corresponding TOD attribute has been allocated.

@paganol paganol added the bug Something isn't working label Feb 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 3, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  litebird_sim
  observations.py 788-799
Project Total  

This report was generated by python-coverage-comment-action

@paganol paganol merged commit 9f46e0d into master Feb 3, 2026
12 checks passed
@paganol paganol deleted the fix_tod_mpi branch February 3, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant