Skip to content

Conversation

@anmyachev
Copy link
Contributor

@anmyachev anmyachev commented Oct 17, 2025

}
}

extern "C" EXPORT_FUNC PyObject *get_native_code(PyObject *args) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of this function is taken from the implementation of load_binary function, as I've decided to leave it alone for now to avoid introducing regressions. However, there's potential to reduce code duplication there.

zebin = f.read()
from triton.runtime.driver import driver
# at this stage the driver is already initialized
device = driver.active.utils.get_current_device()
Copy link
Contributor

Choose a reason for hiding this comment

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

The triton.compile maybe not target to the current device. The compilation flow should not depends on the runtime. It can be used as cross compiling and AOT compiling.

self.get_native_code = mod.get_native_code
self.get_device_properties = mod.get_device_properties
self.device_count = mod.init_devices(self.get_sycl_queue())
# breakpoint()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# breakpoint()

try {
auto [l0_module_dgrf, l0_kernel_dgrf, n_spills_dgrf] =
compileLevelZeroObjects(binary_ptr, binary_size, kernel_name,
l0_device, l0_context, build_flags(), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
l0_device, l0_context, build_flags(), true);
l0_device, l0_context, build_flags(), true /*is_spv*/);


if (!PyArg_ParseTuple(args, "sSisi", &name, &py_bytes, &shared,
&build_flags_ptr, &devId)) {
std::cerr << "loadBinary arg parse failed" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
std::cerr << "loadBinary arg parse failed" << std::endl;
std::cerr << "get_native_code arg parse failed" << std::endl;

@anmyachev anmyachev closed this Oct 20, 2025
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.

Generate native code using L0 sdk instead of ocloc

4 participants