{"record":{"id":"c122e30d90e01b15","repo":"huggingface/pytorch-image-models","slug":"unsupported-distill-type-distill-type-must-be","errorCode":null,"errorMessage":"Unsupported distill_type '{distill_type}'. Must be 'soft' or 'hard'.","messagePattern":"Unsupported distill_type '(.+?)'\\. Must be 'soft' or 'hard'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/task/token_distillation.py","lineNumber":234,"sourceCode":"                in_chans=in_chans,\n                pretrained_path=teacher_pretrained_path,\n                device=self.device,\n                dtype=self.dtype,\n            )\n        else:\n            raise TypeError(\n                f\"teacher_model must be a model name string, nn.Module, or TokenDistillationTeacher, \"\n                f\"got {type(teacher_model).__name__}\"\n            )\n\n        self.trainable_module = student_model\n        self.teacher = teacher\n        self.criterion = criterion if criterion is not None else nn.CrossEntropyLoss()\n        self.distill_type = distill_type\n        self.temperature = temperature\n\n        if distill_type not in ('soft', 'hard'):\n            raise ValueError(f\"Unsupported distill_type '{distill_type}'. Must be 'soft' or 'hard'.\")\n\n        # Register student normalization values as non-persistent buffers\n        student_mean = torch.tensor(\n            student_unwrapped.pretrained_cfg['mean'],\n            device=self.device,\n            dtype=self.dtype,\n        ).view(1, -1, 1, 1)\n        student_std = torch.tensor(\n            student_unwrapped.pretrained_cfg['std'],\n            device=self.device,\n            dtype=self.dtype,\n        ).view(1, -1, 1, 1)\n        self.register_buffer('student_mean', student_mean, persistent=False)\n        self.register_buffer('student_std', student_std, persistent=False)\n\n        # Determine weighting mode\n        if distill_loss_weight is not None:\n            # Mode 1: distill_weight specified - independent weights (task defaults to 1.0 if not set)","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/task/token_distillation.py#L216-L252","documentation":"TokenDistillation.__init__ validates its distill_type argument and only accepts 'soft' or 'hard'. Any other string (e.g. 'Soft', 'KD', 'logit') raises ValueError at construction time. This is a config-validation error for the token-level distillation wrapper in timm.task.token_distillation.","triggerScenarios":"Constructing TokenDistillation(teacher, student, distill_type='feature') or passing a typo like distill_type='sotf' or a non-lowercase variant such as 'Soft'.","commonSituations":"Copy-pasted config from another distillation library with different type names; case mismatch; passing None or an empty string when the default was expected.","solutions":["Set distill_type to exactly 'soft' (KL-divergence over softened logits) or 'hard' (hard-label CE)","Check for typos/case in the config value feeding distill_type","Omit distill_type if you want the default (typically 'soft')"],"exampleFix":"# before\ndistiller = TokenDistillation(teacher, student, distill_type='feature')\n# after\ndistiller = TokenDistillation(teacher, student, distill_type='soft')","handlingStrategy":"validation","validationCode":"assert distill_type in ('soft', 'hard'), f\"bad distill_type: {distill_type}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize config strings with .strip().lower() before passing","Log distill_type at startup to catch config typos early"],"tags":["distillation","config-validation","valueerror","timm"],"backgroundTag":"invalid-enum-argument","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}