Skip to content

Fix dtype mismatch in strided evaluation visibility assignment#180

Open
YannickGibson wants to merge 1 commit intofacebookresearch:mainfrom
YannickGibson:strided-type-mismatch
Open

Fix dtype mismatch in strided evaluation visibility assignment#180
YannickGibson wants to merge 1 commit intofacebookresearch:mainfrom
YannickGibson:strided-type-mismatch

Conversation

@YannickGibson
Copy link

Fix dtype mismatch in strided evaluation

Problem

When running strided evaluation on TapVid-DAVIS dataset, the evaluator crashes with:

Command:

python ./cotracker/evaluation/evaluate.py --config-name eval_tapvid_davis_strided exp_dir=./eval_outputs/strided dataset_root=datasets

Output:

File "./co-tracker/cotracker/evaluation/core/evaluator.py", line 271, in evaluate_sequence
    pred_vsb[mask[:, :, :, 0]] = inv_pred_vsb[mask[:, :, :, 0]]
RuntimeError: Index put requires the source and destination dtypes match, got Bool for the destination and Float for the source.

This occurs at line 271 in cotracker/evaluation/core/evaluator.py when attempting to merge predictions from forward and backward passes.

Environment

  • Python: 3.10.4
  • PyTorch: 1.13.0+cu117
  • NumPy: 1.26.4
  • Hydra: 1.1.0

Solution

Convert pred_vsb to match inv_pred_vsb dtype before indexed assignment:

pred_vsb = pred_vsb.to(inv_pred_vsb.dtype)
pred_vsb[mask[:, :, :, 0]] = inv_pred_vsb[mask[:, :, :, 0]]

This ensures dtype compatibility between the destination tensor and source tensor during the assignment operation. The fix dynamically matches the dtype from the model output rather than hardcoding, making it robust across different precision modes (fp32, fp16, bfloat16).

Testing

Verified fix resolves the issue when running:

python ./cotracker/evaluation/evaluate.py --config-name eval_tapvid_davis_strided exp_dir=./eval_outputs/strided dataset_root=datasets

Resulting JSON

{
    "occlusion_accuracy": 0.6789913433103425,
    "pts_within_1": 0.3681140514159171,
    "jaccard_1": 0.2810965209136301,
    "pts_within_2": 0.5160547528215811,
    "jaccard_2": 0.4269992312134806,
    "pts_within_4": 0.6188633490338561,
    "jaccard_4": 0.5340930209458256,
    "pts_within_8": 0.6852129258977692,
    "jaccard_8": 0.5834998947998223,
    "pts_within_16": 0.7527433967957153,
    "jaccard_16": 0.597554944076797,
    "average_jaccard": 0.48464872238991114,
    "average_pts_within_thresh": 0.5881976951929677,
    "time": 168.436683177948
}

@meta-cla
Copy link

meta-cla bot commented Feb 1, 2026

Hi @YannickGibson!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 1, 2026
@meta-cla
Copy link

meta-cla bot commented Feb 1, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant