Skip to content

Conversation

@happyme531
Copy link

@happyme531 happyme531 commented Oct 23, 2025

Ensure every ONNX pass hydrates external tensor data after loading the IR model. This avoids writing broken references when saving quantized or converted models with external weights, restoring the behavior seen in v0.9.1.

Describe your changes

  • load external tensor data into the in-memory IR model for conversion, HQQ and RTN quantization
  • hydrate external data before running ONNXScript fusions so the passes can safely rewrite the graph
  • restores the ability to emit valid quantized models with external weights after the IR migration

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.

(Optional) Issue link

Fixes #2223

Ensure every ONNX pass hydrates external tensor data after loading the IR model. This avoids writing broken references when saving quantized or converted models with external weights, restoring the behavior seen in v0.9.1.
@happyme531
Copy link
Author

@happyme531 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@xiaoyu-work
Copy link
Collaborator

Thanks for the PR! Did you verify this change work for your case?

@happyme531
Copy link
Author

Thanks for the PR! Did you verify this change work for your case?

Yeah, but I haven't added a test yet.

@xiaoyu-work
Copy link
Collaborator

Thanks for the PR! Did you verify this change work for your case?

Yeah, but I haven't added a test yet.

I tried to repro your error with Qwen/Qwen2.5-0.5B-Instruct:

olive capture-onnx-graph -m Qwen/Qwen2.5-0.5B-Instruct --o onnx_model
olive quantize -m onnx_model --algorithm hqq --precision int4 --o quantized_model

Then load with model = onnx.load("model.onnx") or run onnxslim --inspect --model-check --verbose model.onnx, but I didn't get any error.

Can you tell me more details about how you exported the onnx model? From the error

onnx.onnx_cpp2py_export.checker.ValidationError: Data of TensorProto ( tensor name: /backbone/layers.0/self_attn/rotary_emb/Constant_attr::value) should be stored in PSALM/onnx/onnx_models_quantized/language_model.onnx/model/_backbone_layers.0_self_attn_rotary_emb_Constant_attr__value, but it doesn't exist or is not accessible.

looks like something wrong with the constant. Your model seems an edge case. There is one assumption, but I need to verify it. I have 2 solutions here: can you share your .onnx model file to me, so i can repro the issue? That will be easier to investigate the root cause. Or i have a potential fix here https://github.com/microsoft/Olive/tree/xiaoyu/ir. If you can you try to install Olive with this branch and verify if this change works, that is fine also.

@jambayk jambayk closed this Jan 1, 2026
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.

[Bug] ONNX Quantization Broken Since v0.9.2 Due to Incorrect Weight Data Saving

3 participants