Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 12, 2025

An ActivitySim model run can crash with a FloatingPointError: overflow encountered in multiply when consolidating memory logs due to timestamp overflow issues in pandas datetime conversion. This affects production runs where users lose all model results despite the core modeling completing successfully.

The error occurs in mem.consolidate_logs() when processing timestamp data:

# In mem.py line 45
return pd.to_datetime(bin, unit="s", origin="unix")

When timestamp values are corrupted or extremely large, this causes an overflow during the conversion process, crashing the entire model run.

This PR implements an intermediate fix by wrapping the mem.consolidate_logs(state) call in a try-except block:

# Before
mem.consolidate_logs(state)

# After  
try:
    mem.consolidate_logs(state)
except Exception as e:
    logger.warning(
        f"Memory log consolidation failed with error: {e}. "
        "This does not affect model results, but memory usage logs will not be consolidated."
    )

This provides graceful degradation where the core model functionality continues to work even when the secondary memory logging feature fails. Users receive a clear warning message explaining what happened and that their model results are unaffected.

As noted by @bhargavasana, "One in five runs of ours are failing because of this" - this fix addresses that immediate production issue while preserving all existing functionality.

Fixes #959.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Contributor Author

Copilot AI commented Sep 12, 2025

@jpn-- 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI changed the title [WIP] Overflow error when coalescing memory logs Wrap mem.consolidate_logs in try-except to prevent model run crashes Sep 12, 2025
Copilot AI requested a review from jpn-- September 12, 2025 13:38
@jpn-- jpn-- marked this pull request as ready for review September 26, 2025 12:21
@jpn-- jpn-- merged commit e1f9b2a into main Sep 26, 2025
18 of 19 checks 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.

Overflow error when coalescing memory logs

2 participants