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

Adding model with cycle consistency and VampPrior #2421

Draft
wants to merge 75 commits into
base: main
Choose a base branch
from

Conversation

Hrovatin
Copy link

@Hrovatin Hrovatin commented Jan 19, 2024

Closes #2383

@Hrovatin Hrovatin changed the title Adding model with cycle consistency and VampPrior, closes https://github.com/scverse/scvi-tools/issues/2383 Adding model with cycle consistency and VampPrior Jan 19, 2024
Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: Patch coverage is 88.20375% with 44 lines in your changes missing coverage. Please review.

Project coverage is 84.40%. Comparing base (c53efe0) to head (df4b335).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/scvi/external/sysvi/_base_components.py 72.17% 32 Missing ⚠️
src/scvi/external/sysvi/_model.py 90.90% 7 Missing ⚠️
src/scvi/external/sysvi/_module.py 97.01% 4 Missing ⚠️
src/scvi/external/sysvi/_priors.py 97.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2421      +/-   ##
==========================================
- Coverage   84.81%   84.40%   -0.42%     
==========================================
  Files         173      178       +5     
  Lines       14793    15168     +375     
==========================================
+ Hits        12547    12802     +255     
- Misses       2246     2366     +120     
Files with missing lines Coverage Δ
src/scvi/external/__init__.py 100.00% <100.00%> (ø)
src/scvi/external/sysvi/__init__.py 100.00% <100.00%> (ø)
src/scvi/external/sysvi/_priors.py 97.67% <97.67%> (ø)
src/scvi/external/sysvi/_module.py 97.01% <97.01%> (ø)
src/scvi/external/sysvi/_model.py 90.90% <90.90%> (ø)
src/scvi/external/sysvi/_base_components.py 72.17% <72.17%> (ø)

... and 5 files with indirect coverage changes

Copy link
Contributor

@martinkim0 martinkim0 left a comment

Choose a reason for hiding this comment

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

Hey, thanks for putting in this PR! A couple of high-level comments for now.

Could you restructure the files as follows?

  • csi/model/_model.py -> csi/_model.py
  • csi/model/_utils.py -> csi/_utils.py
  • csi/module/_module.py -> csi/_module.py
  • csi/module/_priors.py -> csi/_priors.py
  • csi/nn/_base_components.py -> csi/_components.py
  • csi/train/_trainingplans.py -> csi/_trainingplans.py
  • Refactor csi/module/_module.py to use scvi.module.base.LossOutput instead of our previous LossRecorder and remove csi/module/_loss_recoder.py
  • If the plan is to directly inherit from UnsupervisedTrainingMixin without any major changes except setting _training_plan_cls, this can be done within _model.py by directly subclassing UnsupervisedTrainingMixin and setting _training_plan_cls there instead, so I would recommend doing that and deleting csi/model/_training.py

I can take a look at compatibility with scArches in the next round.

We're also slowly migrating to newer typing annotations in Python. Could you add a from __future__ import annotations to the top of every file (except __init__.pys) and migrate typing from:

  • Optional[x] -> x | None
  • Union[x, y] -> x | y
  • List[x] -> list[x]
  • Tuple[x] -> tuple[x]
  • Callable -> callable
  • There's more, I don't remember all of them. The pre-commit hooks will warn about missing ones.

@martinkim0 martinkim0 added this to the scvi-tools 1.2.0 milestone Jan 19, 2024
@Hrovatin
Copy link
Author

I added changes and adapted tutorial accrordingly

@martinkim0
Copy link
Contributor

Thanks for addressing the comments! I'll take another pass at it soon.

Copy link
Contributor

@martinkim0 martinkim0 left a comment

Choose a reason for hiding this comment

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

Some minor typing/style comments as well as implementation ones. I still don't understand all parts of the implementation so I will take another pass at this

scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_model.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_model.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_model.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_module.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_priors.py Outdated Show resolved Hide resolved
@martinkim0 martinkim0 added the cuda tests Run test suite on CUDA label Feb 5, 2024
@Hrovatin
Copy link
Author

@canergen Sorry, I am no longer active there and overlooked that you responded. I sent you my personal email over zolip to arrange a meeting.

@ori-kron-wis
Copy link
Collaborator

ori-kron-wis commented Oct 8, 2024

@Hrovatin there are some fixes that need to be done regarding the pre-commit ruff rules (everything that involves linting the code, formatting it etc'..) to be compatible with the rest of our repo and package.
So those errors can be found under Details in the pre-commits.co-pr test below.
Once this is fixed we can continue.
LMK if you need help.

@Hrovatin Hrovatin marked this pull request as draft October 19, 2024 07:23
@Hrovatin
Copy link
Author

The changes I pushed today are not yet ready for review. Missing docs, cleanup, and test on real data.

@Hrovatin
Copy link
Author

Hrovatin commented Oct 27, 2024

@canergen @ori-kron-wis The PR is now ready for review.

@ori-kron-wis Can you help me fix the cuda test err? For some reason, it can not import SysVI, although for me, it works locally. I also was not able to test on GPU since I only have MacOS access and I get the err where mps is detected but not used. - If you have any solutions for that also please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda tests Run test suite on CUDA P1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding cycle consistency loss and VampPrior to scVI
4 participants