Preheat the oven to 425 degrees F. Prepare a large rimmed baking sheet with parchment paper. Place the sweet potatoes on the prepared baking sheet. Use a fork to pierce holes in the sweet potatoes, then coat them generously with 1 Tablespoon olive oil. Transfer to the oven and roast for 55-60 minutes or until very tender. (Note: make sure your sweet potatoes are very tender, otherwise the blender in the following steps will not whip the sweet potatoes and the motor will stall).
Meanwhile, heat the remaining 1 Tablespoon olive oil in a large skillet over medium heat. Sauté the onions with 1/2 teaspoon sea salt for 25 minutes or until caramelized and very tender, stirring often. Lower the heat to medium-low, as needed. Stir in the fresh rosemary. Set aside.
Remove the sweet potatoes from the oven. Discard (or eat later as a snack) the skin. Discard the oily parchment paper and use a clean sheet of parchment paper without oil. The parchment paper should be dry to roast the nuts. Spread the pecans and walnuts onto the prepared baking sheet. Roast for 8 minutes or until fragrant and golden brown. Remove from the oven. Immediately add the fresh rosemary, thyme, olive oil, cinnamon, sea salt and pepper. Use your hands to toss to combine on the baking sheet. Set aside.
Lower the oven temperature to 350 degrees F. Lightly grease an 8 x 11-inch baking dish with olive oil. Set aside.
Transfer the sweet potato flesh to a high-speed blender with the remaining 1 1/2 teaspoons sea salt, vanilla extract, cinnamon, pumpkin pie spice and nutmeg. Puree until silky smooth. Season to taste. Pour half of the whipped sweet potatoes into the prepared baking dish. Use the back of a large spoon to create a smooth layer, covering the entire surface. Layer the caramelized onions on top, followed by the remaining whipped sweet potatoes. Use the back of a large spoon to create a smooth top layer. Sprinkle the rosemary pecan topping over the surface, covering the top layer of sweet potatoes. Place the casserole in the oven for 30 minutes or until warm throughout. Remove from the oven. Set aside to cool for 5 minutes. Spoon into serving bowls. Serve warm.
Store leftovers in a sealed container in the refrigerator for up to 5 days.