helloadhavan/github_issues huggingface dataset:
Repository: ollama/ollama
Pull request: revise help text

Fix up the help text to be more usable.

Changed files:
filename: cmd/cmd.go
patch: @@ -558,8 +558,35 @@ func generateInteractive(cmd *cobra.Command, model string) error {
 	)
 
 	usage := func() {
-		fmt.Fprintln(os.Stderr, "commands:")
-		fmt.Fprintln(os.Stderr, completer.Tree("  "))
+		fmt.Fprintln(os.Stderr, "Available Commands:")
+		fmt.Fprintln(os.Stderr, "  /set         Set session variables")
+		fmt.Fprintln(os.Stderr, "  /show        Show model information")
+		fmt.Fprintln(os.Stderr, "  /bye         Exit")
+		fmt.Fprintln(os.Stderr, "  /?, /help    Help for a command")
+		fmt.Fprintln(os.Stderr, "")
+		fmt.Fprintln(os.Stderr, "Use \"\"\" to begin a multi-line message.")
+		fmt.Fprintln(os.Stderr, "")
+	}
+
+	usageSet := func() {
+		fmt.Fprintln(os.Stderr, "Available Commands:")
+		fmt.Fprintln(os.Stderr, "  /set history      Enable history")
+		fmt.Fprintln(os.Stderr, "  /set nohistory    Disable history")
+		fmt.Fprintln(os.Stderr, "  /set wordwrap     Enable wordwrap")
+		fmt.Fprintln(os.Stderr, "  /set nowordwrap   Disable wordwrap")
+		fmt.Fprintln(os.Stderr, "  /set verbose      Show LLM stats")
+		fmt.Fprintln(os.Stderr, "  /set quiet        Disable LLM stats")
+		fmt.Fprintln(os.Stderr, "")
+	}
+
+	usageShow := func() {
+		fmt.Fprintln(os.Stderr, "Available Commands:")
+		fmt.Fprintln(os.Stderr, "  /show license      Show model license")
+		fmt.Fprintln(os.Stderr, "  /show modelfile    Show Modelfile for this model")
+		fmt.Fprintln(os.Stderr, "  /show parameters   Show parameters for this model")
+		fmt.Fprintln(os.Stderr, "  /show system       Show system prompt")
+		fmt.Fprintln(os.Stderr, "  /show template     Show prompt template")
+		fmt.Fprintln(os.Stderr, "")
 	}
 
 	var painter Painter
@@ -673,7 +700,7 @@ func generateInteractive(cmd *cobra.Command, model string) error {
 					fmt.Printf("Unknown command '/set %s'. Type /? for help\n", args[1])
 				}
 			} else {
-				usage()
+				usageSet()
 			}
 		case strings.HasPrefix(line, "/show"):
 			args := strings.Fields(line)
@@ -714,11 +741,21 @@ func generateInteractive(cmd *cobra.Command, model string) error {
 				default:
 					fmt.Printf("Unknown command '/show %s'. Type /? for help\n", args[1])
 				}
+			} else {
+				usageShow()
+			}
+		case strings.HasPrefix(line, "/help"), strings.HasPrefix(line, "/?"):
+			args := strings.Fields(line)
+			if len(args) > 1 {
+				switch args[1] {
+				case "set", "/set":
+					usageSet()
+				case "show", "/show":
+					usageShow()
+				}
 			} else {
 				usage()
 			}
-		case line == "/help", line == "/?":
-			usage()
 		case line == "/exit", line == "/bye":
 			return nil
 		case strings.HasPrefix(line, "/"):
Repository: ggml-org/llama.cpp
Pull request: CUDA: add unused vars to mmvf and mmvq


Changed files:
filename: ggml/src/ggml-cuda/mmvf.cu
patch: @@ -343,6 +343,10 @@ static __global__ void mul_mat_vec_f(
     }
 
     dst[tid*stride_col_dst + row] = value;
+
+    if constexpr (!has_fusion) {
+        GGML_UNUSED_VARS(use_gate, use_bias, use_gate_bias, glu_op, gate_x, x_bias, gate_bias, sumf_gate);
+    }
 }
 
 template<typename T, typename type_acc, int ncols_dst, int block_size>

filename: ggml/src/ggml-cuda/mmvq.cu
patch: @@ -310,6 +310,10 @@ static __global__ void mul_mat_vec_q(
             dst[j*stride_col_dst + threadIdx.x] = result;
         }
     }
+
+    if constexpr (!has_fusion) {
+        GGML_UNUSED_VARS(use_gate, use_bias, use_gate_bias, active_glu, gate_bias, x_bias, tmp_gate);
+    }
 }
 
 static std::pair<dim3, dim3> calc_launch_params(
Repository: facebook/react
Pull request: Enable stale action

Follows #28695

Now that the action has run successfully in debug mode ([logs](https://github.com/facebook/react/actions/runs/8532177618/job/23372921455#step:2:35)), let's enable it to persist changes.

Also changes the number of operations per run from the default of 30 to 100 since we have a large backlog of issues and PRs to work through.

Finally adds enhancement label as exempt from stale.


Changed files:
filename: .github/workflows/stale.yml
patch: @@ -16,8 +16,8 @@ jobs:
           days-before-stale: 90
           # Number of days of inactivity before a stale issue or PR is closed
           days-before-close: 7
-          # Tmp dry run setup to test new config
-          debug-only: 'true'
+          # Number of issues or PRs to process per day
+          operations-per-run: 100
 
           # --- Issues ---
           stale-issue-label: "Resolution: Stale"
@@ -30,7 +30,7 @@ jobs:
           close-issue-message: >
             Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!
           # Issues with these labels will never be considered stale
-          exempt-issue-labels: "Partner,React Core Team,Resolution: Backlog,Type: Bug,Type: Discussion,Type: Needs Investigation,Type: Regression,Type: Feature Request"
+          exempt-issue-labels: "Partner,React Core Team,Resolution: Backlog,Type: Bug,Type: Discussion,Type: Needs Investigation,Type: Regression,Type: Feature Request,Type: Enhancement"
 
           # --- PRs ---
           stale-pr-label: "Resolution: Stale"
@@ -43,4 +43,4 @@ jobs:
           close-pr-message: >
             Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!
           # PRs with these labels will never be considered stale
-          exempt-pr-labels: "Partner,React Core Team,Resolution: Backlog,Type: Bug,Type: Discussion,Type: Needs Investigation,Type: Regression,Type: Feature Request"
\ No newline at end of file
+          exempt-pr-labels: "Partner,React Core Team,Resolution: Backlog,Type: Bug,Type: Discussion,Type: Needs Investigation,Type: Regression,Type: Feature Request,Type: Enhancement"
\ No newline at end of file
Repository: facebook/react
Pull request: Emit Server Error Prefix in the .stack Property Too

Follow up to #28684.

V8 includes the message in the stack and printed errors include just the stack property which is assumed to contain the message. Without this, the prefix doesn't get printed in the console.

<img width="578" alt="Screenshot 2024-04-03 at 6 32 04 PM" src="https://github.com/facebook/react/assets/63648/d98a2db4-6ebc-4805-b669-59f449dfd21f">

A possible alternative would be to use a nested error with a `cause` like #28736 but that would need some more involved serializing since this prefix is coming from the server. Perhaps as a separate attribute.

Changed files:
filename: packages/react-server/src/ReactFizzServer.js
patch: @@ -842,7 +842,7 @@ function encodeErrorForBoundary(
       ? 'Switched to client rendering because the server rendering aborted due to:\n\n'
       : 'Switched to client rendering because the server rendering errored:\n\n';
     boundary.errorMessage = prefix + message;
-    boundary.errorStack = stack;
+    boundary.errorStack = stack !== null ? prefix + stack : null;
     boundary.errorComponentStack = thrownInfo.componentStack;
   }
 }
Repository: ollama/ollama
Pull request: enable q8, q5, 5_1, and f32 for linux gpu

The bug effecting running these quantizations on Metal does not effect nvidia GPUs, so only turn off GPU support for these model types when Ollama is running on MacOS.

Tested and verified.

Resolves #671

Changed files:
filename: llm/llm.go
patch: @@ -5,6 +5,7 @@ import (
 	"fmt"
 	"log"
 	"os"
+	"runtime"
 
 	"github.com/pbnjay/memory"
 
@@ -37,20 +38,22 @@ func New(workDir, model string, adapters []string, opts api.Options) (LLM, error
 		return nil, err
 	}
 
-	switch ggml.FileType() {
-	case "Q8_0":
-		if ggml.Name() != "gguf" && opts.NumGPU != 0 {
-			// GGML Q8_0 do not support Metal API and will
-			// cause the runner to segmentation fault so disable GPU
-			log.Printf("WARNING: GPU disabled for F32, Q5_0, Q5_1, and Q8_0")
-			opts.NumGPU = 0
-		}
-	case "F32", "Q5_0", "Q5_1":
-		if opts.NumGPU != 0 {
-			// F32, Q5_0, Q5_1, and Q8_0 do not support Metal API and will
-			// cause the runner to segmentation fault so disable GPU
-			log.Printf("WARNING: GPU disabled for F32, Q5_0, Q5_1, and Q8_0")
-			opts.NumGPU = 0
+	if runtime.GOOS == "darwin" {
+		switch ggml.FileType() {
+		case "Q8_0":
+			if ggml.Name() != "gguf" && opts.NumGPU != 0 {
+				// GGML Q8_0 do not support Metal API and will
+				// cause the runner to segmentation fault so disable GPU
+				log.Printf("WARNING: GPU disabled for F32, Q5_0, Q5_1, and Q8_0")
+				opts.NumGPU = 0
+			}
+		case "F32", "Q5_0", "Q5_1":
+			if opts.NumGPU != 0 {
+				// F32, Q5_0, Q5_1, and Q8_0 do not support Metal API and will
+				// cause the runner to segmentation fault so disable GPU
+				log.Printf("WARNING: GPU disabled for F32, Q5_0, Q5_1, and Q8_0")
+				opts.NumGPU = 0
+			}
 		}
 	}
Repository: vercel/next.js
Pull request: [test] update existing passed tests for cache components suite

Update the tests already passed in cache components test manifest.json

Changed files:
filename: test/cache-components-tests-manifest.json
patch: @@ -2,37 +2,38 @@
   "version": 2,
   "suites": {
     "test/production/app-dir/fetch-cache/fetch-cache.test.ts": {
-      "passed": [],
-      "failed": [
+      "passed": [
         "fetch-cache should have correct fetchUrl field for fetches and unstable_cache",
         "fetch-cache should not retry for failed fetch-cache GET",
         "fetch-cache should retry 3 times when revalidate times out",
         "fetch-cache should update cache TTL even if cache data does not change"
       ],
-      "pending": [],
-      "flakey": [],
-      "runtimeError": false
+      "failed": []
     },
     "test/e2e/opentelemetry/opentelemetry.test.ts": {
-      "failed": [
+      "passed": [
         "opentelemetry root context app router should handle RSC with fetch",
         "opentelemetry incoming context propagation app router should handle RSC with fetch",
         "opentelemetry incoming context propagation app router should handle route handlers in app router"
-      ]
+      ],
+      "failed": []
     },
     "test/e2e/app-dir/searchparams-reuse-loading/searchparams-reuse-loading.test.ts": {
+      "passed": [],
       "failed": [
         "searchparams-reuse-loading should re-use loading from \"full\" prefetch for param-full URL when navigating to param-full route",
         "searchparams-reuse-loading should re-use loading from \"full\" prefetch for param-full URL when navigating to param-less route",
         "searchparams-reuse-loading should re-use loading from \"full\" prefetch for param-less URL when navigating to param-full route"
       ]
     },
     "test/production/app-dir/browser-chunks/browser-chunks.test.ts": {
+      "passed": [],
       "failed": [
         "browser-chunks must not bundle any server modules into browser chunks"
       ]
     },
     "test/e2e/next-form/default/next-form-prefetch.test.ts": {
+      "passed": [],
       "failed": [
         "app dir - form prefetching should not prefetch when prefetch is set to false`",
         "app dir - form prefetching should prefetch a loading state for the form's target"
Repository: vercel/next.js
Pull request: [test] fix cache components build error in next-form tests

Add suspense boundary above the async request API to avoid build error with cache components test suite

Changed files:
filename: test/cache-components-tests-manifest.json
patch: @@ -33,10 +33,11 @@
       ]
     },
     "test/e2e/next-form/default/next-form-prefetch.test.ts": {
-      "passed": [],
-      "failed": [
-        "app dir - form prefetching should not prefetch when prefetch is set to false`",
+      "passed": [
         "app dir - form prefetching should prefetch a loading state for the form's target"
+      ],
+      "failed": [
+        "app dir - form prefetching should not prefetch when prefetch is set to false`"
       ]
     }
   },

filename: test/e2e/next-form/default/app/forms/button-formaction-unsupported/page.tsx
patch: @@ -1,14 +1,13 @@
 'use client'
-import * as React from 'react'
+
+import React, { Suspense } from 'react'
 import Form from 'next/form'
 
-type AnySearchParams = { [key: string]: string | Array<string> | undefined }
+type AnySearchParams = Promise<{
+  [key: string]: string | Array<string> | undefined
+}>
 
-export default function Home({
-  searchParams,
-}: {
-  searchParams: Promise<AnySearchParams>
-}) {
+function Home({ searchParams }: { searchParams: AnySearchParams }) {
   const attribute = React.use(searchParams).attribute
   return (
     <div
@@ -39,3 +38,15 @@ export default function Home({
     </div>
   )
 }
+
+export default function Page({
+  searchParams,
+}: {
+  searchParams: AnySearchParams
+}) {
+  return (
+    <Suspense fallback={<div>Page is loading...</div>}>
+      <Home searchParams={searchParams} />
+    </Suspense>
+  )
+}

filename: test/e2e/next-form/default/app/redirected-from-action/page.tsx
patch: @@ -1,6 +1,27 @@
 import * as React from 'react'
+import { Suspense } from 'react'
 
-export default async function RedirectedPage({ searchParams }) {
+type AnySearchParams = Promise<{
+  [key: string]: string | Array<string> | undefined
+}>
+
+async function RedirectedPage({
+  searchParams,
+}: {
+  searchParams: AnySearchParams
+}) {
   const query = (await searchParams).query as string
   return <div id="redirected-results">query: {JSON.stringify(query)}</div>
 }
+
+export default function Page({
+  searchParams,
+}: {
+  searchParams: AnySearchParams
+}) {
+  return (
+    <Suspense fallback={<div>Page is loading...</div>}>
+      <RedirectedPage searchParams={searchParams} />
+    </Suspense>
+  )
+}
Repository: ollama/ollama
Pull request: Increase client/server streaming buffer size to prevent `token too long` error

In the case of a large input the response from `/generate` would be very long due to the encoded context length. Increase the buffer size to prevent this error.

resolves #687 

Changed files:
filename: api/client.go
patch: @@ -18,9 +18,7 @@ import (
 
 const DefaultHost = "127.0.0.1:11434"
 
-var (
-	envHost = os.Getenv("OLLAMA_HOST")
-)
+var envHost = os.Getenv("OLLAMA_HOST")
 
 type Client struct {
 	Base    url.URL
@@ -123,6 +121,8 @@ func (c *Client) do(ctx context.Context, method, path string, reqData, respData
 	return nil
 }
 
+const maxBufferSize = 512 * 1024 // 512KB
+
 func (c *Client) stream(ctx context.Context, method, path string, data any, fn func([]byte) error) error {
 	var buf *bytes.Buffer
 	if data != nil {
@@ -151,6 +151,9 @@ func (c *Client) stream(ctx context.Context, method, path string, data any, fn f
 	defer response.Body.Close()
 
 	scanner := bufio.NewScanner(response.Body)
+	// increase the buffer size to avoid running out of space
+	scanBuf := make([]byte, 0, maxBufferSize)
+	scanner.Buffer(scanBuf, maxBufferSize)
 	for scanner.Scan() {
 		var errorResponse struct {
 			Error string `json:"error,omitempty"`

filename: llm/llama.go
patch: @@ -438,6 +438,8 @@ type PredictRequest struct {
 	Stop             []string `json:"stop,omitempty"`
 }
 
+const maxBufferSize = 512 * 1024 // 512KB
+
 func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string, fn func(api.GenerateResponse)) error {
 	prevConvo, err := llm.Decode(ctx, prevContext)
 	if err != nil {
@@ -498,6 +500,9 @@ func (llm *llama) Predict(ctx context.Context, prevContext []int, prompt string,
 	}
 
 	scanner := bufio.NewScanner(resp.Body)
+	// increase the buffer size to avoid running out of space
+	buf := make([]byte, 0, maxBufferSize)
+	scanner.Buffer(buf, maxBufferSize)
 	for scanner.Scan() {
 		select {
 		case <-ctx.Done():
Repository: nodejs/node
Pull request: typings: add ZSTD_COMPRESS, ZSTD_DECOMPRESS to internalBinding

first added in https://github.com/nodejs/node/commit/bf12d72faa1b55cfb5fd7d52a221f896886b116c

Changed files:
filename: typings/internalBinding/constants.d.ts
patch: @@ -285,6 +285,8 @@ export interface ConstantsBinding {
     UNZIP: 7;
     BROTLI_DECODE: 8;
     BROTLI_ENCODE: 9;
+    ZSTD_COMPRESS: 10;
+    ZSTD_DECOMPRESS: 11;
     Z_MIN_WINDOWBITS: 8;
     Z_MAX_WINDOWBITS: 15;
     Z_DEFAULT_WINDOWBITS: 15;
Repository: ollama/ollama
Pull request: decode starcoder


Changed files:
filename: llm/falcon.go
patch: @@ -1,7 +1,5 @@
 package llm
 
-const ModelFamilyFalcon = "falcon"
-
 const (
 	falconModelType7B   = 32
 	falconModelType40B  = 60
@@ -17,6 +15,6 @@ func falconModelType(numLayer uint32) string {
 	case 80:
 		return "180B"
 	default:
-		return "Unknown"
+		return "unknown"
 	}
 }

filename: llm/ggml.go
patch: @@ -69,7 +69,7 @@ func fileType(fileType uint32) string {
 	case fileTypeQ6_K:
 		return "Q6_K"
 	default:
-		return "Unknown"
+		return "unknown"
 	}
 }
 

filename: llm/gguf.go
patch: @@ -109,9 +109,13 @@ func (llm *ggufModel) ModelType() string {
 		if blocks, ok := llm.kv["falcon.block_count"].(uint32); ok {
 			return falconModelType(blocks)
 		}
+	case "starcoder":
+		if blocks, ok := llm.kv["starcoder.block_count"].(uint32); ok {
+			return starCoderModelType(blocks)
+		}
 	}
 
-	return "Unknown"
+	return "unknown"
 }
 
 func (llm *ggufModel) FileType() string {
@@ -120,7 +124,7 @@ func (llm *ggufModel) FileType() string {
 		return fileType(t)
 	}
 
-	return "Unknown"
+	return "unknown"
 }
 
 func (llm *ggufModel) Decode(r io.Reader) error {

filename: llm/llama.go
patch: @@ -143,7 +143,7 @@ func llamaModelType(numLayer uint32) string {
 	case 80:
 		return "65B"
 	default:
-		return "Unknown"
+		return "unknown"
 	}
 }
 

filename: llm/starcoder.go
patch: @@ -0,0 +1,23 @@
+package llm
+
+const (
+	starCoderModelType1B  = 24
+	starCoderModelType3B  = 36
+	starCoderModelType7B  = 42
+	starCoderModelType15B = 40
+)
+
+func starCoderModelType(numLayer uint32) string {
+	switch numLayer {
+	case 24:
+		return "1B"
+	case 36:
+		return "3B"
+	case 42:
+		return "7B"
+	case 40:
+		return "15B"
+	default:
+		return "unknown"
+	}
+}
Repository: denoland/deno
Pull request: fix(dts): align crypto.getRandomValues in lib.deno_crypto.d.ts with lib.dom.d.ts and lib.webworker.d.ts

As title.

Changed files:
filename: cli/tsc/dts/lib.deno_crypto.d.ts
patch: @@ -651,20 +651,7 @@ interface Crypto {
    *
    * @see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
    */
-  getRandomValues<
-    T extends
-      | Int8Array<ArrayBuffer>
-      | Int16Array<ArrayBuffer>
-      | Int32Array<ArrayBuffer>
-      | Uint8Array<ArrayBuffer>
-      | Uint16Array<ArrayBuffer>
-      | Uint32Array<ArrayBuffer>
-      | Uint8ClampedArray<ArrayBuffer>
-      | BigInt64Array<ArrayBuffer>
-      | BigUint64Array<ArrayBuffer>,
-  >(
-    array: T,
-  ): T;
+  getRandomValues<T extends ArrayBufferView>(array: T): T;
 
   /**
    * Generates a random RFC 4122 version 4 UUID using a cryptographically
Repository: ollama/ollama
Pull request: show a default message when license/parameters/etc aren't specified


Changed files:
filename: cmd/cmd.go
patch: @@ -686,15 +686,31 @@ func generateInteractive(cmd *cobra.Command, model string) error {
 
 				switch args[1] {
 				case "license":
-					fmt.Println(resp.License)
+					if resp.License == "" {
+						fmt.Println("No license was specified for this model.\n")
+					} else {
+						fmt.Println(resp.License)
+					}
 				case "modelfile":
 					fmt.Println(resp.Modelfile)
 				case "parameters":
-					fmt.Println(resp.Parameters)
+					if resp.Parameters == "" {
+						fmt.Println("No parameters were specified for this model.\n")
+					} else {
+						fmt.Println(resp.Parameters)
+					}
 				case "system":
-					fmt.Println(resp.System)
+					if resp.System == "" {
+						fmt.Println("No system prompt was specified for this model.\n")
+					} else {
+						fmt.Println(resp.System)
+					}
 				case "template":
-					fmt.Println(resp.Template)
+					if resp.Template == "" {
+						fmt.Println("No prompt template was specified for this model.\n")
+					} else {
+						fmt.Println(resp.Template)
+					}
 				default:
 					fmt.Printf("Unknown command '/show %s'. Type /? for help\n", args[1])
 				}
Repository: ollama/ollama
Pull request: clean up num_gpu calculation code

there were some unreachable code paths and unused variables here from iterations on an old branch, remove them

Changed files:
filename: llm/llama.go
patch: @@ -218,7 +218,6 @@ func NumGPU(numLayer, fileSizeBytes int64, opts api.Options) int {
 	if opts.NumGPU != -1 {
 		return opts.NumGPU
 	}
-	n := 1 // default to enable metal on macOS
 	if runtime.GOOS == "linux" {
 		vramMib, err := CheckVRAM()
 		if err != nil {
@@ -235,10 +234,11 @@ func NumGPU(numLayer, fileSizeBytes int64, opts api.Options) int {
 		// TODO: this is a rough heuristic, better would be to calculate this based on number of layers and context size
 		bytesPerLayer := fileSizeBytes / numLayer
 
-		// set n to the max number of layers we can fit in VRAM
-		return int(totalVramBytes / bytesPerLayer)
+		// max number of layers we can fit in VRAM
+		layers := int(totalVramBytes / bytesPerLayer)
+		log.Printf("%d MiB VRAM available, loading up to %d GPU layers", vramMib, layers)
 
-		log.Printf("%d MiB VRAM available, loading up to %d GPU layers", vramMib, n)
+		return layers
 	}
 	// default to enable metal on macOS
 	return 1
Repository: huggingface/transformers
Pull request: fix: use consistent dtype for DETR sine positional embeddings

# What does this PR do?

Allows the use of non-float32 types, such as float16, with DETR models.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

@amyeroberts, @qubvel

Changed files:
filename: src/transformers/models/conditional_detr/modeling_conditional_detr.py
patch: @@ -431,7 +431,7 @@ def gen_sine_position_embeddings(pos_tensor, d_model):
     pos_x = torch.stack((pos_x[:, :, 0::2].sin(), pos_x[:, :, 1::2].cos()), dim=3).flatten(2)
     pos_y = torch.stack((pos_y[:, :, 0::2].sin(), pos_y[:, :, 1::2].cos()), dim=3).flatten(2)
     pos = torch.cat((pos_y, pos_x), dim=2)
-    return pos
+    return pos.to(pos_tensor.dtype)
 
 
 def inverse_sigmoid(x, eps=1e-5):

filename: src/transformers/models/dab_detr/modeling_dab_detr.py
patch: @@ -338,7 +338,7 @@ def gen_sine_position_embeddings(pos_tensor, hidden_size=256):
         pos = torch.cat((pos_y, pos_x, pos_w, pos_h), dim=2)
     else:
         raise ValueError(f"Unknown pos_tensor shape(-1):{pos_tensor.size(-1)}")
-    return pos
+    return pos.to(pos_tensor.dtype)
 
 
 def inverse_sigmoid(x, eps=1e-5):