Skip to content

Fix ps_decoder2 input width when pert_dim is None; add regression test and CI - #51

Merged
davidliwei merged 3 commits into
mainfrom
fix/ps-decoder2-input-dim
Sep 2, 2026
Merged

Fix ps_decoder2 input width when pert_dim is None; add regression test and CI#51
davidliwei merged 3 commits into
mainfrom
fix/ps-decoder2-input-dim

Conversation

@davidliwei

@davidliwei davidliwei commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Fixes #50

Problem

Training with pred_lochness_next=True (e.g. notebook/train_pertTF_with__lochNESS.ipynb) crashes in the first forward pass:

RuntimeError: mat1 and mat2 shapes cannot be multiplied (128x64 and 32x32)

ps_decoder2 was built with geneinput=0 whenever pert_dim was not given, so its first layer was Linear(d_model, d_model). The perturbation encoder defaults pert_dim to d_model in that case, so the concatenated [cell_emb_orig, pert_emb_next] input is 2 * d_model wide.

Changes

  • Fix (perttf/model/pertTF.py): build ps_decoder2 with the same local pert_dim the encoder uses, so decoder input width always matches encoder output width. One line.
  • Regression test (tests/test_pertTF_model.py): builds PerturbationTFModel with the notebook's arguments and checks the decoder width and a full forward pass. Both tests fail on main with the error above and pass with the fix.
  • CI (.github/workflows/ci.yml, pyproject.toml): GitHub Actions runs pytest on every push and PR, Python 3.10 and 3.12, CPU-only torch. Adds a [test] extra. First run on this branch: https://github.com/davidliwei/pertTF/actions/runs/33589260892 (both jobs green, ~75 s each).

Not addressed

An explicit pert_dim != d_model still fails at pertTF.py:156 when perturbation labels are fed into the transformer input. Pre-existing and independent; noted in #50.

🤖 Generated with Claude Code

davidliwei and others added 3 commits September 1, 2026 23:43
PSDecoder for the lochNESS-next head was built with geneinput=0 whenever
pert_dim was not given, giving a first layer of Linear(d_model, d_model).
The perturbation encoder defaults pert_dim to d_model in that case, so the
concatenated [cell_emb_orig, pert_emb_next] input is 2*d_model wide and the
first forward pass fails with
"mat1 and mat2 shapes cannot be multiplied (128x64 and 32x32)".

Reuse the local pert_dim already computed for the encoder so the decoder's
input width always matches the encoder's output width.

Fixes #50

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9KDzjgXDQg5zs9uVybiuR
Builds PerturbationTFModel with pred_lochness_next=True and no pert_dim,
mirroring notebook/train_pertTF_with__lochNESS.ipynb, and checks that
ps_decoder2's first layer accepts 2 * d_model and that a forward pass with
pert_labels_next succeeds. Both tests fail on main with
"mat1 and mat2 shapes cannot be multiplied" and pass with the fix.

Run with: python -m pytest tests/

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9KDzjgXDQg5zs9uVybiuR
Installs CPU-only torch from the PyTorch wheel index, then the package
with a new [test] extra (pytest, torch>=2.2, tqdm), and runs pytest on
Python 3.10 and 3.12. torch>=2.2 is required for torch.nn.attention.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9KDzjgXDQg5zs9uVybiuR
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T04:17:44.182389Z 970c7cd PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@davidliwei
davidliwei merged commit 8838d72 into main Sep 2, 2026
4 checks passed
@davidliwei
davidliwei deleted the fix/ps-decoder2-input-dim branch September 2, 2026 13:57
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.

ps_decoder2 built with wrong input width when pert_dim is None (pred_lochness_next training crashes)

1 participant