Skip to content

Unmappable dims used for inlining should be leaf domains instead of root domains #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zasdfgbnm opened this issue Sep 30, 2022 · 2 comments
Assignees

Comments

@zasdfgbnm
Copy link
Collaborator

🐛 Describe the bug

Currently, inlining uses unmappable dims in MaxPosCalculator to avoid inlining into illegal dims. However, the unmappable dims in MaxPosCalculator only contains root domains, which is a mistake and can result wrong CA position being set. See the following example:

TEST_F(NVFuserTest, FusionUnmappableLeaf_CUDA) {
  Fusion fusion;
  FusionGuard fg(&fusion);

  TensorView* tv0 = makeConcreteTensor({4});
  fusion.addInput(tv0);
  auto tv1 = sin(tv0);
  auto tv2 = cos(tv1);
  auto tv3 = exp(tv2);
  auto tv4 = add(tv1, tv3);
  fusion.addOutput(tv4);

  tv3->split(0, 2);
  inlineMost();

  // For old code, use
  // InlinePropagator ip(tv0, -1, ComputeAtMode::MostInlined);
  // MaxRootDomainInfoSpanningTree(tv0).traverse(&ip);

  auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0);

  at::Tensor input = at::randn({4}, options);

  FusionExecutor fe;
  fe.compileFusion(&fusion);
  auto cg_outputs = fe.runFusion({input});

  auto t1 = input.sin();
  at::Tensor output_ref = t1 + t1.cos().exp();

  testValidate(&fusion, cg_outputs, {input}, {output_ref}, __LINE__, __FILE__);
}

Note that this bug is NOT introduced in #2004

Versions

TOT devel

@zasdfgbnm zasdfgbnm self-assigned this Sep 30, 2022
@zasdfgbnm
Copy link
Collaborator Author

Self assign as one of my upcomming refactoring of MaxPosCalculator should fix this. Will not be high priority because I don't see any scheduler triggers such an error.

@zasdfgbnm
Copy link
Collaborator Author

cc @naoyam @csarofeen

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

No branches or pull requests

1 participant