{"id":17086228,"url":"https://github.com/kach/optimally-framing-roger-rabbit","last_synced_at":"2026-05-09T15:32:31.607Z","repository":{"id":66653319,"uuid":"231167772","full_name":"kach/optimally-framing-roger-rabbit","owner":"kach","description":"accelerating accelerators with differentiable kD-trees","archived":false,"fork":false,"pushed_at":"2020-01-01T04:59:29.000Z","size":1054,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T14:37:00.416Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kach.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-01T02:34:39.000Z","updated_at":"2023-12-20T00:12:41.000Z","dependencies_parsed_at":"2023-02-28T16:30:58.440Z","dependency_job_id":null,"html_url":"https://github.com/kach/optimally-framing-roger-rabbit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kach/optimally-framing-roger-rabbit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Foptimally-framing-roger-rabbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Foptimally-framing-roger-rabbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Foptimally-framing-roger-rabbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Foptimally-framing-roger-rabbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kach","download_url":"https://codeload.github.com/kach/optimally-framing-roger-rabbit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Foptimally-framing-roger-rabbit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32824334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T13:27:57.270Z","updated_at":"2026-05-09T15:32:31.590Z","avatar_url":"https://github.com/kach.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a silly idea I had last year...\n\nSome raytracers use a data structure called a kD-tree to store all the objects\nin the scene. The kD-tree narrows down the set of objects you have to check ray\nintersections with, speeding up the rendering process. It does this by\nrepeatedly splitting up the space using planes parallel to the XY, YZ, or XZ\nplanes, essentially creating a spatial binary tree.\n\nBecause the planes are aligned to the axes, it turns out that you _might_ be\nable to do slightly better by rotating your entire scene a little bit. What do\nI mean by \"do better\"? I mean lower the number of ray-object intersection tests\nthat need to be done. Clearly there's no way to know this ahead of time, but\nthere's a good heuristic called the Surface Area Heuristic (SAH) that assumes\nthat rays will be roughly randomly distributed around the scene.\n\nThe idea was to \"learn\" an optimal rotation by gradient descent on SAH.\nSpecifically, given a function that takes a set of vertices and puts them in a\nkD-tree, returning the SAH, I want to find some optimal rotation R on those\nvertices that minimizes that function. This requires the SAH computation, and\nthus the kD-tree generation, to be \"differentiable\" (i.e. all math is done on\nPyTorch tensors...).\n\nOkay, okay, so does it work? I'm not sure. It's doing _something_ (see the GIF\nof the rotating rabbit below, notice that it \"converges\" eventually!) but I\nhave not yet tried it on a scene large enough to get a perceptible speed bump\nout of PBRT. It's possible that there is a small speedup but it's negligible\nenough to get wiped out in statistical noise...\n\n![rotating rabbit](out.gif)\n\n---\n\nBesides `numpy` and `torch`, you also need the Python `plyfile` module:\nhttps://github.com/dranjan/python-plyfile\n\nI've been testing things on a Stanford bunny model:\nhttp://graphics.stanford.edu/data/3Dscanrep/\n\nAnd here are some CS348B notes on accelerators... in fact the lecture that\ninspired this whole idea in the first place:\nhttp://graphics.stanford.edu/courses/cs348b/lecture/rt2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkach%2Foptimally-framing-roger-rabbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkach%2Foptimally-framing-roger-rabbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkach%2Foptimally-framing-roger-rabbit/lists"}