You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RuntimeError: mat1 and mat2 shapes cannot be multiplied during sampling with finetuned_replogle.ckpt #4
Hello! I'm trying to run the sampling script using the provided finetuned_replogle.ckpt.
It seems this checkpoint was trained on 12626 genes, but script defaults to a 2000-gene space, causing a shape mismatch error: RuntimeError: mat1 and mat2 shapes cannot be multiplied (128x4000 and 25252x512)
However, the script still fails because 2000 is strictly hardcoded in several assert statements across the sampling codebase (e.g., sampling_generation_helpers.py line 58 and sampling_generation.py line 94).
How can I correctly run sampling for this finetuned checkpoint? Are there plans to make the gene dimension dynamic instead of hardcoded?
Hi,
Thanks for the question and sorry that I was too busy for the last few weeks.
For pretraining, to leverage different datasets, we build a unified gene vocabulary (size of 12626). That's why finetuned ckpt for Replogle is of shape 12626. This is similar for PBMC. (Note that Tahoe100M finetuned ckpt is an exception, because we replaced its input/output projection layer with 2000-dim one duering finetuning to avoid out-of-memory issue.)
The sampling logic for Replogle is that, we first sample 12626-gene expressions for all perturbed cells. And then, we only keep those 2000 HVG expressions for benchmarking. "sampling_generation_helpers.py line 58 and sampling_generation.py line 94" is loading the 2000 HVG pickle files to make sure the gene order for testing does not change. Therefore, these are expected coding logics.
Could you please paste your error logs in full details onto the github issue. Happy to help around.
I am trying to simply reproduce the same figures as in your paper, using your provided Replogle dataset and checkpoints. I am coming up with the same dims mismatch issue as above when trying to run rawdata_diffusion_sampling.py on replogle finetune checkpoints.
I made the following .sh modifications to try to run sampling on replogle finetune checkpoint:
where scripts/run1.sh is a direct copy-paste from your main/README.md.
Note, I removed the data.sample_replogle_only=true because this appeared to change the path on line 54 of src/apps/sampling/sampling_generation.py to PerturbDiff_data/perturb_data/selected_genes/replogle_real_selected_genes.pkl (but it appears the finetune data should use the PerturbDiff_data/perturb_data/selected_genes/merged_pbmc_tahoe_rep_cellxgene_genes_mapped.pkl, if I understand correctly?).
However, then the top 2000 HVG error is raised, which I think is due to missing huggingface files (line 32 of configs/cov_encoding/trixie_onehot.yaml):
I was only able to find and download replogle_gene_emb_dict_perturbation_emb_dict.pkl in perturb_data/gene_names. Will the missing top HVG.pkl files be uploaded in the future?
Meanwhile, I tried to reproduce the replogle (from scratch) instead, using:
This script appears to work, however after running cell-eval run ... on the output diffusion_predict.h5ad and diffusion_true.h5ad, I don't get the same values as in your paper Table 4. Additionally, when plotting a simple scanpy.pl.umap on the generated vs. real outputs, there is no overlap between points.... I must be doing something wrong.
Would it be possible to please share your workflow for reproducing your paper's figures ? Thanks again for your time !
I looked into this more carefully. The released finetuned_replogle.ckpt is a 12626-gene checkpoint, so sampling must also be run in the 12626-gene input space:
This flag is important. It does not only switch the selected-gene path; it also makes the datamodule sample only Replogle and makes the sampling output use the Replogle 2000 HVG set for benchmarking. The intended logic is:
sample in the 12626 unified gene vocabulary;
then restrict the generated and real expressions to the 2000 Replogle HVGs for evaluation.
So the assert len(_genes) == 2000 in the sampling code is expected for the benchmark output stage.
The problematic part in your command is removing data.sample_replogle_only=true while setting:
That merged file contains 12626 genes and is used for the model input vocabulary, not for the final Replogle HVG benchmark output. For Replogle sampling, the final selected genes should be replogle_real_selected_genes.pkl.
Also, the files with highly_variavle in the filename are unfortunately named with that spelling in the current data release/code, so the spelling itself is not the runtime issue.
A correct Replogle finetuned sampling command should look like:
I also found that the current release code/documentation does not make this workflow clear enough, and there were some sampling-side compatibility issues around loading the released checkpoint and overriding local embedding paths. I will update the README / sampling script so the Replogle finetuned checkpoint can be reproduced directly.
With the corrected workflow, the generated output should have shape (n_cells, 2000) after HVG restriction, and the Replogle finetuned metrics should be close to the paper values.
Activity
KatarinaYuan commentedon Apr 7, 2026
Hi,
Thanks for the question and sorry that I was too busy for the last few weeks.
For pretraining, to leverage different datasets, we build a unified gene vocabulary (size of 12626). That's why finetuned ckpt for Replogle is of shape 12626. This is similar for PBMC. (Note that Tahoe100M finetuned ckpt is an exception, because we replaced its input/output projection layer with 2000-dim one duering finetuning to avoid out-of-memory issue.)
The sampling logic for Replogle is that, we first sample 12626-gene expressions for all perturbed cells. And then, we only keep those 2000 HVG expressions for benchmarking. "sampling_generation_helpers.py line 58 and sampling_generation.py line 94" is loading the 2000 HVG pickle files to make sure the gene order for testing does not change. Therefore, these are expected coding logics.
Could you please paste your error logs in full details onto the github issue. Happy to help around.
kiristern commentedon May 20, 2026
Hi @KatarinaYuan,
Thanks for this work!
I am trying to simply reproduce the same figures as in your paper, using your provided Replogle dataset and checkpoints. I am coming up with the same dims mismatch issue as above when trying to run
rawdata_diffusion_sampling.pyon replogle finetune checkpoints.I made the following
.shmodifications to try to run sampling on replogle finetune checkpoint:where
scripts/run1.shis a direct copy-paste from your main/README.md.Note, I removed the
data.sample_replogle_only=truebecause this appeared to change the path online 54ofsrc/apps/sampling/sampling_generation.pytoPerturbDiff_data/perturb_data/selected_genes/replogle_real_selected_genes.pkl(but it appears the finetune data should use thePerturbDiff_data/perturb_data/selected_genes/merged_pbmc_tahoe_rep_cellxgene_genes_mapped.pkl, if I understand correctly?).However, then the top 2000 HVG error is raised, which I think is due to missing huggingface files (
line 32ofconfigs/cov_encoding/trixie_onehot.yaml):(Note assumed typos: variavle -> variable ?).
I was only able to find and download
replogle_gene_emb_dict_perturbation_emb_dict.pklin perturb_data/gene_names. Will the missing top HVG.pkl files be uploaded in the future?Meanwhile, I tried to reproduce the replogle (from scratch) instead, using:
This script appears to work, however after running
cell-eval run ...on the outputdiffusion_predict.h5adanddiffusion_true.h5ad, I don't get the same values as in your paperTable 4. Additionally, when plotting a simplescanpy.pl.umapon the generated vs. real outputs, there is no overlap between points.... I must be doing something wrong.Would it be possible to please share your workflow for reproducing your paper's figures ? Thanks again for your time !
KatarinaYuan commentedon Aug 23, 2026
Hi @kiristern, thanks for the detailed report.
I looked into this more carefully. The released
finetuned_replogle.ckptis a 12626-gene checkpoint, so sampling must also be run in the 12626-gene input space:However, please keep:
This flag is important. It does not only switch the selected-gene path; it also makes the datamodule sample only Replogle and makes the sampling output use the Replogle 2000 HVG set for benchmarking. The intended logic is:
So the assert len(_genes) == 2000 in the sampling code is expected for the benchmark output stage.
The problematic part in your command is removing data.sample_replogle_only=true while setting:
That merged file contains 12626 genes and is used for the model input vocabulary, not for the final Replogle HVG benchmark output. For Replogle sampling, the final selected genes should be replogle_real_selected_genes.pkl.
Also, the files with highly_variavle in the filename are unfortunately named with that spelling in the current data release/code, so the spelling itself is not the runtime issue.
A correct Replogle finetuned sampling command should look like:
I also found that the current release code/documentation does not make this workflow clear enough, and there were some sampling-side compatibility issues around loading the released checkpoint and overriding local embedding paths. I will update the README / sampling script so the Replogle finetuned checkpoint can be reproduced directly.
With the corrected workflow, the generated output should have shape (n_cells, 2000) after HVG restriction, and the Replogle finetuned metrics should be close to the paper values.