Skip to content

Hard-coded batch-triplet unpack breaks custom DataLoader formats #10

Open

Description

@HuangWeiMi

content: The hessian.dataloader_hv_product method destructures dataloader items as _, inputs, targets. DataLoaders that emit (inputs, targets) pairs (the pervasive PyTorch convention) or dictionaries therefore raise ValueError: too many values to unpack.
file: src/infty/utils/hessian.py
code:

for _, inputs, targets in self.data:
    self.model.zero_grad()
    tmp_num_data = inputs.size(0)
    loss_fn = self.create_loss_fn(inputs.to(self.device), targets.to(self.device))

description: Relax the unpacking so it either (a) detects tuple length or (b) lets callers supply a small adapter callback. Accepting (inputs, targets) pairs with an optional sample-index fallback is sufficient to support the common vision and text dataloaders without breaking the existing 3-tuple case.

Activity

  1. kabishou11 commented on Sep 15, 2026

    @kabishou11

    I'll take this. Plan: relax hessian.dataloader_hv_product batch unpacking to accept common (inputs, targets) pairs as well as the existing 3-tuple form, with a small helper so dict/custom loaders can adapt. Adding unit tests for 2-tuple and 3-tuple batches.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions