{"record":{"id":"57964594f063d95f","repo":"huggingface/transformers","slug":"push-to-hub-token-is-not-set-cannot-push-results","errorCode":null,"errorMessage":"PUSH_TO_HUB_TOKEN is not set, cannot push results to the Hub. When setting dataset_id, please also set the PUSH_TO_HUB_TOKEN environment variable.","messagePattern":"PUSH_TO_HUB_TOKEN is not set, cannot push results to the Hub\\. When setting dataset_id, please also set the PUSH_TO_HUB_TOKEN environment variable\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"benchmark_v2/framework/benchmark_runner.py","lineNumber":447,"sourceCode":"        # Convert results to dict\n        converted_results = {}\n        for cfg_hash in results.keys():\n            converted_results[cfg_hash] = {\n                \"metadata\": results[cfg_hash][\"metadata\"].to_dict(),\n                \"measurements\": results[cfg_hash][\"measurements\"].to_dict(summarized=summarized),\n                \"config\": results[cfg_hash][\"config\"].to_dict(),\n            }\n\n        # Save to JSON file\n        with open(filepath, \"w\") as f:\n            f.write(compact_json_numeric_arrays(converted_results))\n\n        self.logger.info(f\"Results saved to {filepath}\")\n        return filepath\n\n    def push_results_to_hub(self, dataset_id: str, results: dict[Any, Any], timestamp: str) -> None:\n        if PUSH_TO_HUB_TOKEN is None:\n            raise ValueError(\n                \"PUSH_TO_HUB_TOKEN is not set, cannot push results to the Hub. When setting dataset_id, please also set the PUSH_TO_HUB_TOKEN environment variable.\"\n            )\n\n        api = HfApi()\n        n_results = len(results)\n        for summarized in [False, True]:\n            self.logger.info(f\"Pushing {n_results} results to: {dataset_id} with {summarized = }\")\n            rows = []\n            for cfg_hash, entry in results.items():\n                row = {\n                    \"benchmark_config_hash\": cfg_hash,\n                    \"config\": entry[\"config\"].to_dict(),\n                    \"measurements\": entry[\"measurements\"].to_dict(summarized=summarized),\n                    \"metadata\": entry[\"metadata\"].to_dict(),\n                }\n                rows.append(row)\n\n            ds = Dataset.from_list(rows)","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/benchmark_v2/framework/benchmark_runner.py#L429-L465","documentation":"In the scale-factor layout coercion helper (`_coerce_sf_for_kernel`-style path), after dtype normalization the tensor `sf.dim()` is neither 2 nor 3, which is the only rank DeepGEMM kernels accept for activation/weight scale factors. This is a programming/shape error in how the caller prepared the SF tensor (e.g. a per-tensor scalar, or a 4D batched tensor).","triggerScenarios":"Passing an SF tensor with rank 1 (single flat scale vector), rank 0 (scalar per-tensor scale), or rank 4+ into a DeepGEMM linear/experts forward; commonly from custom quantization code that produced scales in an unexpected layout (e.g. `(E, N/128, K/128, 1)` kept with a trailing singleton instead of squeezing).","commonSituations":"Custom FP8 wrappers building their own scale tensors; converting HF FBGEMM-style scales `(1, K//128)` without reshape; offline preprocessing scripts that save scales with an extra batch dim.","solutions":["Inspect `sf.shape` right before the call and reshape to 2D `(rows, cols)` or 3D `(groups, rows, cols)` block-scale layout","If the scale is per-tensor, re-quantize block-wise (per 128-block) since DeepGEMM needs block SFs","Squeeze/remove spurious singleton dims from your scale pipeline (`.squeeze(-1)`, fix the `view` in your preprocessing)"],"exampleFix":"# before\nsf = scales.reshape(1, -1)          # dim()==1 -> ValueError\nout = deepgemm_fp8_linear(x, w, sf)\n\n# after\nsf = scales.reshape(rows, cols)      # 2D block SF layout\nout = deepgemm_fp8_linear(x, w, sf)","handlingStrategy":"validation","validationCode":"def check_sf_rank(sf: torch.Tensor) -> None:\n    if sf.dim() not in (2, 3):\n        raise ValueError(f\"bad SF rank {sf.dim()}; expected 2D (rows, cols) or 3D (groups, rows, cols)\")\n\ncheck_sf_rank(scale_2d)","typeGuard":"def is_valid_sf(t: torch.Tensor) -> bool:\n    \"\"\"DeepGEMM scale factors must be rank 2 or 3.\"\"\"\n    return isinstance(t, torch.Tensor) and t.dim() in (2, 3)","tryCatchPattern":"try:\n    out = deepgemm_fp8_fp4_linear(x, w, sf)\nexcept ValueError as e:\n    if \"SF must be 2D or 3D\" in str(e):\n        sf = sf.reshape(-1, sf.size(-1))  # or fix the producer\n        out = deepgemm_fp8_fp4_linear(x, w, sf)\n    else:\n        raise","preventionTips":["Assert scale tensor rank right after producing it in your quantization pipeline","Keep SF layout conventions written down (rows=K/128 blocks, cols=N or vice versa)","Add unit checks for scale shapes in preprocessing scripts"],"tags":["deepgemm","tensor-shape","scale-factor","validation"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}