Heat the butter and olive oil in a large skillet over medium heat. Add the sliced onions, sugar, and salt, then cook for 20 to 25 minutes, stirring often, until the onions turn golden and soft.
Remove the skillet from the heat and stir in the thyme leaves and a few grinds of black pepper. Let the onion mixture cool slightly.
Heat the oven to 400°F and line a baking sheet with parchment paper. Roll out the puff pastry on a lightly floured surface and cut it into 8 small squares or rounds.
Place the pastry pieces on the baking sheet. Spoon the caramelized onions evenly over each piece, then top with the shredded Gruyère cheese.
Bake for 15 to 18 minutes until the pastry is golden and the cheese has melted. Serve warm.