Skip to content

Expose PZ two-jet polynomial trace in benchmark notebook - #184

Merged
MoritzMaibaum merged 1 commit into
better-intfrom
codex/update-pz-diagnostic-notebook-for-polynomials
Jul 23, 2026
Merged

Expose PZ two-jet polynomial trace in benchmark notebook#184
MoritzMaibaum merged 1 commit into
better-intfrom
codex/update-pz-diagnostic-notebook-for-polynomials

Conversation

@MoritzMaibaum

Copy link
Copy Markdown
Collaborator

Motivation

  • Make the polynomial-zonotope two-jet propagation inspectable by exposing the actual propagated input/domain and per-layer Y, J, and H polynomials prior to squaring and integration so users can debug monomial growth and approximation behavior.
  • Keep notebook output opt-in and size-bounded to avoid overwhelming interactive sessions as monomial counts grow.

Description

  • Updated notebooks/affine_pz_twojet_adaquad_benchmarks.ipynb to call model.eval_pz_twojet(cell.domain, return_trace=True) and reuse trace_result.final for subsequent norm integrand construction so the traced polynomials correspond to the computed norms.
  • Added imports for inline display and rendering (IPython.display.Markdown, display) and pz_to_latex, and added configurable display limits TRACE_MAX_TERMS, TRACE_PRECISION, and TRACE_COMPONENT_LIMIT plus TRACE_DISPLAY_MARKDOWN and TRACE_OUTPUT_PATH for a repo-local notebooks/generated/pz_twojet_trace.md output.
  • Implemented helper functions that summarize term counts and max degree, render a size-limited set of scalar components with pz_to_latex, write the generated Markdown/LaTeX trace file, and optionally display it in the notebook; kept the existing y_sq, j_sq, h_sq computation after trace rendering.

Testing

  • Ran git diff --check to ensure no whitespace/git-diff issues and it passed.
  • Validated notebook JSON formatting with python -m json.tool notebooks/affine_pz_twojet_adaquad_benchmarks.ipynb which succeeded, and compiled each code cell via Python compile(...) to check for syntax errors which also succeeded.
  • Attempted to execute the modified notebook cell(s) in this environment to exercise the trace writer, but a partial run that executes notebook setup cells failed due to missing runtime dependencies (numpy/matplotlib) so full runtime execution was not completed here.

Codex Task

@MoritzMaibaum
MoritzMaibaum merged commit e991e22 into better-int Jul 23, 2026
1 check passed
@MoritzMaibaum
MoritzMaibaum deleted the codex/update-pz-diagnostic-notebook-for-polynomials branch July 23, 2026 17:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f1b5f43e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

" return\n",
" total = _pz_component_count(z)\n",
" for flat_idx in range(min(total, limit)):\n",
" multi = tuple(int(i) for i in torch.unravel_index(torch.tensor(flat_idx, device=z.center.device), z.center.shape))\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle tuple-backed PZ components in the trace renderer

When running this notebook as written, domain = IntervalTensor.from_bounds(...) stores bounds as Python tuples, and PZIntegrationCell.from_affine_box(domain) builds a tuple-backed PolynomialZonotope; the first _render_pz_components("X", cell.domain) then reaches this line with z.center as a tuple, so .device/.shape raises AttributeError before the direct PZ norms are computed. Use z.shape and a fallback scalar-index iterator (as the diagnostics cell already does), or keep the integration-cell domain torch-backed.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant