Skip to content

WASM: use int64 in comb_jit for consistent overflow guards on wasm32 - #942

Open
kp992 wants to merge 9 commits into
QuantEcon:mainfrom
kp992:wasm-intp-audit
Open

WASM: use int64 in comb_jit for consistent overflow guards on wasm32#942
kp992 wants to merge 9 commits into
QuantEcon:mainfrom
kp992:wasm-intp-audit

Conversation

@kp992

@kp992 kp992 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #929. Part of #925 (Phase 1).

comb_jit was typed intp(intp, intp), making the overflow guard trip at 2**31-1 on wasm32 instead of 2**63-1. This caused simplex_grid to reject grids that fit comfortably in memory, and could silently wrap in simplex_index for near-boundary inputs.

  • Change comb_jit signature to int64(int64, int64) and update the INT64_MAX guard throughout
  • Update num_compositions_jit docstring
  • Update TestCombJit to test against np.int64 limits (platform-agnostic)
  • Update overflow comments in test_gridtools.py
  • Add test_simplex_grid_comb_int64 to the WASM smoke suite

Assumes #938 as baseline.

kp992 and others added 8 commits August 14, 2026 17:26
Bare pytest from the repo root (as run by ci_np2.yml) died collecting
ci/wasm/test_jupyterlite.py because playwright is not installed in the
test environments.  testpaths keeps bare pytest collecting exactly the
package tests as before; ci/wasm stays opt-in via an explicit path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The wasm job exercises the released conda-forge package (quantecon is
not on emscripten-forge-4x), so it cannot gate PR source and needs its
own red/green iteration; it will be developed in a follow-up PR under
issue QuantEcon#933 with the review fixes applied (drop --with-deps, add
pytest-timeout, needs: native, no _site cache).

The native gate stays on every PR and gets timeout-minutes so a hang
cannot burn the 6-hour job limit again (the last run's Playwright
browser install hung for the full limit).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Each cell is wrapped in try/finally printing a unique token and _run
waits for that token in the output area.  This removes the fragile
kernel-status selector, the stale-idle race (the indicator may not have
flipped to busy yet), and the traceback-prone substring assertions --
tests now assert on unique uppercase sentinels.  insert_text replaces
keyboard.type so multi-line cells are not mangled by the console's
run-on-Enter binding and auto-indent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Nothing ships smoke_test.py into the JupyterLite site yet, so pytest in
the kernel env and the in-kernel run described by the docstring are
deferred to the QuantEcon#933 wiring.  The IS_EMSCRIPTEN/xfail branches stay:
inert natively, they document the expected Emscripten behaviour.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coveralls

coveralls commented Aug 19, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 90.78%. remained the same — kp992:wasm-intp-audit into QuantEcon:main

@oyamad

oyamad commented Aug 19, 2026

Copy link
Copy Markdown
Member

@kp992 Thanks, but I remember the np.intp typing in comb_jit was intentional. Its output is used as an index or size. So I would keep intp.

(simplex_index is a pure Python function by the way.)

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.

WASM: audit 32-bit intp behaviour on wasm32 (overflow guards, simplex_index wrapping, dtypes)

4 participants