Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support broadcast index put #3421

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

chohk88
Copy link
Collaborator

@chohk88 chohk88 commented Feb 27, 2025

Description

  • Support broadcasting index_put (Add test case)
  • Indexing with None type is WIP.

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@chohk88 chohk88 self-assigned this Feb 27, 2025
@github-actions github-actions bot added component: tests Issues re: Tests component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Feb 27, 2025
@github-actions github-actions bot requested a review from narendasan February 27, 2025 21:13
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/examples/dynamo/torch_compile_pg.py	2025-02-27 21:13:32.356782+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/dynamo/torch_compile_pg.py	2025-02-27 21:13:50.969706+00:00
@@ -9,17 +9,22 @@
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg"
image = load_image(url)


model = PaliGemmaForConditionalGeneration.from_pretrained(
-    model_id, torch_dtype=torch.float16).eval()
+    model_id, torch_dtype=torch.float16
+).eval()
model.to(DEVICE).to(torch.float16)
# model.forward = model.forward.to(torch.float16).eval()

processor = PaliGemmaProcessor.from_pretrained(model_id)
prompt = ""
-model_inputs = processor(text=prompt, images=image, return_tensors="pt").to(torch.float16).to(DEVICE) # to(DEVICE) # .to(torch.float16).to(DEVICE)
+model_inputs = (
+    processor(text=prompt, images=image, return_tensors="pt")
+    .to(torch.float16)
+    .to(DEVICE)
+)  # to(DEVICE) # .to(torch.float16).to(DEVICE)
input_len = model_inputs["input_ids"].shape[-1]

# model.config.token_healing = False

with torch.inference_mode():
@@ -49,13 +54,15 @@
            # "use_fp32_acc": True,
            "debug": True,
            # "use_aot_joint_export":False,
        },
    )
-    
+
    with torch.inference_mode():
-        trt_generation = model.generate(**model_inputs, max_new_tokens=100, do_sample=False) 
+        trt_generation = model.generate(
+            **model_inputs, max_new_tokens=100, do_sample=False
+        )
        trt_generation_out = trt_generation[0][input_len:]
        trt_decoded = processor.decode(trt_generation_out, skip_special_tokens=True)
        print(trt_generation)
        print("TensorRT generated text:")
-        print(trt_decoded)
\ No newline at end of file
+        print(trt_decoded)

@chohk88 chohk88 force-pushed the support_broadcast_index_put branch from 80bef6e to 175f191 Compare February 28, 2025 01:35
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/examples/dynamo/torch_compile_pg.py	2025-02-28 01:35:45.736123+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/dynamo/torch_compile_pg.py	2025-02-28 01:36:05.082683+00:00
@@ -9,17 +9,22 @@
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg"
image = load_image(url)


model = PaliGemmaForConditionalGeneration.from_pretrained(
-    model_id, torch_dtype=torch.float16).eval()
+    model_id, torch_dtype=torch.float16
+).eval()
model.to(DEVICE).to(torch.float16)
# model.forward = model.forward.to(torch.float16).eval()

processor = PaliGemmaProcessor.from_pretrained(model_id)
prompt = ""
-model_inputs = processor(text=prompt, images=image, return_tensors="pt").to(torch.float16).to(DEVICE) # to(DEVICE) # .to(torch.float16).to(DEVICE)
+model_inputs = (
+    processor(text=prompt, images=image, return_tensors="pt")
+    .to(torch.float16)
+    .to(DEVICE)
+)  # to(DEVICE) # .to(torch.float16).to(DEVICE)
input_len = model_inputs["input_ids"].shape[-1]

# model.config.token_healing = False

with torch.inference_mode():
@@ -49,13 +54,15 @@
            # "use_fp32_acc": True,
            "debug": True,
            # "use_aot_joint_export":False,
        },
    )
-    
+
    with torch.inference_mode():
-        trt_generation = model.generate(**model_inputs, max_new_tokens=100, do_sample=False) 
+        trt_generation = model.generate(
+            **model_inputs, max_new_tokens=100, do_sample=False
+        )
        trt_generation_out = trt_generation[0][input_len:]
        trt_decoded = processor.decode(trt_generation_out, skip_special_tokens=True)
        print(trt_generation)
        print("TensorRT generated text:")
-        print(trt_decoded)
\ No newline at end of file
+        print(trt_decoded)

@chohk88 chohk88 marked this pull request as draft February 28, 2025 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants