helloadhavan/github_issues huggingface dataset:
Repository: huggingface/transformers
Pull request: Fix Mamba2ForCausalLM weight tying

## What does this PR do?

Fixes #43206

Adds the `_tied_weights_keys` mapping to `Mamba2ForCausalLM` to enable proper weight tying when `tie_word_embeddings=True`.

## The Bug

When `tie_word_embeddings=True`, the embedding weights should be shared with the `lm_head`. However, `Mamba2ForCausalLM` had:
```python
_tied_weights_keys = {}  # Empty - weight tying never happens
```

This caused:
- Weights not actually tied (different tensors)
- `resize_token_embeddings()` not resizing `lm_head` properly

## The Fix

```python
_tied_weights_keys = {"lm_head.weight": "backbone.embeddings.weight"}
```

This is the standard pattern used by `MambaForCausalLM` (v1), GPT2, LLaMA, and other models.

## Verification

```python
from transformers import Mamba2ForCausalLM, Mamba2Config

config = Mamba2Config(vocab_size=1000, tie_word_embeddings=True)
model = Mamba2ForCausalLM(config)

# Weights are now properly tied
assert model.lm_head.weight.data_ptr() == model.backbone.embeddings.weight.data_ptr()

# Resize works correctly
model.resize_token_embeddings(1100)
assert model.lm_head.weight.shape[0] == 1100
```

Changed files:
filename: src/transformers/models/mamba2/modeling_mamba2.py
patch: @@ -930,7 +930,7 @@ def forward(
     """
 )
 class Mamba2ForCausalLM(Mamba2PreTrainedModel, GenerationMixin):
-    _tied_weights_keys = {}
+    _tied_weights_keys = {"lm_head.weight": "backbone.embeddings.weight"}
 
     def __init__(self, config):
         super().__init__(config)

filename: tests/models/mamba2/test_modeling_mamba2.py
patch: @@ -341,6 +341,26 @@ def recursive_check(tuple_object, dict_object):
             dict_inputs = self._prepare_for_class(inputs_dict, model_class, return_labels=True)
             check_equivalence(model, tuple_inputs, dict_inputs, {"output_hidden_states": True})
 
+    def test_tied_weight_embeddings(self):
+        """Regression test for https://github.com/huggingface/transformers/issues/43206."""
+        config = self.model_tester.get_config()
+
+        config.tie_word_embeddings = True
+        model = Mamba2ForCausalLM(config)
+
+        self.assertEqual(
+            model.lm_head.weight.data_ptr(),
+            model.backbone.embeddings.weight.data_ptr(),
+        )
+
+        config.tie_word_embeddings = False
+        model = Mamba2ForCausalLM(config)
+
+        self.assertNotEqual(
+            model.lm_head.weight.data_ptr(),
+            model.backbone.embeddings.weight.data_ptr(),
+        )
+
 
 @require_torch
 @slow
Repository: facebook/react
Pull request: Back out "Remove Dead Code in WWW JS"


Original commit changeset: 65c4decb565b

This was removed by dead code removal. Adding back the TODO with commented out code.


Changed files:
filename: packages/react-server/src/ReactFizzServer.js
patch: @@ -4661,6 +4661,12 @@ function abortTask(task: Task, request: Request, error: mixed): void {
     if (node !== null && typeof node === 'object') {
       // Push a fake component stack frame that represents the await.
       pushHaltedAwaitOnComponentStack(task, node._debugInfo);
+      /*
+      if (task.thenableState !== null) {
+        // TODO: If we were stalled inside use() of a Client Component then we should
+        // rerender to get the stack trace from the use() call.
+      }
+      */
     }
   }
Repository: vuejs/vue
Pull request: fix #8842: Override v-bind object with kebab-cased props

<!--
Please make sure to read the Pull Request Guidelines:
https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines
-->

<!-- PULL REQUEST TEMPLATE -->
<!-- (Update "[ ]" to "[x]" to check a box) -->

**What kind of change does this PR introduce?** (check at least one)

- [x] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [ ] Other, please describe:

**Does this PR introduce a breaking change?** (check one)

- [ ] Yes
- [x] No

If yes, please describe the impact and migration path for existing applications:

**The PR fulfills these requirements:**

- [x] It's submitted to the `dev` branch for v2.x (or to a previous version branch), _not_ the `master` branch
- [x] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
- [x] All tests are passing: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#development-setup
- [x] New/updated tests are included

If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

**Other information:**


Changed files:
filename: src/core/instance/render-helpers/bind-object-props.js
patch: @@ -6,7 +6,8 @@ import {
   warn,
   isObject,
   toObject,
-  isReservedAttribute
+  isReservedAttribute,
+  camelize
 } from 'core/util/index'
 
 /**
@@ -43,12 +44,13 @@ export function bindObjectProps (
             ? data.domProps || (data.domProps = {})
             : data.attrs || (data.attrs = {})
         }
-        if (!(key in hash)) {
+        const camelizedKey = camelize(key)
+        if (!(key in hash) && !(camelizedKey in hash)) {
           hash[key] = value[key]
 
           if (isSync) {
             const on = data.on || (data.on = {})
-            on[`update:${key}`] = function ($event) {
+            on[`update:${camelizedKey}`] = function ($event) {
               value[key] = $event
             }
           }

filename: test/unit/features/directives/bind.spec.js
patch: @@ -187,6 +187,26 @@ describe('Directive v-bind', () => {
     }).then(done)
   })
 
+  it('bind object with explicit overrides', () => {
+    const vm = new Vue({
+      template: `<test v-bind="test" data-foo="foo" dataBar="bar"/>`,
+      components: {
+        test: {
+          template: '<div :data-foo="dataFoo" :data-bar="dataBar"></div>',
+          props: ['dataFoo', 'dataBar']
+        }
+      },
+      data: {
+        test: {
+          dataFoo: 'hi',
+          dataBar: 'bye'
+        }
+      }
+    }).$mount()
+    expect(vm.$el.getAttribute('data-foo')).toBe('foo')
+    expect(vm.$el.getAttribute('data-bar')).toBe('bar')
+  })
+
   it('.sync modifier with bind object', done => {
     const vm = new Vue({
       template: `<test v-bind.sync="test"/>`,
Repository: ollama/ollama
Pull request: [readme]: Add ollama-d library

doc: https://ollama-d.dpldocs.dlang.org/ollama.html
pkg-info: https://code.dlang.org/packages/ollama-d

cc: @BruceMacD 

Changed files:
filename: README.md
patch: @@ -512,6 +512,7 @@ See the [API documentation](./docs/api.md) for all endpoints.
 - [Ollama for Zig](https://github.com/dravenk/ollama-zig)
 - [Abso](https://github.com/lunary-ai/abso) (OpenAI-compatible TypeScript SDK for any LLM provider)
 - [Nichey](https://github.com/goodreasonai/nichey) is a Python package for generating custom wikis for your research topic
+- [Ollama for D](https://github.com/kassane/ollama-d)
 
 ### Mobile
Repository: nodejs/node
Pull request: zlib: reduce code duplication

The offset in the allocated memory was calculated in alloc and free, this makes it a single constant so it only needs to be defined once.

As requested by @Flarna in https://github.com/nodejs/node/pull/57727

Changed files:
filename: src/node_zlib.cc
patch: @@ -612,9 +612,11 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
     return AllocForBrotli(data, real_size);
   }
 
+  static constexpr size_t reserveSizeAndAlign =
+      std::max(sizeof(size_t), alignof(max_align_t));
+
   static void* AllocForBrotli(void* data, size_t size) {
-    constexpr size_t offset = std::max(sizeof(size_t), alignof(max_align_t));
-    size += offset;
+    size += reserveSizeAndAlign;
     CompressionStream* ctx = static_cast<CompressionStream*>(data);
     char* memory = UncheckedMalloc(size);
     if (memory == nullptr) [[unlikely]] {
@@ -623,16 +625,15 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
     *reinterpret_cast<size_t*>(memory) = size;
     ctx->unreported_allocations_.fetch_add(size,
                                            std::memory_order_relaxed);
-    return memory + offset;
+    return memory + reserveSizeAndAlign;
   }
 
   static void FreeForZlib(void* data, void* pointer) {
     if (pointer == nullptr) [[unlikely]] {
       return;
     }
     CompressionStream* ctx = static_cast<CompressionStream*>(data);
-    constexpr size_t offset = std::max(sizeof(size_t), alignof(max_align_t));
-    char* real_pointer = static_cast<char*>(pointer) - offset;
+    char* real_pointer = static_cast<char*>(pointer) - reserveSizeAndAlign;
     size_t real_size = *reinterpret_cast<size_t*>(real_pointer);
     ctx->unreported_allocations_.fetch_sub(real_size,
                                            std::memory_order_relaxed);
Repository: vercel/next.js
Pull request: Update font data

This auto-generated PR updates font data with latest available

Changed files:
filename: packages/font/src/google/font-data.json
patch: @@ -7762,6 +7762,11 @@
     "styles": ["normal"],
     "subsets": ["cyrillic", "cyrillic-ext", "devanagari", "latin", "latin-ext"]
   },
+  "LINE Seed JP": {
+    "weights": ["100", "400", "700", "800"],
+    "styles": ["normal"],
+    "subsets": ["cyrillic", "greek-ext", "latin", "latin-ext"]
+  },
   "LXGW Marker Gothic": {
     "weights": ["400"],
     "styles": ["normal"],
@@ -11076,9 +11081,34 @@
     "subsets": ["latin", "latin-ext", "multani"]
   },
   "Noto Sans Myanmar": {
-    "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],
+    "weights": [
+      "100",
+      "200",
+      "300",
+      "400",
+      "500",
+      "600",
+      "700",
+      "800",
+      "900",
+      "variable"
+    ],
     "styles": ["normal"],
-    "subsets": ["myanmar"]
+    "axes": [
+      {
+        "tag": "wdth",
+        "min": 62.5,
+        "max": 100,
+        "defaultValue": 100
+      },
+      {
+        "tag": "wght",
+        "min": 100,
+        "max": 900,
+        "defaultValue": 400
+      }
+    ],
+    "subsets": ["latin", "latin-ext", "myanmar"]
   },
   "Noto Sans NKo": {
     "weights": ["400"],

filename: packages/font/src/google/index.ts
patch: @@ -12388,6 +12388,18 @@ export declare function Kurale<
     'cyrillic' | 'cyrillic-ext' | 'devanagari' | 'latin' | 'latin-ext'
   >
 }): T extends undefined ? NextFont : NextFontWithVariable
+export declare function LINE_Seed_JP<
+  T extends CssVariable | undefined = undefined,
+>(options: {
+  weight: '100' | '400' | '700' | '800' | Array<'100' | '400' | '700' | '800'>
+  style?: 'normal' | Array<'normal'>
+  display?: Display
+  variable?: T
+  preload?: boolean
+  fallback?: string[]
+  adjustFontFallback?: boolean
+  subsets?: Array<'cyrillic' | 'greek-ext' | 'latin' | 'latin-ext'>
+}): T extends undefined ? NextFont : NextFontWithVariable
 export declare function LXGW_Marker_Gothic<
   T extends CssVariable | undefined = undefined,
 >(options: {
@@ -17701,8 +17713,8 @@ export declare function Noto_Sans_Multani<
 }): T extends undefined ? NextFont : NextFontWithVariable
 export declare function Noto_Sans_Myanmar<
   T extends CssVariable | undefined = undefined,
->(options: {
-  weight:
+>(options?: {
+  weight?:
     | '100'
     | '200'
     | '300'
@@ -17712,6 +17724,7 @@ export declare function Noto_Sans_Myanmar<
     | '700'
     | '800'
     | '900'
+    | 'variable'
     | Array<
         '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
       >
@@ -17721,7 +17734,8 @@ export declare function Noto_Sans_Myanmar<
   preload?: boolean
   fallback?: string[]
   adjustFontFallback?: boolean
-  subsets?: Array<'myanmar'>
+  subsets?: Array<'latin' | 'latin-ext' | 'myanmar'>
+  axes?: 'wdth'[]
 }): T extends undefined ? NextFont : NextFontWithVariable
 export declare function Noto_Sans_NKo<
   T extends CssVariable | undefined = undefined,
Repository: facebook/react
Pull request: Remove Dead Code in WWW JS

Reviewed By: kassens

Differential Revision: D77531947




Changed files:
filename: packages/react-server/src/ReactFizzServer.js
patch: @@ -4661,10 +4661,6 @@ function abortTask(task: Task, request: Request, error: mixed): void {
     if (node !== null && typeof node === 'object') {
       // Push a fake component stack frame that represents the await.
       pushHaltedAwaitOnComponentStack(task, node._debugInfo);
-      if (task.thenableState !== null) {
-        // TODO: If we were stalled inside use() of a Client Component then we should
-        // rerender to get the stack trace from the use() call.
-      }
     }
   }
Repository: ggml-org/llama.cpp
Pull request:  ggml/hip: fix APU compatibility - soft error handling for hipMemAdviseSetCoarseGrain

 Description:
  ## Problem

  On AMD APU/iGPU devices (unified memory architecture, e.g. AMD Strix Halo gfx1151), `hipMemAdviseSetCoarseGrain` returns
  `hipErrorInvalidValue` because this hint is not applicable to UMA systems. The current code wraps this call in `CUDA_CHECK()`, which treats
  it as a fatal error and crashes.

  ## Fix

  Treat `hipMemAdviseSetCoarseGrain` as an **optional performance hint**:
  - Remove `CUDA_CHECK()` wrapper
  - Clear any resulting error with `hipGetLastError()` to prevent propagation

  This matches the intent of the existing comment ("fall back to cudaMalloc if not supported") and is consistent with how optional hints are
  handled elsewhere.

  ## Additional Changes

  - Add `GGML_LOG_DEBUG` pre-allocation memory logging to help diagnose memory issues on APU systems
  - Store `totalGlobalMem` in device info struct for future use

  ## Testing

  Tested on AMD Strix Halo (gfx1151), 128GB unified memory, Windows 11:
  - ✅ Before: crash on `hipMemAdviseSetCoarseGrain` with `hipErrorInvalidValue`
  - ✅ After: runs successfully, no error propagation

  ## Context: ROCm APU Large BAR Bug

  AMD APUs on Windows are currently limited to ~64GB `hipMallocManaged` allocations due to a ROCm runtime bug where `largeBar_` is
  unconditionally disabled for all APU devices in HIP mode. This causes the Windows GART allocator's 50%-of-RAM cap to trigger prematurely.

  A fix has been submitted to ROCm upstream:
  **https://github.com/ROCm/rocm-systems/pull/4077**

  Without that ROCm fix, APUs are still limited to ~64GB regardless of this change. However, this PR is independently valuable:
  1. Prevents crashes on APUs with current ROCm versions
  2. Enables full functionality once users update to a patched ROCm runtime
  3. The debug logging helps users diagnose memory allocation issues

  ## Impact

  - ✅ APU/iGPU users: no more crashes when using `GGML_CUDA_ENABLE_UNIFIED_MEMORY`
  - ✅ Discrete GPU users: no change (hint is valid and still applied)
  - ✅ No performance regression

Changed files:
filename: ggml/src/ggml-cuda/ggml-cuda.cu
patch: @@ -124,7 +124,10 @@ static cudaError_t ggml_cuda_device_malloc(void ** ptr, size_t size, int device)
         err = cudaMallocManaged(ptr, size);
 #if defined(GGML_USE_HIP)
         if (err == hipSuccess) {
-            CUDA_CHECK(cudaMemAdvise(*ptr, size, hipMemAdviseSetCoarseGrain, device));
+            // hipMemAdviseSetCoarseGrain is an optional performance hint;
+            // ignore errors (e.g. hipErrorInvalidValue on some APU/iGPU configs).
+            cudaMemAdvise(*ptr, size, hipMemAdviseSetCoarseGrain, device);
+            (void)hipGetLastError(); // clear any error
         }
 
         // fall back to cudaMalloc if not supported (e.g. on Windows)
Repository: vuejs/vue
Pull request: Fixed `RenderContext.scopedSlots` types bug

<!--
Please make sure to read the Pull Request Guidelines:
https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines
-->

<!-- PULL REQUEST TEMPLATE -->
<!-- (Update "[ ]" to "[x]" to check a box) -->

**What kind of change does this PR introduce?** (check at least one)

- [x] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [ ] Other, please describe:

**Does this PR introduce a breaking change?** (check one)

- [ ] Yes
- [x] No

If yes, please describe the impact and migration path for existing applications:

**The PR fulfills these requirements:**

- [x] It's submitted to the `dev` branch for v2.x (or to a previous version branch), _not_ the `master` branch
- [x] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
- [x] All tests are passing: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#development-setup
- [x] New/updated tests are included

If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

**Other information:**
Fixed #9616.


Changed files:
filename: types/options.d.ts
patch: @@ -1,5 +1,5 @@
 import { Vue, CreateElement, CombinedVueInstance } from "./vue";
-import { VNode, VNodeData, VNodeDirective, ScopedSlot } from "./vnode";
+import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from "./vnode";
 
 type Constructor = {
   new (...args: any[]): any;
@@ -140,7 +140,7 @@ export interface RenderContext<Props=DefaultProps> {
   data: VNodeData;
   parent: Vue;
   listeners: { [key: string]: Function | Function[] };
-  scopedSlots: { [key: string]: ScopedSlot };
+  scopedSlots: { [key: string]: NormalizedScopedSlot };
   injections: any
 }
 

filename: types/test/vue-test.ts
patch: @@ -147,6 +147,13 @@ const FunctionalHelloWorldComponent = Vue.extend({
   }
 });
 
+const FunctionalScopedSlotsComponent = Vue.extend({
+  functional: true,
+  render(h, ctx) {
+    return ctx.scopedSlots.default && ctx.scopedSlots.default({}) || h('div', 'functional scoped slots');
+  }
+});
+
 const Parent = Vue.extend({
   data() {
     return { greeting: 'Hello' }

filename: types/vue.d.ts
patch: @@ -12,7 +12,7 @@ import {
   ThisTypedComponentOptionsWithRecordProps,
   WatchOptions,
 } from "./options";
-import { VNode, VNodeData, VNodeChildren, ScopedSlot, NormalizedScopedSlot } from "./vnode";
+import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from "./vnode";
 import { PluginFunction, PluginObject } from "./plugin";
 
 export interface CreateElement {
Repository: facebook/react
Pull request: Align `AttributeConfiguration` type in `ReactNativeTypes`

<!--
  Thanks for submitting a pull request!
  We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory.

  Before submitting a pull request, please make sure the following is done:

  1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`.
  2. Run `yarn` in the repository root.
  3. If you've fixed a bug or added code that should be tested, add tests!
  4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
  5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`.
  6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect".
  7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
  8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

  Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

This PR aligns `AttributeConfiguration` in `ReactNativeTypes` to generate proper TS definitions using `flow-api-translator`. Currently, the generated TS type produces ts error due to mismatch in style and object indexer type:

![Screenshot 2025-06-30 at 15 06 18](https://github.com/user-attachments/assets/1e3ce921-ee99-4d2e-a645-6cc434ff657f)

<!--
 Explain the **motivation** for making this change. What existing problem does the pull request solve?
-->

## How did you test this change?

Changed in react-native repo and regenerated the snapshot.

<!--
  Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface.
  How exactly did you verify that your PR solves the issue you wanted to solve?
  If you leave this empty, your PR will very likely be closed.
-->


Changed files:
filename: packages/react-native-renderer/src/ReactNativeTypes.js
patch: @@ -34,7 +34,7 @@ export type AttributeType<T, V> =
 export type AnyAttributeType = AttributeType<$FlowFixMe, $FlowFixMe>;
 
 export type AttributeConfiguration = $ReadOnly<{
-  [propName: string]: AnyAttributeType,
+  [propName: string]: AnyAttributeType | void,
   style?: $ReadOnly<{
     [propName: string]: AnyAttributeType,
     ...
Repository: nodejs/node
Pull request: src: fix pointer alignment

The NgLibMemoryManager::ReallocImpl method prefixes the allocated memory with its size, and returns a pointer to the region after it. This pointer can however no longer be suitably aligned.

On Arm 32bits this resulted in unaligned accesses, since the NEON vst1.64 instruction was used with a not properly aligned addresses. A reproducer is available at https://github.com/victronenergy/venus/issues/1559.

Correct this by allocating the maximum of the the size of the size_t and the max alignment.


Changed files:
filename: src/node_mem-inl.h
patch: @@ -8,6 +8,8 @@
 
 namespace node {
 namespace mem {
+static constexpr size_t kReserveSizeAndAlign =
+    std::max(sizeof(size_t), alignof(max_align_t));
 
 template <typename Class, typename AllocatorStruct>
 AllocatorStruct NgLibMemoryManager<Class, AllocatorStruct>::MakeAllocator() {
@@ -30,19 +32,18 @@ void* NgLibMemoryManager<Class, T>::ReallocImpl(void* ptr,
   char* original_ptr = nullptr;
 
   // We prepend each allocated buffer with a size_t containing the full
-  // size of the allocation.
-  if (size > 0) size += sizeof(size_t);
+  // size of the allocation, while keeping the returned pointer aligned.
+  if (size > 0) size += kReserveSizeAndAlign;
 
   if (ptr != nullptr) {
     // We are free()ing or re-allocating.
-    original_ptr = static_cast<char*>(ptr) - sizeof(size_t);
+    original_ptr = static_cast<char*>(ptr) - kReserveSizeAndAlign;
     previous_size = *reinterpret_cast<size_t*>(original_ptr);
     // This means we called StopTracking() on this pointer before.
     if (previous_size == 0) {
       // Fall back to the standard Realloc() function.
       char* ret = UncheckedRealloc(original_ptr, size);
-      if (ret != nullptr)
-        ret += sizeof(size_t);
+      if (ret != nullptr) ret += kReserveSizeAndAlign;
       return ret;
     }
   }
@@ -62,7 +63,7 @@ void* NgLibMemoryManager<Class, T>::ReallocImpl(void* ptr,
     manager->env()->external_memory_accounter()->Update(
         manager->env()->isolate(), new_size);
     *reinterpret_cast<size_t*>(mem) = size;
-    mem += sizeof(size_t);
+    mem += kReserveSizeAndAlign;
   } else if (size == 0) {
     manager->DecreaseAllocatedSize(previous_size);
     manager->env()->external_memory_accounter()->Decrease(
@@ -95,8 +96,8 @@ void* NgLibMemoryManager<Class, T>::CallocImpl(size_t nmemb,
 
 template <typename Class, typename T>
 void NgLibMemoryManager<Class, T>::StopTrackingMemory(void* ptr) {
-  size_t* original_ptr = reinterpret_cast<size_t*>(
-      static_cast<char*>(ptr) - sizeof(size_t));
+  size_t* original_ptr =
+      reinterpret_cast<size_t*>(static_cast<char*>(ptr) - kReserveSizeAndAlign);
   Class* manager = static_cast<Class*>(this);
   manager->DecreaseAllocatedSize(*original_ptr);
   manager->env()->external_memory_accounter()->Decrease(