这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@kaixuanliu
Copy link
Contributor

No description provided.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@kaixuanliu
Copy link
Contributor Author

@BenjaminBossan pls help review, thx

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

"\n",
"# Hyper-parameters\n",
"device = \"cuda\"\n",
"device = \"xpu\" if torch.xpu.is_available() else \"cuda\"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about we use this? device = torch.accelerator.current_accelerator().type if hasattr(torch, "accelerator") else "cuda"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I assumed we should install accelerate to use torch.accelerator.current_accelerator() API, it turns out I am wrong...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have adjusted

"\n",
"batch = tokenizer(context, return_tensors=\"pt\")\n",
"batch = {k: v.to(\"cuda\") for k, v in batch.items()}\n",
"device = \"xpu\" if torch.xpu.is_available() else \"cuda\"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted

"\n",
"inference_model = PeftModel.from_pretrained(inference_model, \"smangrul/mistral_lora_clm_with_added_tokens\")\n",
"inference_model.to(\"cuda\")\n",
"device = \"xpu\" if torch.xpu.is_available() else \"cuda\"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted

"from datasets import load_dataset\n",
"\n",
"device = \"cuda\"\n",
"device = \"xpu\" if torch.xpu.is_available() else \"cuda\"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
@kaixuanliu kaixuanliu marked this pull request as draft August 1, 2025 02:40
@kaixuanliu kaixuanliu marked this pull request as ready for review August 1, 2025 03:25
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
@BenjaminBossan
Copy link
Member

@kaixuanliu Could you please run make style?

@kaixuanliu
Copy link
Contributor Author

@BenjaminBossan Done

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
@BenjaminBossan
Copy link
Member

Thanks, but there still seem to be issues with formatting. Maybe let's check that you have matching ruff version (0.9.10) and that the settings from the pyproject.toml are being used.

@kaixuanliu
Copy link
Contributor Author

@BenjaminBossan Well my ruff version is old. Have updated to 0.9.10. Can you help trigger the CI check again?

@BenjaminBossan
Copy link
Member

BenjaminBossan commented Aug 5, 2025

The linter is still complaining. This is the diff I get when running it locally:

@@ -247,9 +247,9 @@ def main():
 
         correct = 0
         total = 0
-        assert len(eval_preds) == len(
-            dataset["train"][label_column]
-        ), f"{len(eval_preds)} != {len(dataset['train'][label_column])}"
+        assert len(eval_preds) == len(dataset["train"][label_column]), (
+            f"{len(eval_preds)} != {len(dataset['train'][label_column])}"
+        )
         for pred, true in zip(eval_preds, dataset["train"][label_column]):
             if pred.strip() == true.strip():
                 correct += 1

Update: I see, already fixed.

@BenjaminBossan
Copy link
Member

BenjaminBossan commented Aug 5, 2025

@kaixuanliu For some reason, GH does not update on your latest commit, could you try pushing an empty commit, hopefully that fixes it.

@kaixuanliu
Copy link
Contributor Author

@BenjaminBossan pls try again.

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
…s_zero3_offload.py

Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the causal LM examples and for making them work with XPU.

@BenjaminBossan BenjaminBossan merged commit 154ef37 into huggingface:main Aug 6, 2025
2 of 14 checks passed
@kaixuanliu kaixuanliu deleted the causal_language_modeling_xpu branch August 11, 2025 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants