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

Scatter parameters once in TPI #925

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11"]

steps:
- name: Checkout
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.11.6] - 2024-04-19 01:00:00

### Added

- Scatters parameters once in `TPI.py`
- Removes Python 3.9 tests from `build_and_test.yml`


## [0.11.5] - 2024-04-11 12:00:00

### Added
Expand Down Expand Up @@ -219,6 +227,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Any earlier versions of OG-USA can be found in the [`OG-Core`](https://github.com/PSLmodels/OG-Core) repository [release history](https://github.com/PSLmodels/OG-Core/releases) from [v.0.6.4](https://github.com/PSLmodels/OG-Core/releases/tag/v0.6.4) (Jul. 20, 2021) or earlier.


[0.11.6]: https://github.com/PSLmodels/OG-Core/compare/v0.11.5...v0.11.6
[0.11.5]: https://github.com/PSLmodels/OG-Core/compare/v0.11.4...v0.11.5
[0.11.4]: https://github.com/PSLmodels/OG-Core/compare/v0.11.3...v0.11.4
[0.11.3]: https://github.com/PSLmodels/OG-Core/compare/v0.11.2...v0.11.3
Expand Down
17 changes: 13 additions & 4 deletions ogcore/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"""
ENFORCE_SOLUTION_CHECKS = True

"""
A global future for the Parameters object for client workers.
This is scattered once and place at module scope, then used
by the client in the inner loop.
"""
scattered_p = None


def get_initial_SS_values(p):
"""
Expand Down Expand Up @@ -529,6 +536,12 @@ def run_TPI(p, client=None):
results

"""
global scattered_p
if client:
scattered_p = client.scatter(p, broadcast=True)
else:
scattered_p = p

# unpack tuples of parameters
initial_values, ss_vars, theta, baseline_values = get_initial_SS_values(p)
(B0, b_sinit, b_splus1init, factor, initial_b, initial_n) = initial_values
Expand Down Expand Up @@ -719,10 +732,6 @@ def run_TPI(p, client=None):

euler_errors = np.zeros((p.T, 2 * p.S, p.J))
lazy_values = []
if client:
scattered_p = client.scatter(p, broadcast=True)
else:
scattered_p = p
for j in range(p.J):
guesses = (guesses_b[:, :, j], guesses_n[:, :, j])
lazy_values.append(
Expand Down
2 changes: 1 addition & 1 deletion ogcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
from ogcore.txfunc import *
from ogcore.utils import *

__version__ = "0.11.5"
__version__ = "0.11.6"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
target-version = ["py39", "py310", "py311"]
target-version = ["py310", "py311"]
include = '\.pyi?$'
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="ogcore",
version="0.11.5",
version="0.11.6",
author="Jason DeBacker and Richard W. Evans",
license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
description="A general equilibribum overlapping generations model for fiscal policy analysis",
Expand Down Expand Up @@ -44,7 +44,6 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
Loading